Posts

Showing posts from July, 2011

php - PHPUnit and Extended Classes -

i curious, have base class - called base , controller class called - controller - apparently cannot test controller - in netbeans - because cannot find base class. class controller extends base{} class base{} netbeans generate tests base not controller. because a) every test must extend php unit , b) if test logic in base , passes it's safe assume controller too? - seems rather untrustworthy. what 1 in situation? you must include file or can use autoload (check autoload of composer. psr-0 or classmap). , preferably use phpunit.xml passing autoload or bootstrap automated testing. (no need stay including files tested in test file).

asp.net - Date format conversion in c# -

how convert 04/09/2013 8:09:10 pm 09/04/2013 (mm-dd-yyyy). tried convert taking 09 date , 04 month. please help [httppost] public string getdailynote(datetime selecteddate) //selecteddate gets date 04/09/2013 8:09:10 pm { string x = selecteddate.tostring("mm-dd-yyy", cultureinfo.invariantculture); string daily; datetime dt = convert.todatetime(x); //dt gets value {09/04/2013 12:00:00 am} 09 date , 04 month dnote.realdate =dt; daily = _scheduler.getdailynote(dnote); return daily; } it taking 09 date , 04 month yes, because have said it, change "mm-dd-yyy" to "dd/mm/yyyy h:mm:ss tt" datetime.parseexact("04/09/2013 8:09:10 pm","dd/mm/yyyy h:mm:ss tt", cultureinfo.invariantculture); demo now, if want convert string format mm-dd-yyyy : string result = dt.tostring("mm-dd-yyyy", cultureinfo.invariantculture);

eclipse - Jetty Startup issue: WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,null} -

i´m trying start new project war maven , spring spring tool suite ide, downloaded project git hub, project made on macs , i´m working in windows. this i´m getting when try start jetty server: 2013-09-03 10:01:47.161:info:oejs.server:jetty-8.1.12.v20130726 2013-09-03 10:01:47.179:info:oejdp.scanningappprovider:deployment monitor c:\users\hp\documents\workspace-sts-3.3.0.release\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps @ interval 1 2013-09-03 10:01:47.183:info:oejdp.scanningappprovider:deployment monitor c:\users\hp\documents\workspace-sts-3.3.0.release\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\contexts @ interval 1 2013-09-03 10:01:47.187:info:oejd.deploymentmanager:deployable added: c:\users\hp\documents\workspace-sts-3.3.0.release\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\contexts\moca-console.xml 2013-09-03 10:01:47.238:warn:oejw.webinfconfiguration:web application not found c:\users\hp\documents\workspace-sts-3.3.0.release\.metadata\.pl

javascript - Jquery check if special char exists in text value -

i need check if textarea contains special characters, need count them 2 (sms lenght). i wrote piece of code seems doesn't find no special chars, if write "€€€" could please me? if rewrite directly function, without problem. thank tou! var special_chars = array('€', '%'); function charused() { var count = $('#text').val().length; var chars = $('#text').val().split(""); var numberofspecialchars = 0; if ($.inarray(chars, special_chars) > -1) { numberofspecialchars++; } return count + numberofspecialchars; } // function a rewrite : var nbspecialchars = $('#text').val().split(/[€%]/).length - 1; the idea make array of strings, using special characters separator : 'some € chars %' => ["some ", " chars ", ""] and use length of array deduce count of chars. there many other (faster) soluti

searchable spinner not working in Android Java -

i have java.lang.unsupportedoperationexception @ iterator .remove() believe considered safe , think code "ok" can me? final list<string> livelist = arrays.aslist((string[]) button.getitems().toarray()); //create mutable list<string> button.getitems() list<string> final premspinner dropdown = new premspinner(this); //spinner (eg: "dropdown") of options dropdown.setlayoutparams(col); final arrayadapter<string> dataadapter = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, livelist); // <---+ dataadapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); // | dropdown.setpadding(45, 15, 45, 15); // | dropdown.setadapter(dataadapter); //the way [populate] `dropdown(spinner)` via `a

Call SOAP service from android with ksoap error -

this question has answer here: how fix android.os.networkonmainthreadexception? 44 answers i have webservice running on google app engine, , call available service android device. i've follow , merge code of tutorial ksoap2, still obtain exception on android. code: private static string method_name = "getdata"; private static string soap_action = "http://example.com/getdata"; private static string wsdl_url = "http://arduino-data-server.appspot.com/functionsservice.wsdl"; private static string namespace = "http://example.com/"; soapobject request = new soapobject(namespace, method_name); soapserializationenvelope envelope = new soapserializationenvelope( soapenvelope.ver12); envelope.setoutputsoapobject(request); httptransportse androidhttptransport = new httptransportse(wsdl_url); try { androidhttptransport

c# - The view must derive from WebViewPage -

i had working mvc application when decided time maintenance. views under shared directory , decided move them separate directories. i implemented customviewengine found here: can specify custom location "search views" in asp.net mvc? view structure lookes views appviews otherappviews ... shared ... this error getting: the view @ '~/views/appviews/someview.cshtml' must derive viewpage, viewpage<tmodel>, viewusercontrol, or viewusercontrol<tmodel>. i tried inherit @inherits system.web.mvc.webviewpage (as explained here: the view must derive webviewpage, or webviewpage<tmodel> ) , when error saying can't use @inherits , @model @ same time. thank you your customengine should derive razorviewengine instead of webformviewengine since use .cshtml files (razor engine). docs: razorviewengine webformviewengine

c - strncpy() and memcpy() are different? -

strncpy() , memcpy() same? because of fact strncpy() accepts char * parameter, icasts integer arrays char *. why gets different output? here code, #define _crt_secure_no_warnings #include <stdio.h> #include <string.h> #define size 5 void print_array(int *array, char *name ,int len) { int i; printf("%s ={ ",name); for(i=0; i<len;i++) printf("%d," ,array[i]); printf("}\n"); } int main(void){ char string1[size] = {'1','2','3','4','\0'}; char string2[size], string3[size]; int array1[size] = {1,2,3,4,5}; int array2[size],array3[size]; strncpy(string2,string1,sizeof(string1)); memcpy(string3, string1,sizeof(string1)); printf("string2 =%s \n",string2); printf("string3 =%s \n",string3); strncpy((char *)array2, (char*)array1 , sizeof(array1)); memcpy(array3,array1,sizeof(array1)); print_array(array2,&quo

How can I create a case-insensitive database index in Django? -

i using django create database tables, so: class metadataterms(models.model): term = models.charfield(max_length=200) size = models.integerfield(default=0) validity = models.integerfield(default=0, choices=term_validity_choices) i running lookup queries find appropriate row correct term , matched in case-insensitive way. e.g.: metadataterms.objects.filter(term__iexact=search_string, size=3) this lookup clause translates in sql: select "app_metadataterms"."id", "app_metadataterms"."term", "app_metadataterms"."size" "app_metadataterms" (upper("app_metadataterms"."term"::text) = upper('jack nicklaus survives') , "app_metadataterms"."size" = 3 ); on postgres, can perform explain query on above, , query plan: query plan ----------------------------------------------------------------------------------- seq

python login to website, no "id" only "class" for login button -

Image
have been searching , searching, testing , trying, reading , reading... not programmer, , not pick these things quickly. here code: import requests url = 'http://company.page.com/member/index.php' (this url has form on it) values = {'username': 'myusernamehere', 'password': 'mypasswordhere'} r = requests.post(url, data=values) # have logged in url = "http://company.page.com/member/member.php" (this resulting url after logging in) # sending cookies result = requests.get(url, cookies=r.cookies) print (result.headers) print (result.text) i error: <form action="http://company.page.com/member/index.php" method="post" id="login"> <h3 class="head">donor login</h3> <em class="notice"><p class="errors">you must log in</p><br /> image of website source code: (first way figure out how post html) use se

how to convert string png to image in javascript -

look @ code! var imageqrcode; $.ajax({ url: url, data: { c1: ca, c2: cli}, success: function(image) { imageqrcode = image; } }); this html: <div class="areaqrcode"><img src="javascript:imageqrcode"></div> my ajax call returns image string this: "‰png\r\n\u001a\n\u0000\u0000\u0000\rihdr\u0000\u0000\u0000d\u0000\u0000\u0000d\b\u0002\u0000\u0000\u0000ÿ€\u0002\u0003\u0000\u0000\u0000\u0006bkgd\u0000ÿ\u0000ÿ\u0000ÿ ½§“\u0000\u0000\u0001ÞidatxœíÜÁnÄ \feÑrõÿ9Ýzƒä+üj¦ºgÛ4\u0013=y,`\bëyž/õ|ß~€obx€a\u0001†\u0005\u0018\u0016`x€a\u0001?»?¬µÆ?¬Žév÷ßûêõûœØ=ƒ•\u0005\u0018\u0016`xÀ¶gu'óÇnošê;‰ç¬¬,À°\u0000Ã\u0002z=«ê|·;½£3nj÷ z+\u000b0,À°\u0000ܳÒ\u0012ýkŠ•\u0005\u0018\u0016`xÀ+z\u0016]ÛºÅÊ\u0002\f\u000b0,\u0000÷¬©>’îg‰û[y€a\u0001†\u0005´zvâ·9ºžÕ™'&ž³²²\u0000Ã\u0002\f\u000bxo˜97ü‡\f\u000b0,`lÖɾ*ºïajÌeÇqv\u0016`x€a\u0001Ûq\u0016ýÍîä7>Úƒ\u0012ûn;Ïle\u0001†\u0005\u0018\u0016p´?«~Ï\u0013㬓

authentication - VBS- Login script to map drive with multiple NICs -

i trying create script map drive @ logon per ip address or subnet. able find 1 script works on single mic, thre few machines have 2 nics, , not work them. here modified script. set objnetwork = createobject("wscript.network") strcomputer = "." set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root\cimv2") set coladapters = objwmiservice.execquery _ ("select * win32_networkadapterconfiguration ipenabled=true") redim arrsubnets(-1) each objadapter in coladapters each straddress in objadapter.ipaddress arroctets = split(straddress, ".") if arroctets(0) <> "" redim preserve arrsubnets(ubound(arrsubnets)+1) arrsubnets(ubound(arrsubnets)) = arroctets(0) & "." & arroctets(1) & "." _ & arroctets(2) end if next next set colitems = objwmiservice.execquery _ ("select * win32_logicaldisk deviceid =

java - Take off namespace from Jaxb fields -

i want know how type 1 time namespace in jabx, because in every fields need put namespace. the code below show it. @xmlrootelement(name = "nfeproc", namespace = "http://www.portalfiscal.inf.br/nfe") @xmlaccessortype(xmlaccesstype.field) class nfeproc { @xmlelement(name = "nfe", namespace = "http://www.portalfiscal.inf.br/nfe") private nfe nfe; @xmlattribute(name = "versao") private string versao; public nfe getnfe() { return nfe; } public void setnfe(nfe nfe) { this.nfe = nfe; } public string getversao() { return versao; } public void setversao(string versao) { this.versao = versao; } } i wanna put 1 time. thanks you can set @ package level using @xmlschema annotation. setting element form default qualified, elements without namespace specified via annotation belong given namespace. package-info.java @xmlschema( namespac

clojure - How do I use with-out-str with collections? -

i can use with-out-str string value (doc func) . => (with-out-str (doc first)) "-------------------------\nclojure.core/first\n([coll])\n returns first item in collection. calls seq on its\n argument. if coll nil, returns nil.\n" however, if try same thing collection of functions, can return empty string each: => (map #(with-out-str (doc %)) [first rest]) ("" "") where going wrong here? unfortunately doc macro, , such not first class citizen in clojure because cannot use higher order function. user> (doc doc) ------------------------- clojure.repl/doc ([name]) macro prints documentation var or special form given name what seeing output of looking documentation % twice. user> (doc %) nil user> (with-out-str (doc %)) "" because call doc has finished running during macro-expansion-time, before call map runs (at run-time). can doc string directly metadata on var containing functions user&g

c++ - Converting lower & upper case ASCII characters -

i'm making program converts ascii characters 'a' through 'z' , 'a' through 'z'. (only letters). example, a+1 = b a+2 = c b+1 = c a+1 = b so thing i'm not sure how mapping around. how can make when checklower/checkupper true, map around lower case letter (example, of z+2 = b). the simplest way use % modulus operator: int letter_add = ((input.at(i) - 'a' + cmd_int) % 26) + 'a'; you'll need symmetrical line capital letters (or make 'a' variable too).

php - Error parsing data org.json.JSONException: type java.lang.String cannot be converted to JSONObject -

currently php file used interface between mysql server , android app looks like: <?php // array json response $response = array(); if (isset($_get['porfileid'])) { $id = $_get['porfileid']; // include db connect class require_once __dir__ . '/db_connect.php'; // connecting db $db = new db_connect(); // products products table $result = mysql_query("select * profiles_profilelists profileid = '$id'") or die(mysql_error()); // check empty result if (mysql_num_rows($result) > 0) { // looping through results // products node $response["lists"] = array(); while ($row = mysql_fetch_array($result)) { // temp user array $lists = array(); $lists["profilelistid"] = $row["profilelistid"]; $lists["profilelistname"] = $row["profilelistname"]; // push single product final response arr

json - Combining Two JQuery.Map into one? -

im doing calls spotify webservice search artists , tracks in personal application. the problem want display 2 different results in 1 object. is possible? or should approach in different way? (get me on track in case). maybe should nested call webservice ?(please write code, i've tried myself, dont know how right) jsfiddle readability , demo: http://jsfiddle.net/a97ys/ code below function gettracks(request, response) { $.get("http://ws.spotify.com/search/1/track.json", { q: request.term }, function (data) { response($.map(data.tracks.slice(0, 5), function (item) { return { label: item.name, by: item.artists[0].name, category: "track" }; })); }); } function getartist(request, response) { $.get("http://ws.spotify.com/search/1/artist.json", { q: request.term }, function (data) { response($.map(data.artists.slice(0, 5), function (item)

sql server - How can I use SQL to get a variable value from a literal? -

part 1 declare @a int declare @b nvarchar(20) set @a=123 set @b='@a' part 2 declare @sql nvarchar(max) set @sql='select ' + @b exec sp_executesql @sql --should return 123 directly referencing @a in non-dynamic sql not acceptable task. the above in part 2 generically trying do. understand variable out of scope , won't work done above. how use @b value of @a? i didn't understand whole thing asking, can define variables on sp_executesql : exec sp_executesql @sql, n'@a int', @a = @a

html - Keep close button on upper right corner even when image scales -

how heck can keep close button on right top corner of image when scale image using css? scale in terms of when user make browser different size image scaled. p.s. how come when use full_close {left:0px;} lose image jsfiddle .fit { max-width: 100%; } .center { display: block; top: 0px; right: 0; } .right { position: relative; right: 0; } #full_image { width: 0px; height: 0px; left: 0px; position: absolute; opacity: 1; z-index: 9; } #full_image img { left: 0px; position: fixed; overflow: hidden; } #full_image ul { width: 0px; height: 0px; list-style: none outside none; position: relative; overflow: hidden; } #full_image li:first-child { display: list-item; position: absolute; } #full_image li { position: absolute; display: none; } #full_image .full_close{ background-color:yellow; top: 10px; cursor: pointer; height: 29px; opacity: 1; position: absolute;

Changing the active class of a link with the twitter bootstrap css in python/flask -

i got following html snippet page template.html . <ul class='nav'> <li class="active"><a href='/'>home</a></li> <li><a href='/lorem'>lorem</a></li> {% if session['logged_in'] %} <li><a href="/account">account</a></li> <li><a href="/projects">projects</a> <li><a href="/logout">logout</a></li> {% endif %} {% if not session['logged_in'] %} <li><a href="/login">login</a></li> <li><a href="/register">register</a></li> {% endif %} </ul> as can see on line 2, there's class active. highlights active tab twitter bootstrap css file. now, work fine if visit www.page.com/ not when visit www.page.com/login example. still highlight home link active tab

ruby on rails - Importing a large amount of data for testing only. -

here background: i have client wants me test rails app against large number of potential inputs in form page. has excel spreadsheet 200 potential input combinations entered form. the client want's app able "read" spreadsheet , execute couple hundred form submissions. my solution import spreadsheet database table, client doesn't want database table in application. so here question: is possible/not exceptionally complicated read/crawl spreadsheet or csv file above, or import data test database? i haven't been able find resources aren't importing spreadsheet. thanks! use spreadsheet gem read , parse data excel. use capybara automate form submission. initial learning curve steep, once hang of it, comes handy automate web interactions.

php - jQuery DataTables load large data -

how load large data on databases jquery datatables? $(document).ready(function(){ $('#datatables').datatable({ "spaginationtype":"full_numbers", "aasorting": [[0, 'asc'], [1, 'desc']], "sscrolly": "200px", "bjqueryui":true }); }) total data on xnod_kode table > 10000 records ??? <?php $result = mysql_query("select * xnod_kode limit 10"); $no = 1; while ($row = mysql_fetch_array($result)) { ?> <tr> <td><?php echo $no; ?></td> <td><?php echo $row['kodepos']?></td> <td><?php echo $row['kelurahan']?></td>

python multicore queue randomly hangs for no reason, despite queue size being tiny -

in python here multiprocessing setup. subclassed process method , gave queue , other fields pickling/data purposes. this strategy works 95% of time, other 5% unknown reason queue hangs , never finishes (it's common 3 of 4 cores finish jobs , last 1 takes forever have kill job). i aware queue's have fixed size in python, or hang. queue stores 1 character strings... id of processor, can't that. here exact line code halts: res = self._recv() does have ideas? formal code below. thank you. from multiprocessing import process, queue multiprocessing import cpu_count num_cores import codecs, cpickle class processor(process): def __init__(self, queue, elements, process_num): super(processor, self).__init__() self.queue = queue self.elements = elements self.id = process_num def job(self): ddd = [] l in self.elements: obj = ... heavy computation ... dd = {} dd['data&

android - SoapObject result of service call is always null -

i have implemented soap webservice following tutorial found on google developers website, , i'm writing android app call available service , show result (for in textview) using ksoap2 libraries. that's code: public class downloaddatatask extends asynctask<void, void, soapobject> { private static string method_name = "getdata"; private static string soap_action = "http://example.com/getdata"; private static string wsdl_url = "http://arduino-data-server.appspot.com/functionsservice.wsdl"; private static string namespace = "http://example.com/"; private mainactivity caller_activity; public downloaddatatask(mainactivity a) { caller_activity = a; } @override protected soapobject doinbackground(void... arg0) { soapobject request = new soapobject(namespace, method_name); soapserializationenvelope envelope = new soapserializationenvelope( soapenvelope.ver12); envelope.setoutputsoapobject(request); htt

php - Forcing SSL for all but one directory in CodeIgniter with .htaccess -

i realize there's been lot of questions along these lines @ point i've read through of them , think situation unique. i'm trying use .htaccess force https make optional 1 directory (which called pirate). i've done things before time didn't cooperate. first started code forces use https. <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{server_port} 80 rewriterule ^(.*)$ https://%{server_name}%{request_uri} [l,r=301] rewritecond $1 !^(blog|images|css|js|robots\.txt|favicon\.ico) rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /index.php?/$1 [l] </ifmodule> <ifmodule !mod_rewrite.c> errordocument 404 /index.php </ifmodule> then added exception (i'm showing first rule here): rewritecond %{server_port} 80 rewritecond %{request_uri} !^(/pirate/) [nc] rewriterule ^(.*)$ https://%{server_name}%{request_uri} [l,r=301] that should it! controllers sh

c - Printf output using UART in ARM Cortex-M3 microcontroller -

i have lpc1768 based board - landtiger (worth checking manual @ bottom). program use keil uvision4/72 lite , j-link edu segger. simple program interact joystick , diodes works fine, but... i trying implement debug printf, can see printf output in keil "debug (printf) viewer" window. problem dont see output - think on right track because when run debugger can see trace:running @ bottom of window (before trace:no synchronization ). unfortunately dont see in uart , debug output windows. i've spent quite lot of time trying make work , appreciate help, thank ;) my keil settings are: project/options target/debug set j-link/j-trace cortex . then inside it's settings have segger selected port:sw , max clock:10 mhz . trace tab enabled 100mhz core clock , swo prescaler = 17 (which results in 5.882352mhz swo clock ). itm stimulus ports set enable:0xffffffff , privilege:0x0000000f here parts of code: define fosc 12000000

python - django transaction.commit_manually leads to 'MySQL server has gone away' -

have long running process worked fine. started getting (2006 'mysql server has gone away') error after adding transaction.commit() manually commit transaction. before (works great): dbobject.objects.get(id = 1) after: (getting error after idle 8 hours of nothing process @ night) note: need flush avoid getting stale data. flush_transaction() dbobject.objects.get(id = 1) where @transaction.commit_manually def flush_transaction(): """ flush current transaction don't read stale data use in long running processes make sure fresh data read database. problem mysql , default transaction mode. can fix setting "transaction-isolation = read-committed" in my.cnf or calling function @ appropriate moment """ transaction.commit() as understand, i'm switching commit_manually seems i'm losing django's auto reconnect. other increasing wait_timeout on mysql side, there way of handi

Haskell avoiding stack overflow in folds without sacrificing performance -

the following piece of code experiences stack overflow large inputs: {-# language derivedatatypeable, overloadedstrings #-} import qualified data.bytestring.lazy.char8 l gentweets :: l.bytestring -> l.bytestring gentweets text | l.null text = "" | otherwise = l.intercalate "\n\n" $ gentweets' $ l.words text gentweets' txt = foldr p [] txt p word [] = [word] p word words@(w:ws) | l.length word + l.length w <= 139 = (word `l.append` " " `l.append` w):ws | otherwise = word:words i assume predicate building list of thunks, i'm not sure why, or how fix it. the equivalent code using foldl' runs fine, takes forever, since appends constantly, , uses ton of memory. import data.list (foldl') gentweetsstrict :: l.bytestring -> l.bytestring gentweetsstrict text | l.null text = ""

haskell - Function Argument that might or might not instantiate a TypeClass? -

this i'm trying make handler - getuserstudentsr :: userid -> handler typedcontent getuserstudentsr userid = getstudententitiesforcoach userid >>= returntypedcontent . map touserstudentresponse where student persistent entity (details not important) , getstudententitiesforcoach :: userid -> handlert app io [entity student] getstudententitiesforcoach coachid = rundb $ selectlist [studentprimarycoachid ==. just(coachid)] [] data userstudentresponse = studentresponse (key student) student instance tojson userstudentresponse tojson (studentresponse studentid student) = object [ "login" .= studentlogin student , "studentid" .= studentid , "firstname" .= studentfirstname student , "lastname" .= studentlastname student ] touserstudentresponse :: (entity student) ->

.htaccess - Special 301 redirection rules -

i'm moving old site new domain , i've been trying make proper 301 redirect in .htaccess file accomodate kind of redirection rules below think i'm stumped. new.com --> new.com/main www.new.com --> new.com/main old.com --> new.com/main www.old.com --> new.com/main old.com/* --> new.com/* www.old.com/* --> new.com/* sub.old.com/* --> sub.new.com/* for first part, seems code works: # rewritecond %{http_host} ^new\.com$ [or] # rewritecond %{http_host} ^www\.new\.com$ # rewriterule ^/?$ "http\:\/\/new\.com\/main" [r=301,l] # rewriterule ^$ http://www.new.com/main [r=301,l] put simple, if browser requests page other old.com domain's homepage, i'd go new.com. if visit new.com, they'd redirected /main folder. however, i'm worried should ever explicitly visit new.com/main, they'd fall infinite redirect. any appreciated. this code needed on document_root/.htaccess on new.com : options +follow

d - Preferred foreach Index Type -

what preferred type loop indexes when using foreach in d, int , uint or automatic omitting type? in general, indices should size_t . same length . you're going have issues 32-bit vs 64-bit machines if try , use int or uint . size_t language uses array indices , length . it's aliased uint on 32-bit machines , ulong on 64-bit machines. so, if you're going give index type, give size_t . however, type inferred size_t foreach when iterating on array. so, in cases, there's no reason list type.

Simplest case of loading an image via jQuery -

i'm not having luck pulling image file image element using jquery. looks pretty simple, i'm missing elementary. (i'm complete jquery tyro, i've made silly mistake somewhere.) all files in same directory (html, jquery-1.10.2.min.js, myimage.png). the text shows up, no image. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <script type="text/javascript" src="jquery-1.10.2.min.js"></script> </head> <body> beforeimage <img id="myimageelement" src="" /> afterimage <script type="text/javascript"> $('#myimageelement').load('myimage.png'); </script> </body> </html> you should try setting src property of img tag instead. $('#myimag

xcode - git trying to commit thousands of files -

i trying commit changes project in xcode 4.6.3 have used source control -> commit mechanism several times , worked beautifully added dcroundswitch objects project ( https://github.com/domesticcatsoftware/dcroundswitch ) when try commit changes, xcode hangs loooong time tells me wants commit 100,875 files (in past commits ran between few , few dozen files), , every crashes out. tried doing commit no avail. it appears git trying commit files in linked libraries, in addition source files. not attempting prior adding dcroundswitch files i went online , read .gitignore files , created 1 in project directory (not git subdirectory of project directly)...it had no effect on behavior fwiw, content of .gitignore file below. any appreciated #xcode .ds_store */build/* *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata profile *.moved-aside deriveddata .idea/ *.hmap #cocoapods pods you can t

python - celery how to terminate and start again task -

i want use celery this: 1. send message start task, task starting 2. if in task condition true task should terminated (canceled) , "returned" messages queue other worker can take , it. and don't know how terminate task worker function. trying in called function: if condition == true: revoke(current_task.request.id, terminate=true) and in app when message send trying connect signal 'task_revoke' in way: @task_revoked.connect def do_something_when_revoke(terminated, signum, expired): do_something_here... but not working me good. maybe can me , tell me i'm doing wrong or maybe different way :) in advance possibly easier way achieve implement logic inside task itself: you don't have revoke task, don't in it your task can submit new, updated, task queue

R: Passing function arguments to override defaults of inner functions -

in r, this: have function f1, has argument default value; k=3. f1 = function(x,k=3){ u=x^2+k u } i later define second function, f2 calls f1. f2 = function(z,s){ s*f1(z) } what's cleanest way allow users of f2 override default value of k in inner function f1? 1 trivial solution redefine f2 as: f2 = function(z,s,k){ s*f1(z,k) } however, feel might cumbersome if i'm dealing large heirarchy of functions. suggestions? thanks. the easiest way deal using ... argument. allows pass number of additional arguments other functions: f1 = function(x,k=3){ u=x^2+k u } f2 = function(z,s, ...){ s*f1(z, ...) } you'll see commonly used in functions call others many optional arguments, example plot .

Why doesn't tracing behavior appear to work when added to Autofixture Fixture.Behaviors in an AutoDataAttribute implementation? -

when add new tracingbehavior autofixture fixture instance using fixture.behaviors.add(new tracingbehavior()); i tracing output in r# unit test sessions window. however, when inherit autodataattribute , add behavior inside attribute's constructor this i no tracing output, though tests indicate tracingbehavior has been added fixture.behaviors in both scenarios. below 2 simple tests , attribute implementation reproduce. public class tracingbehaviortests { [theory, autodata] public void tracingoutputdisplayedwhenmanuallyaddedtofixture(fixture fixture) { fixture.behaviors.add(new tracingbehavior()); var actual = fixture.behaviors.oftype<tracingbehavior>().any(); assert.equal(true, actual); // passes fixture.create<string>(); // tracing output displayed } [theory, tracingfixtureconventions] public void tracingoutputdisplayedwhenusingtracingfixtureconventionsattribute(fixture fixture) {

How to ignore .gitignore files in git status? -

this question has answer here: ignore .gitignore file itself 19 answers when run git status , lists bunch of .gitignore files not interested in seeing in list (they got updated locally eclipse ). browsed numerous posts in regards seemingly common issue none of suggested solutions worked me. e.g. went ~/.gitconfig , found that excludesfile = ~/.gitignore_global then went file , added .gitignore @ tail did not change anything. how ignore .gitignore files in git status don't clutter view? it sounds might misunderstanding "ignore" means git. file name mentioned in .gitignore means if file untracked , git status not show file untracked file. ignoring file not when file tracked git, , has been modified. considered change repository, git doesn't let ignore. (after all, have told git file important enough store in repository, git h

c++ - Behavior of ifstream object -

i have class has istream constructor. can initialize class object ifstream object. in program open file ifstream object , use object initialize class object. std::ifstream in(test); object1(in); object2(in); the file contains transactions. math 3 5 phys 3 6 phys 3 7 etc. when print data members each line gets assigned to, object1 prints line 1 , object 2 prints line 2. why? i mention constructor takes istream object reference , in function body, calls function takes istream object reference , uses fill in data , returns istream object. but why each initialization advance next line in file? constructor code: sales_data(std::istream &is) : sales_data() { read(is, *this); } function read code: std::istream &read(std::istream &is, sales_data &item) { double price = 0; >> item.bookname >> item.books_sold >> price; item.revenue = price * item.books_sold; return is; } the issue line: is >> item.bookname >> item.b

Update PHP with javascript trigger and MySQL backend -

i trying create thumbnail carousel on page. loads 6 images links sql database. when click next button go down list of 6 images selecting border current 1 page on. when on image 6 , click next, want load next 6 in descending order mysql database. can't seem this. have setup. --connect , select database $con = mysql_connect("localhost", "xxxx", "xxxx"); mysql_select_db("xxxx"); $result = mysql_query("select sql_calc_found_rows * `images` `id` order id desc limit 6"); $row_object = mysql_query("select found_rows() rowcount"); $row_object = mysql_fetch_object($row_object); $actual_row_count = $row_object->rowcount; and code in carousel working <div id="thumbs-top" class="jcarousel"> <ul id="thumbs-data" class="thumbs-grid"> <?php while ($row = mysql_fetch_array($result)) { echo '<li><a href="########'.$row['filenam

can perform some operations but not all on c# calculator? -

so far, addition , subtraction work. but, multiplication , division not. because first 2 numbers put in added , them operation done. such as, if 9 * 9 + 3 should 84, 21 on calculator. because taking 9+9 + 3; sees last operator. have absolutely no idea how fix this. there helpful insight? public partial class form1 : form { double num2; double num1; string c; public form1() { initializecomponent(); } private void btn0_click(object sender, eventargs e) { txtbox.text = txtbox.text + btn0.text; } private void btn1_click(object sender, eventargs e) { txtbox.text = txtbox.text + btn1.text; } private void btn2_click(object sender, eventargs e) { txtbox.text = txtbox.text + btn2.text; } private void btn3_click(object sender, eventargs e) { txtbox.text = txtbox.text + btn3.text; } private void btn4_click(object sender, eventargs e) { txtbox.text = txtbox.t

C Programming: Linear Search with Struct -

how do linear search struct? we given typedef struct { int month; int day; int year; } date; typedef struct { int hour; int minute; } time; typedef struct { char name[size]; char bloodtype[bloodtypesize]; } patient; we given input file names , blood type: joe_smith a- 12/13/2010 10:45 anabell_brown o+ 10/10/2012 13:10 regina_white a- 1/13/2008 19:29 1 a- basically have linear search through names , blood types , see matches a- based on added first list i trying figure out how linear search based on names space , blood type, space, , time. hints help! simple question has been years since had code in c. thanks! do have more requirements? said "we given" set of typedef declarations , input. fro you've said, have load data arrays of appropriate type, search arrays. given above typedefs, date[50] declare array of 50 date structures, filled input (date.month = month; date.year = year; date.day = day;) , on remaining dat

jQuery validate across multiple fields -

i have 3 input fields ask number of people, , of them how many adults , how many children. trying use jquery validate plugin add custom method children + adults = number of people this validation call $("#form2").validate({ errorelement: "span", rules: { attendees: { required: true, digits: true }, adults: { required: true, digits: true }, children: { required: true, digits: true } }, messages: { attendees: "enter number of persons (including yourself)", adults: "enter number of adults", children: "enter number of childern" } }); i looked @ group feature , addmetod of validate plugin seems crafted 1 element in mind. ideas ? follow the documentation creating custom method/rule. here, ca