Posts

Showing posts from March, 2012

Trouble understanding children() and :first in jQuery -

i confused how selection of element in jquery works using children() , :first custom class? for instance, in jsfiddle , code ul > li {hello nest} not class .emphasis first-child of top level ul gets it. expected inner li class. the commented out line in jquery code works expect to. :first selector returns first matched item among selected so $('ul').children('li:first').addclass('emphasis'); selects children of ul li , takes first of them. whereas $('ul > li:first-child').addclass('emphasis'); takes li direct children of ul , takes every first child of matched set.

javascript - Emacs - replace some string pattern with another string pattern -

i need make js file more friendly node.js module it has bunch of statements these function somefunction(jjjj){ and need transformed into exports.somefunction = function(jjjj){ even better if there call somefunction in code somefunction(bla); it replaced exports.somefunction well. you can use replace-regexp : m-x replace-regexp <ret> \(function\) \(.*\)(\(.*\)){ <ret> export.\2 = \1(\3)) i'm not sure can replace codes of calling functions, however, if there pattern, try.

php - Filtering record from last month and current year -

i need query, 1 works fine, thing returns me ingresos . need retrieve records of last month , current year. i have tried interval 1 month returns me previous month based on today's day. need records of last month without counting first last date. this 1 when e page loaded first: select * ingresos fechareporteing < date_sub(curdate(),interval dayofmonth(curdate()) day) and 1 when user selects specific month: select * ingresos fechareporteing < date(concat(year(curdate()),"-",'.$_post['mes'].',"-","0")) this works me. used php calculate date based on month selected user. <?php //get users month. $month = isset($_get['mes'])? $_get['mes'] : "04"; //starting date string `current year`-`user month`-`first day` $startdatetext = date('y') . "-" . $month . "-01"; //add 1 month starting date. $startdate = date_create($startdatetext); $enddate = date_add($s

python - Changing Values in a xml file -

i trying change numerous values in xml document. have tried couple different things dont seem change seem access file modification time changes value doesnt. from xml.etree import elementtree et import os import xml path = os.path.expanduser(r'~\appdata\roaming\etc\etc\somefile.xml') et = et.parse(path) name in et.findall('name'): if name == 'sometext1': name.text = "sometext2" et.write(path) and secondly tried attributeerror: 'str' object has no attribute 'text' with open(path,'r+') f: tree = et.parse(f) node in tree.iter('favourite'): name = node.attrib.get('name') if name == 'sometext1': name.text = "sometext2" tree.write(path) could advise ive gone wrong the line et = et.parse(path) uses et module on right , variable name on left. after point, not possible (or @ least overly hard) access elementtree module. disambiguate et . let, say, et module

python - Nested dict comprehension -

in following code, [{word: score_tweet(tweet) word in tweet} tweet in tweets] i getting list of dicts: [{u'soad': 0.0, u'&lt;3': 0.0}, {u'outros': 0.0, u'acredita': 0.0}] i obtain 1 flat dict like: {u'soad': 0.0, u'&lt;3': 0.0, u'outros': 0.0, u'acredita': 0.0} how should change code? note: using python 2.7. {word: score_tweet(tweet) tweet in tweets word in tweet}

django - When I catch the data in my views, how I clean the data? -

example: url(r'^/users/(?p<usr>[0-9]+)/$', 'home.views.who_user'), how have clean usr in view? when access usr in view, in case, number specified regular expression. requests urls of above format value of usr not number receive 404 page. i.e. /users/abcd/ return 404 that being said, you'll still want validate usr in view. example, can inferred intend the usr variable should refer existing django user. in case, you'll want check see if user exists. here example lookup django user based on user id (assuming usr refers user id). return user instance if 1 exists, or 404 error page if 1 not. from django.shortcuts import get_object_or_404 django.contrib.auth.models import user def this_view(request, usr): user = get_object_or_404(user, pk=usr) ...

android - calling onCreate method from inside another method -

i have never seen explicitly call 1 of system callback methods oncreate() or ondestroy() inside method. looks wrong. thought saw in example , can not believe it. imagination or real? in code below onupgrade() method of sqliteopenhelper class, calling oncreate() method explicitly function. possible call oncreate() inside method? , there better way without calling oncreate()? private static class databasehelper extends sqliteopenhelper{ databasehelper(context context){ super(context, database_name, null, database_version); } @override public void oncreate(sqlitedatabase db) { db.execsql("create table if not exists " + table_name + " (" + lentitems.note_id + "id integer primary key autoincrement, " + lentitems.title + " text, " + lentitems.text + " text);"); } @override public void onupgrade(sqlitedatabase db, int previousversion, int newversion) { db.exec

php - Recursively list files in an archive -

i'm creating method inspect files in upload folder , of these files archive ( tar, tar.gz, zip, rar, etc ). read these archive files , list files in nested tree format. for example, have archive file called sandwich.tar.gz , listed below:- sandwich.tar.gz lettuce mayonaise cheese bread (directory) wholemeal my code far:- <?php $archive = new phardata('/upload/directory/sandwich.tar.gz'); foreach($archive $file) { echo $file . "<br />"; } but failed list files inside bread directory. how fix this? although question rather dated, considering stupidity , uselessness of previous answer, cannot reply. it seems whatever php non-standard , awkward @ best... you got right inspect first level. however, objects returned iteration not of same type, calling foreach on them lead failure. iterating on phardata object gives pharfileinfo ones. there can check file type (checking if directory inherited isdir

java - How to let XMLHttpRequest not cach in IE -

if(xmlhttp) { xmlhttp.open("get","dokterweek_klantoverzichtservletajax?" + $(this).prop("href").split("?")[1],true);//gettime servlet name xmlhttp.onreadystatechange = handleserverresponse; xmlhttp.setrequestheader('content-type', 'application/x-www-form-urlencoded'); xmlhttp.send(null); } }); }); function getxmlobject() //xml object { var xmlhttp = false; try { xmlhttp = new activexobject("msxml2.xmlhttp") // old microsoft browsers } catch (e) { try { xmlhttp = new activexobject("microsoft.xmlhttp") // microsoft ie 6.0+ } catch (e2) { xmlhttp = false // no browser accepts xmlhttp object false } } if (!xmlhttp && typeof xmlhttprequest != 'undefined') { xmlhttp = new xmlhttprequest(); //for mozilla, opera,chrome browsers } return xmlhttp; // mandatory statement returning ajax object created } var xmlhttp = new getxm

Auto-backup shell github -

i wrote script auto-backup website , script push resources github . wrote code in crontab let auto-execution. however, don't know why resources can't pushed. i can see heads .git has been modified (which means commit successfully). guess problem incorrect use of username. the information below output of auto-backup script. committer: root &lt;root@xxxx.(none)> name , email address configured automatically based on username , hostname. please check accurate. can suppress message setting them explicitly: git config --global user.name "your name" git config --global user.email you@example.com after doing this, may fix identity used commit with: git commit --amend --reset-author 1 file changed, 14 insertions(+), 14 deletions(-) how can deal it? the command in crontab: */2 * * * * root /var/backwiki.sh >/home/xxx/tmp/4.txt here main part of shell script: git pull origintyl master git add -a echo '2' git co

border - How to Make a 3D button using CSS? -

Image
i have css button looks this: that formed css code: .button{ color: #333; border: 1px solid orange; border-bottom: 5px solid orange; background-color: #fff; font-size: 12px; margin: 5px; padding: 1px 7px 1px 7px; display: inline-block; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; position: relative; top: 0px; } .button:hover{ cursor: hand; cursor: pointer; } .button:active{ border-bottom: 3px solid #999; top: 3px; } this trying make (but can't figure out how it): please pardon drawing skills. want extend orange border on left looks 3d. thanks! this close, not quite perfect. using box-shadow & border : .button { color: #333; box-shadow: -3px 3px orange, -2px 2px orange, -1px 1px orange; border: 1px solid orange; } http://jsfiddle.net/grytz/3/

java - Exit from HttpClient session -

how exit httpclient session? i use following code login application using apache httpclient public httpclient logintohexgen(string username, string password) { httpclient client = new defaulthttpclient(); // send post url login hexgen httppost post = new httppost("http://localhost:8080/j_spring_security_check"); try { // set user name , password list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(1); namevaluepairs.add(new basicnamevaluepair("j_username", username)); namevaluepairs.add(new basicnamevaluepair("j_password", password)); post.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = client.execute(post); httpentity entity = response.getentity(); if (entity != null) { post.abort(); } } catch (ioexception e) { e.pr

git - Merge Request not working GitLab -

i have been trying merge 2 branches gitlab keep getting message. checked no branch protected. you can accept request automatically. if still want manually - click here instructions after merge request button disables. tried bundle exec rake gitlab:app:enable_automerge rails_env=production error: could not locate gemfile being total noob gitlab , ubuntu having hard time understanding this. githost.log may 13, 2013 09:59 -> error -> command failed [1]: /opt/gitorious-2.4.12-1/git/bin/git --git-dir=/opt/gitlab-5.1.0-2/apps/gitlab/gitlab-satellites/testairtdl/.git push origin master remote: hooks/update:10: undefined method `require_relative' main:object (nomethoderror)[k remote: error: hook declined update refs/heads/master[k /opt/gitlab-5.1.0-2/apps/gitlab/repositories/testairtdl.git ! [remote rejected] master -> master (hook declined) error: failed push refs '/opt/gitlab-5.1.0-2/apps/gitlab/repositories/testairtdl.git' from gitl

objective c - How to get List of Only Purchased Product Ids fron inApp in ios? -

i having app in have 5 non consumable in app purchases. on every single in app purchase update db images. there 5 packages 5 non consumable in app purchases. now there restore purchase functionality non consumable in app purchase. there single restore button in app. how identify product has being purchased? i use following code restoring in app purchase. doesn't update db because doesn't know products purchased. if ([transaction.payment.productidentifier isequaltostring:@"pack1"]) { if ([[nsuserdefaults standarduserdefaults] boolforkey:@"haslaunchedp1once"]) { // app launched nslog(@"launching secondtime"); } else { [[nsuserdefaults standarduserdefaults] setbool:yes forkey:@"haslaunchedp1once"]; nslog(@"launching first time"); requesttext= @"animal"; [self makequeryforupdate]; [self

How to use ComboChart with GWT visualization -

anyone knows if posible use google combochart gwt . tried using wrapper in gwt visualization wrapper error sun.misc.invalidjarindexexception: invalid index im using jar found in gwt official jar yes can combine google combochart gwt easily. same jar mentioned. follow this link. . the error facing sounds jar version issue.

java - How can I transform input stream when I'm using stax2 XMLInputFactory2? -

parsing big xml files (500 - 800mb) using stax2 that: xmlstreamreader2 reader = (xmlstreamreader2) xmlif2.createxmlstreamreader(filename, new fileinputstream(filename)); to convert specific csv , have next problem. text nodes contains "&#x1;" sequence. in output file have replaced cyrillic letter "Ё". when parser found sequence "&#x1;", it's throw exception: [com.ctc.wstx.exc.wstxlazyexception] com.ctc.wstx.exc.wstxparsingexception: illegal character entity: expansion character (code 0x1 @ [row,col,system-id] in stax have same exception. can set transforation xml stream reader , replace &#x1; Ё automative while parsing??? can create intermediate file, replaced, , parse it, it's not idea error message indicates xml not well-formed: either encoding broken. sounds contains entity reference unicode character value 0x1. not allowed xml 1.0; although legal xml 1.1. perhaps xml document not declare "version

bash - Shuffle piped through sed gives different number of lines -

i have data file thousands of lines, each consisting of 5 numbers. example: 23 31 56 21 34 34 76 34 75 32 ... ... i want write bash script select n% lines @ random, , output them last entry set 0. remainder of entries want output line is. don't care in order lines output. my attempt @ doing shuffle file, take first n% of lines , use awk print them 0 in last place. output remainder of lines. here attempt: #! /bin/bash number=$2 numlines=$(less $1 | wc -l) number=$(echo $number'*'$numlines | bc) number=$(echo $number'/'100 | bc) shuffledfile=$(less $1 | shuf) # following line echos shuffled file, gets first $number lines, , prints them 0 in final column echo "$shuffledfile" | sed -n --unbuffered "1,/$number/p" | awk '{print $1" "$2-7200" "$3" "$4" 0"}' echo "$shuffledfile" | sed -n "/${number}/,/${numlines}/p" | awk '{print $1" "$2" "$3" &

HTML/CSS panel not displaying through JavaScript in PHP -

i trying make so, when user clicks on contact button @ bottom of page, php script check if message sent , show panel based on status. i've implemented css class display panel not working. sample: the script can found on adamginther.com http://jsfiddle.net/gintherthegreat/zfkmt/ <div id="contactme"> <p>whether you’re stopping hi or have inquiry, enjoy receiving messages. of employers out there, searching far , wide summer internship.</p> <br> <a href="https://www.facebook.com/whoisthecoolestpersonalive?ref=tn_tnmn"> <img src="images/facebook-512.png" height="50" width="50" alt="facebook" target="_new"> </a> <br> <br> <form action="contact.php" method="post"> <label name="firstname">name:</label> <input type="text" name="firstname"> <br&

SQL Server : select same colums count by date -

hi guys table l_date 2013-05-14 2013-05-12 2013-05-13 2013-05-15 and need dates , count result l_date <= selected like: l_date count (<=) 2013-05-14 3 2013-05-12 1 2013-05-13 2 2013-05-15 4 please try: select *, (select count(*) yourtable b b.l_date<=a.l_date) [count (<=)] yourtable

url - Not able to add {} in URI provided by axis-adb -

i have following piece of code need execute uri uri = new uri("http://localhost:8080/rest/{data}"); the uri in above example axis2-adb-1.5.1.jar - org.apache.axis2.databinding.types.uri i tired using axis2-adb-1.6.1.jar well. malformeduriexception stating "path contains invalid character:{". can use workaround , modify uri make work uri uri = new uri("http://localhost:8080/rest/%7bdata%7d"); however, looking options wherein dont need modify input. moreover, can answer me why axis jar have limitation. tried looking explanations not find any. found few days ago not valid scenario add curly braces in url. can added after proper encoding http://axis.apache.org/axis2/java/core/api/org/apache/axis2/databinding/types/uri.html states parsing of uri specification done according uri syntax described in rfc 2396, , amended rfc 2732. both rfc 2396 , rfc 2732 prescribes following other characters excluded because gateways , other transpor

html - Simple mathematical Calculator using jquery -

this code , want use pressing keys on keyboard , simple solution same helpful. should able perform multiple calculation. eg. 2+2+ -> 4+2+ -> 6+2= ->8. html: <div id="main"> <h2>simple calculator</h2> <input id="result" type="number" /> <div id="keys"> <div id="firstrow"> <button id="clearall" type="reset" value="ce" class="clean">ce</button> <button id="clear" type="reset" value="c" class="clean">c</button> <button id="add" type="button" value="+" class="operators operand">+</button> </div> <div id="secondrow"> <button id="one" type="button" value="1" class="show">1</button>

Copying Z3 Solver -

i have seen in post: is possible clone z3_context? ability copy/clone solver planned addition z3, facilitate backtracking behaviour. have looked in c api documentation , not find way this. is possible copy solver through c api? the api not have method copying solver object, can simulated using z3_solver_get_assertions , z3_solver_assert . idea create new solver object, , copy assertions old new.

c# - Validate values of all properties in list with a duplicate for custom method -

i need write method can compare 2 lists see whether there differences between two, without specifying property in 2 lists compare. instance cannot say: var exceptlist = list1.where (r => r.name !list2.any( r2.name == r.name )) the bold part needs dynamic can re-use method different types of lists. know following example won't work, need similar: var r = myleftlist.where(p => !myrighttlist.any(p2 => p2.gettype().getproperties().getvalue(myleftlist.indexof(p2)) == p.gettype().getproperties().getvalue(myrighttlist.indexof(p)))); you can use except extension method. see msdn being aware of point: if want compare sequences of objects of custom data type, have implement iequalitycomparer generic interface in class.

python - How to do image upload with Boothstrap and Django? -

i'm using bootstrap django. though i'm in python,i'm struggling figure out basic things file uploads/forms in bootstrap. there example that? also, there particular reason using filefield in django models? have tried file uploads documentation django cripsy forms bootstrap forms. the filefield ( docs ) automatically upload , save file model along giving various bit of additional functionality such upload to, getting absolute url file , ability delete file model object.

c# - mutiple search textboxes in asp.net -

i have multiple text-boxes , 1 drop-down list in system , i'm using query builder select data multiple tables in database (sql server), , display them in grid view suggestion id : (textbox) staff id: (textbox) status: (drop down list) staff name: (textbox) .............................. i want searching result work entering 1 field or multiple fields. problem is, when browse in internet test if queries worked or not, find works entering fields. this query generated in query builder (visual studio 2010) select suggestiondetail.suggestiondescription, suggestiondetail.suggestionid, suggestiondetail.dateofsubmission, employee.employeeid, employee.city, employee.employeename, category.categoryname, suggestionstatusdetail.dateoflastupdate, suggestionstatus.statusname employee inner join suggestiondetail on employee.employeeid = suggestiondetail.employeeid inner join category on suggestiondetail.categoryid = category.categoryid inner join suggestionstatusdetail on

getJSON not getting data from database -

function find() { var id = $('#id').val(); $.getjson("api/questionsanswer/" + id, function (data) { var str = data.username + ': $ ' + data.questions; $('#questionanswer').text(str); }) .fail ( function (jqxhr, textstatus, err) { $('#questionanswer').text('error: ' + err); }); } i try data display "null: null" seems data.username , data.questions wasn't capture... wrong code??

python - Reading selected portion of line and soting it in array -

how read every line of string in python , store seleted line element in array? i want read file line line , each line appended end of array. not find how anywhere , couldn't find how create array of strings in python. for example: line1= abc def gef lmn qrt lmh kjd lxm skd fdj djk ndz weg tdg ndg has dbg pef rah vdg pas dgh ghr bde ghx ore my output should be: line1[0]= abc def gef lmn qrt lmh kjd lxm line1[1]= skd fdj djk ndz weg tdg ndg has dbg line1[2]= pef rah vdg pas dgh ghr bde ghx ore >>> line1 = """abc def gef ... lmn qrt ... lmh kjd lxm ... ... skd fdj djk ... ndz weg tdg ... ndg has dbg ... ... pef rah vdg ... pas dgh ghr ... bde ghx ore""" >>> line1.split("\n\n") ['abc def gef\nlmn qrt was\nlmh kjd lxm', 'skd fdj djk\nndz weg tdg\nndg has dbg', 'pef rah vdg\npas dgh ghr\nbde ghx ore

ios - How to determine if score for the match has been submitted -

i working on turn based game uses game center. not save match data locally. while game goes on, 1 of players ends game , submit score him self. when other player launches game, gets matches game center (including finished). problem is, can not determine game had submitted score. better understanding list steps of scenerio. bob starts match alice accepts match alice plays & ends turn bob plays & ends turn ... ... ... bob ends match & submits score leaderboard alice launches game , gets game center 10 finished matches. now how know, matches did submit score. far know can not update match data, after match has finished. can not save flag match data anymore. do wrong , finish match early? should players have wait other players submit score? do have save match data locally? i thought using last turn date of match , save locally "last score submit date". saving match data or date locally bad multiple devices. another thing try: if usin

lucene - Complex queries with Solr 4 -

i fire complex queries in solr 4. if using lucene, can search using xml query parser , results need. however, not able see how use xml query parser in solr. i need able execute queries proximity searches, booleans, wildcards, span or, phrases (although these can handled proximity searches). guidance on material on how proceed welcome. regards puneet as far know it's still work in progress. more info can found @ jira . can of course use normal query language, it's capable of doing pretty complex things, example: "a proximity search"~2 , *wildcards* or "a phrase" as can see can search phrases, boolean operators (and, or, ...), span, proximity , wildcards. more information query syntax @ lucene documentation . solr added features on top of lucene query parser , more information can found @ solr wiki .

ios - making 300x300 webview scale 200x200 image -

i trying display images in uiwebview. image sizes 200x200. want make them scale , fill in 300x300 webview. i tried aspect modes not seem work. even webview.scalespagetofit = yes; doesnt work. missing obvious? you can following: webview.contentmode = uiviewcontentmodescaleaspectfit; or webview.contentmode = uiviewcontentmoderedraw; not on mac cannot test, should work. update soon also set, webview.autoresizessubviews = yes; edit :- found solution use html scale image, have question

jekyll - rdiscount enable parsing markdown within block html? -

is there global option rdiscount enable parsing markdown in block html tags? , way use option within octopress/jekyll? option kramdown supports: parse_block_html process kramdown syntax in block html tags if option true, kramdown parser processes content of block html tags text containing block-level elements. since not wanted normally, default false. better selectively enable kramdown processing via markdown attribute. default: false unfortunately, jekyll not pass kramdown flag kramdown. opened issue on that: https://github.com/mojombo/jekyll/issues/1095 no. there no rdiscount option this. options listed in api docs here: http://rdoc.info/github/davidfstr/rdiscount/rdiscount here workaround jekyll/octopress. consider following example: <div> want in *markdown*! </div> you can use markdownify tag in jekyll manually force section in markdown: <div> {% capture m %}i want in *markdown*!{% endcapture %} {{ m | markdo

Python & tumblr API: cannot log in to my own tumblr to create posts -

so have consumer key , consumer secret tumblr, , have following code allowing me oauth authentication, have no idea how log in own tumblr through python and/or pytumblr. can't post tumblr after using oauth. supposed login tumblr through api, or log in regularly though http python , use api? old tumblr api hasn't worked since sept 2012 believe, python-tumblr @ here doesn't work more can tell. instead i'm using pytumblr here . here's code: import urlparse import oauth2 import pytumblr request_token_url = 'http://www.tumblr.com/oauth/request_token' authorization_url = 'http://www.tumblr.com/oauth/authorize' access_token_url = 'http://www.tumblr.com/oauth/access_token' consumer_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' consumer_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' def test(): consumer = oauth2.consumer(consumer_key, consumer_secret) client = oauth2.client(consumer) resp, content = client.request(request_to

asp.net mvc - How to use dependency injection in ashx (Autofac, MVC4) -

public class autocompletecity : ihttphandler { public iautocompleterepository autocompleterepository { get; set; } public void processrequest(httpcontext context) { } } public static void registerdependencies() { var builder = new containerbuilder(); builder.registertype<autocompleterepository>().as<iautocompleterepository>).singleinstance(); icontainer container = builder.build(); dependencyresolver.setresolver(new autofacdependencyresolver(container)); } autocompleterepository registered singleinstance, null when calling processrequest . how can fix this? your code looks good. suspect missing in propertyinjectionmodule httpmodules setup in web.config. following module setup required autofac work asp.net: <add name="containerdisposal" type="autofac.integration.web.containerdisposalmodule, autofac.integration.web"/> <add name="propertyinjection" type="autofac.integration.

asp.net - EPiServer 7: Site crashed unless I'm logged in -

Image
when enter webpage in console: if log in episerver, not errors, , seems fixed little while, can log out , works couple of hours. anyone knows is? to me seems anonymous user trying access resources on server being redirected login page said resources. suggests everyone group cannot access resources. need grant everyone group read access resources. problematic resources seems in /scripts folder make sure everyone has read access it.

java - Solr Query to get the overall stats, not just the filtered ones -

i'm trying use solr statscomponent retrieve information product prices. problem if put filter on these prices, stats=true&stats.field=price&fq=price:[10 100] , stats requested range. price stats available products , not filtered ones. possible in single query? thanks, found out possible using groups. can use stats=true&stats.field=price&group=true&group.query=price:[10 100] , leave main fq other custom queries(or empty price available products). stats component return stats results of main fq , while having results of group.query in group component. way, can used numerical slider described in jira issue posted in comment. things tricky though when want use more 1 slider.

java - After session timeout redirect to last visited page for previous user -

when session timeout, redirect login page. need that, whether login user name same user name, logged in before session timeout, page redirect previous user visited page login page. for example, user name admin, when user open contactus.jsp, after session timeout page redirect login.jsp, in login.jsp whether same admin user logged in then, page redirect contactus.jsp instead of home.jsp. thanks in advance. one way of achieving using cookies. but best way below one. if using db in application can in below way: create table in db fields ip address , user name , last visited page . when user performs login , insert values table. when user performs logout or when session time out occurs , update table , set last visited page current jsp name. again @ login , before inserting row in table, make check on ip address . if row present current ip address , if user names match, retrieve last visited page value table , forward user jsp page.

couchdb - Couchbase Lite iOS: CouchCocoa's unversionedURL and CouchbaseLite's bodyURL, are they same? -

i've been working on couchbase-lite (aka touchdb) ios app. meanwhile, trying figure out what's new in cbl , faced following question: @property (readonly) nsurl* bodyurl; //cblattachment and @property (readonly) nsurl* unversionedurl; //couchattachment are these same? if not, what's alternative unversionedurl in new couchbaselite? i'm newbie touchdb, appreciate help. after few experiments, i've found out couchbase-lite's bodyurl looking for. there minor differences between url string returned unversionedurl , bodyurl result same. go ahead , replace unversionedurl bodyurl :)

java - How do I extract only the bold text from an HTML document? -

i need extract bold snippets in body of html document. need on server side using java (not on browser) the text on page can bold because of tags e.g. <b> , <h1> , etc., or because of inline css styling style="font-weight:bold;" , or because of external css styling using css clases. i using jsoup, can use other library done. thanks time! a plain javascript solution: on sufficiently new browsers, can use getpropertyvalue method retrieve computed style of element. can traverse document tree , check text nodes; text nodes not have style, need check parents: function consume(string) { console.log(string); } function traverse(tree) { var i; if(tree.nodetype === 3) { if(getcomputedstyle(tree.parentnode).getpropertyvalue('font-weight') === 'bold') { consume(tree.textcontent); } } for(i = 0; < tree.childnodes.length; i++) { traverse(tree.childnodes[i]); } } traverse(document.body); replace consume ow

How can I work with UIL to load images that are stored in the cacheDir of the app package in android? -

i use android universal image loading in android app load images internet , work perfect, no outofmemory errors. tried use local existing images in device (cache directory e.g /data/data/package-name/cache/...) without success did use file:// plus link of image seem have going wrong load images , doesn't. tried create own local imagedownloader extending imagedownloader didn't work either. clear : it's not permission problem, it's not path problem!, , images physically exist in cache directory. here's error have in logcat : 05-13 11:41:10.605: w/system.err(28789): java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1076) 05-13 11:41:10.605: w/system.err(28789): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:569) 05-13 11:41:10.613: w/system.err(28789): @ java.lang.thread.run(thread.java:856) 05-13 11:41:10.613: w/system.err(28789): caused by: libcore.io.errnoexception: open failed: enoent (no such f

java - Is it possible to use a "TypedQuery" as the DataSource of a JasperReport? -

i'm creating report ireport uses jpql datasource but there's 1 thing don't seem able do. can query work if fields i'm searching known java default, on example: select p.name person p in case map p.name java.lang.string <field name="name" class="java.lang.string"> <fielddescription><![cdata[column_1]]></fielddescription> </field> and voilà, works. but if query this: select p person p and map p com.myproject.person , <field name="person" class="com.myproject.person"> <fielddescription><![cdata[column_1]]></fielddescription> </field> i exception this: java.lang.classcastexception: com.myproject.person cannot cast [ljava.lang.object; that tells me can´t cast person array of java.lang.object when wanted result list of person is there way can run second query? place can set type of result? i have exported .jar file of project,

javascript - How can I target a specific link/click in jQuery? -

http://jsfiddle.net/kevinorin/khhdt/ after clicking open 1 of black bars/accordions (example: "greenhouse gases") have link "more/less info" suppose toggle more information. problem click function not on "more/less info" element entire "."happening-main-text" element. clicking anywhere in div activates toggle , shouldn't be. ideas how modify jquery target .readmore in div? // more/less info why is happening jquery('.readmore').closest(".happening-main-text").click(function() { jquery(this).children(".divmore").toggle('slow'); return false; }); use jquery('.readmore').click(function() { jquery(this).closest(".happening-main-text").children(".divmore").toggle('slow'); return false; }); w

winforms - How to deploy windows form applications on a winRT tablet (Surface)? -

is possible deploy windows form application winrt tablet? surface. the target platform win form application either x86 or x64 , not arm. hence not able build win form application tablet , hence not executed on tablet. thanks, soorya no, it's not supported scenario. can develop windows store (windows runtime known winrt) applications arm device running windows rt. windows forms (aka. winforms) applications desktop applications leveraging legacy desktop windows api/winapi/win32.

oauth - Errors running Google API calendar example for vb.net -

when try run this example in vbexpress 2010, following intellisense errors. scopes.add(calendarservice.scopes.calendar.getstringvalue()) this line generates: error 7 overload resolution failed because no accessible 'getstringvalue' specific these arguments: extension method 'public function getstringvalue() string' defined in 'google.apis.util.utilities': not specific. extension method 'public function getstringvalue() string' defined in 'google.apis.util.utilities': not specific. additionally, these 2 lines each generate "not defined" error. dim credentials fullclientcredentials = promptingclientcredentials.ensurefullclientcredentials() dim initializer new baseclientservice.initializer() error 9 type 'baseclientservice.initializer' not defined. error 8 type 'fullclientcredentials' not defined. finally, line: dim state iauthorizationstate = authorizationmgr.getcache

actionscript - AS3 default values as Class in Function Parameter -

how can assign default value function parameter of type class in action script 3 public function foo(param:class = ????? ) { } thanks you can't, here's workaround achieve same effect: public function foo(param:class = null ):void { if(!param) { // this'll default class param = myclass; } // here can do: var bar:* = new param(); }

c# - Why can't I use "yield" operator to return a lazy list in IValueConverter? -

suppose have following class: public class values { public string value1 {get;set;} public string value2 {get;set;} public string value3 {get;set;} } now want bind object's values gui component's itemssource in specific order, using ivalueconverter: public class valuestolistconverter : ivalueconverter { public object convert(object value, type targettype, object parameter, cultureinfo culture) { var valuesobj = (values ) value; yield return valuesobj.value1; yield return valuesobj.value3; yield return valuesobj.value2; } public object convertback(object value, type targettype, object parameter, cultureinfo culture) { throw new notimplementedexception(); } } but when this, following error: the body of 'convert' cannot iterator block because 'object' not iterator interface type. is there way lazily create list in ivalueconverter? or have do: return new list<string>

Cordova Client Phonegap Upgrade -

i using cordova client phonegap project.i got question when type cordova create name namespace working fine.i want add platforms , got error, when android. e.g. error : error occurred during creation of android sub-project. cp /usr/local/lib/node_module/cordova/lib/android/framework/cordova-2.2.0.jar .. i copied manually since didn't figure out how slove it. can me explain , how can update 2.7 ? did npm install cordova.. took new sources when type codorva create xxx , add plattform got same error. have tried npm update cordova command? update latest cordova version (2.7.2 @ moment)

Memory issues in iOS app in Unity3d at transition between scenes (made with Application.LoadLevel) -

i developing app ios in unity3d. have memory issues ios app. there 3 large peaks. each peak 50 mb's. first occurs when app launches. app presents simple main menu scene (it consist of background texture , 3 or 4 gui.buttons) second occurs when user taps start button in main menu. third occurs when users leaves game scene. transition between scenes made application.loadlevel. before each transition call resources.unloadunusedassets() , system.gc.collect(); app crashes ( after memory warnings) on old devices (ipad 1 , iphone 3gs) on transitions. how should debug crashes? why memory consumption ontransition between scenes high? how can reduce memory consumption in situations? why don't try using. application.loadleveladditive ("actualscenewhereuwanttogo"); please let know improvements.

android - Database Query only returns column name -

hello , help! database has 4 columns , need way return newest item added last column each time. column name spininterval , value int. database http://www.bthindiet.com/datatable.jpg in dbadapter class have set method retrieving data public cursor fetchreminder(long rowid) throws sqlexception { cursor mcursor = mdb.query(true, database_table, new string[] {key_rowid, key_title, key_body, key_date_time, key_spinner}, key_rowid + "=" + rowid, null, null, null, null, null); if (mcursor != null) { mcursor.movetofirst(); } return mcursor; } the code tried string repeat = remindersdbadapter.key_spinner.tostring(); returned name of column spininterval. correct way query info (60 * 60 * 1000 * 8) , work each time new item added db? going add info alarmmanager setrepeating call. public class remindermanager { private context mcontext; private alarmmanager malarmmanager; string rep

electronics - Arduino LED chaser freezes after a few loops? -

Image
i using 3 led sequencer circuit below arduino uno r3. led 1 connected pin 2, led 2 pin 3, led 3 pin 4. r1/r2/r3 330 ohm, 1/4 w each. the code is: int mypins[] = {2,3,4}; // set pin array pins 2 through 4 void setup() { (int thispin = 0; thispin < (sizeof(mypins)); thispin++) { pinmode(mypins[thispin],output); // set each pin in array output mode. } } void loop() { (int thispin = 0; thispin < (sizeof(mypins)); thispin++) // loop every pin , switch on & off. { digitalwrite(mypins[thispin], high); // set led on. delay(100); // keep on 100 ms. digitalwrite(mypins[thispin], low); // set led off 50 ms , goto next one. delay(50); } } this seems work fine in begining. leds blink on/off in sequence 13 times , led connected pin 2 stays on. when re-upload sketch or click menu items on ide, loop restarts. why happening, due noise in circuit? p.s.: on 4th iterati

mysql - How can I join conditionally based on a value joined to the join? -

i not sure if possible, want records back, attachment, if type (a definition table) 'main' (if has attachment, it's type else, want null. select r.* record r left join attachment d on d.record_id = r.id left join attachment_type @ on d.type_id = at.id at.name = "main" group r.id i redesign of data here, that's not possible. use subquery id before doing join? i don't know attachment column table looks (beyond fact has type column), should close, meaning (a) it'll return rows, , (b) returned attachment value null if type main : select r.*, case when at.name = 'main' d.whatever else null end attach_thingie record r left join attachment d on d.record_id = r.id left join attachment_type @ on d.type_id = at.id and, @freshprinceofso mentioned in comment above, don't see need group by . one more thing: based on can infer query, don't see glaring design problems among 3 tables. read record can have number of attachme

Powershell: Running a .msc applet as another user -

i'm writing powershell script asks single set of admin credentials, , uses run relevant applications, pulled network-hosted csv. when try run start-process $tools[$userinput-1].path.tostring() -credential $credential (where $tools returning "c:\program files\microsoft\exchange server\v14\bin\exchange management console.msc") error below start-process : command cannot executed because input "c:\program files\microsoft\exchange server\v14\bin\exchange management console.msc" invalid application. give valid application , run command again. @ line:1 char:14 + start-process <<<< "c:\program files\microsoft\exchange server\v14\bin\exchange management console.msc" -credential get-credential + categoryinfo : invalidoperation: (:) [start-process], invalidoperationexception + fullyqualifiederrorid : invalidoperationexception,microsoft.powershell.commands.startprocesscommand if need to, i'll write .bat file , run tha

java - Can you do traditional Servlet Filtering with JAX-RS/Jersey? -

imagine have filter starts database transaction, processes request, , then attempts commit transaction. dofilter(...) { ... transaction.begin(); filterchain.dofilter(request, response); transaction.commit(); } using jersey, there problems: using filter, jersey servlet container commits/flushes response before execution returns filter. so, if commit fails, can't modify return code failure. also, exceptions won't caught jax-rs exceptionmapper. using containerrequestfilter/containerresponsefilter. public containerrequest filter(containerrequest request) { ... } public containerresponse filter(containerrequest request, containerresponse response) { ... } this allows exceptions bubble exceptionmapper, splits logic on 2 separate methods/interfaces. problem if there's exception doesn't map response, containerresponsefilter never called, can't clean up. what's preferred way handle in jax-rs environment? there way configure flu

c# - Finding and Filtering XML Data -

i have xml document here: <?xml version="1.0" encoding="utf-8" ?> <catalog> <cd> <title>empire burlesque</title> <artist>bob dylan</artist> <country>usa</country> <company>columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>hide heart</title> <artist>bonnie tyler</artist> <country>uk</country> <company>cbs records</company> <price>9.90</price> <year>1988</year> </cd> <cd> <title>test title 1</title> <artist>test name 1</artist> <country>test country 1</country> <company>test company 1</company> <price>100.00</price> <year>1985</year> </cd> <cd> <title>test title 3</title>

c# - Passing a struct by reference from managed to unmanaged code? -

my struct looks in c code: typedef struct _request { char d [_d_max+1]; char m [_m_max+1]; char t [_t_max+1]; char clref [_cl_ref_max+1]; char load [_load_max]; ulong loadlen; } _request, *lp_request; in c# this: [structlayout(layoutkind.sequential, charset=charset.ansi)] public struct _request_struct { [marshalas(unmanagedtype.byvaltstr, sizeconst = 32)] public string d; [marshalas(unmanagedtype.byvaltstr, sizeconst = 32)] public string m; [marshalas(unmanagedtype.byvaltstr, sizeconst = 32)] public string t; [marshalas(unmanagedtype.byvaltstr, sizeconst = 20)] public string clref; [marshalas(unmanagedtype.byvaltstr, sizeconst = 1200)] public string load; public uint32 loadlen; } the method calling in c: int aj_stdcall simptran (const char* svc_name, const lp_request query, lp_response response) { //init stuff //validate input parameters if (

asp.net mvc - Cleaning Up Temporary File after Returning to Browser -

i have controller action dynamically generates powerpoint file. happens unzipping existing .pptx file, applying changes xml, , zipping result new, temporary .pptx file. file returned action using file(). how can clean temporary file after has been returned client? is there better way approach this? i suppose using library such sharpziplib . the correct solution imo not generate file in first place. sharpziplib write file stream . point outputstream , should good.

r - Reduce List but avoid Null variables -

given list null element: l<-list(x=1,b=2,c=null) how can reduce list using '+' addition avoid adding null value? tried reduce(l,"+",null.rm=t) but don't think got null.rm. efficient way of solving this? thanks you can exclude null elements with: l[!unlist(lapply(l, is.null))] is want? cheers

c# - Get specific UIElemet from grid in Windows Phone with visual tree helper -

i have grid view in windows phone xaml page , grid contains many ui element buttons, checkboxes , textboxes. want search specific uielement name grid , want value of uielement , set new values well. how can uielement grid visual tree helper in code behind. <grid x:name="contentpanel" grid.row="1" margin="12,0,12,0"> <grid.rowdefinitions> <rowdefinition height="120" /> <rowdefinition height="120" /> <rowdefinition height="120" /> <rowdefinition height="120" /> <rowdefinition height="120" /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="240" /> <columndefinition width="240" /> </grid.columndefinitions> <border bord