Posts

Showing posts from January, 2014

c++ - AVX convert 64 bit integer to 64 bit float -

i convert 4 packed 64 bit integers 4 packed 64 bit floats using avx. i've tried like: int_64t *ls = (int64_t *) _mm_malloc(256, 32); ls[0] = a; //... ls[3] = d; __mm256i packed = _mm256_load_si256((__m256i const *)ls); which display in debugger: (gdb) print packed $4 = {1234, 5678, 9012, 3456} okay far, cast/conversion operation can find _mm256i_castsi256_pd, doesn't me want: __m256d pd = _mm256_castsi256_pd(packed); (gdb) print pd $5 = {6.0967700696809824e-321, 2.8053047370865979e-320, 4.4525196003213139e-320, 1.7074908720273481e-320} what i'd see is: (gdb) print pd $5 = {1234.0, 5678.0, 9012.0, 3456.0} all of cast intrinsics perform bitwise cast, why you're not seeing meaningful results that. a vector conversion (the cvt intrinsics) between 64-bit integer , 64-bit float not exist.

c++ - How to declare two structs which have members of the others type? -

i trying make directed graph, made graph class , has private edge struct , private node struct. edges have node member node edge points to, , nodes have list of edges lead away them. #ifndef directed_graph_h #define directed_graph_h #include <iostream> #include <vector> #include <string> class graph { public: graph( const std::string & ); ~graph(); void print(); private: struct gnode { std::string currency_type; std::vector<gedge> edges; // line 19 gnode( std::string name ) : currency_type( name ) {} }; struct gedge { int weight; gnode * node; // node edge pointed towards gedge( int weight, gnode* node ) : weight( weight ), node( node ) {} }; gnode *source; std::vector<gnode> nodes; void add_node( const std::string & currency ); void add_edge( const gnode *& source, const gnode *& destination, int weight ); std::string be

Sorting a list of students by name and grade using struct in C -

i'm writing program sorts list of students name , grade. i'm receiving following errors when attempt compile: ex11.c: in function 'comparebygrade': ex11.c:46: error: request member 'grade' in not structure or union ex11.c:47: error: request member 'grade' in not structure or union ex11.c: in function 'comparebyname': ex11.c:56: error: request member 'name' in not structure or union ex11.c:57: error: request member 'name' in not structure or union this header file: #define class_size 10 struct student { char *name; int idnumber; char grade; }; this main file: #include <stdio.h> #include <stdlib.h> #include <string.h> #include "ex11.h" int main(void) { int c, i; file *data; struct student tmp, class[class_size]; void *namearray[class_size], *gradearray[class_size]; static int comparebygrade(const void *first, const void *second); static int comparebyna

c++ - Don't understand Insert function too well, getting an error I can't seem to get past -

i trying insert user inputted name pre-existing string, , keep getting error stating that: "[error] no matching function call 'std::basic_string::insert(std::basic_string::iterator, std::string&)'" on line 25 code: #include <iostream> #include <string> using namespace std; string custname = " "; string firstname = " "; string midinitial = " "; string lastname = " "; string getfullname = ""; string comma = ","; int getname() { cout<<"please enter first name \n"; cin>>firstname; cout<<"please enter middle initial \n"; cin>>midinitial; cout<<"please enter surname \n"; cin>>lastname; getfullname = firstname+" "+midinitial+". "+lastname; } int addname() { custname.insert (custname.end(), ','); custname.insert(custname.end(), getfullname); } int main

cordova - phonegap can't compile project for iOs 6.1 -

i'm trying upload app app store. have icons in project , compiles ios 5 simulator. in itunes connect i've downloaded screenshots. when uploaded app, apple says: missing localized screenshots. have 1 localized version of app , screenshot it. i've researched on issue , found can because of project not compiling ios 6. i've cheched , project not compiling ios 6 simulator. how solve issue??? someone, please me ) p.s. i'm using phone gap 2.7.

javascript - Handling data through $resource in Angular -

i'm trying figure out best handle working async data. basically, receive data controller doing: userresource.query(function (res) { $scope.user = res; }); this works fine, there's flickering. example, if i'm using along directive (such bootstrap select), render select first (with no data), show correctly. is there elegant way handle this, without creating lots of additional parameters check values , show/hides ng-switch. any tips/best practice suggestions great! thank you using $resource promise pr commit slated 1.1.3 $scope.userresource = function() { var promise = userresource.get().$promise.then( function( res ){ $scope.user = res; }, function( error ){ //something went wrong! } ) return promise; } ran myself recently: callback after async foreach angularjs edit: @dave had catch --- is, in 1.1.4 convention changes too: userresource.get().$then() ... $then

java - Unused private methods, private fields and local variables -

we using sonar review our codebase. there few violations unused private method, unused private field , unused local variable. as per understanding private methods , private fields can accessed outside of class through reflection , java native interface. not using jni in our code base, using reflection in places. so planning complete workspace search these methods , fields , if these not used anywhere through reflection, these commented out. again chances accessing private methods , fields through reflection less. safer side. unused local variables can’t accessed outside of method. can comment out these. do have other suggestions this? i love reflection myself, put in few words: can nightmare. keep java reflection controlable (that is, stateless, no global/external variable usage) , minimal scope. what for? to find private fields , methods turned public, field#setaccessible() , method#setaccessible() , such examples below: field privatenamefield = person.cla

ios5 - Upgrade xibs to iPhone5 -

we have iphone app built 2 years ago. right going convert suit iphone 5. major works converting existed xibs 2 versions: 1 keep same iphone 4 or before, other iphone 5. that means each view controller, have 2 versions of xib. wonder if there alternative solution use same 1 xib, use auto size mask etc achieve this. question here hear feedback or suggest on this. thanks,

excel vba - The following VBA code breaks. How may I keep it running? -

option base 1 sub prepareiofile() 'step 1: open final spq edpss , find earliest start date dim rowcount integer dim lastrow integer = 2 until isempty(cells(i, 1).value) = + 1 loop lastrow = - 1 rowcount = - 2 'step 2: find earliest start date in records dim earliestdate date dim firstdate date earliestdate = cdate(application.min(range("k2:k" & lastrow))) firstdate = earliestdate 'step 3: find number of months between earliest start date , specified month dim nowmonth integer dim nowyear integer nowmonth = inputbox("please specify recent month compute." & vbnewline & "note: month should between 1 , 12 only.") if nowmonth < 1 or nowmonth > 12 msgbox "you have entered invalid month." exit sub else nowmonth = nowmonth nowyear = inputbox("please specify current year compute." & vbnewline & "note: year should entered in yyyy format.") if nowyear < 2008 or

Check out From SVN in Maven Module Project Using cmd -

i have maven mutil module project in svn. i want build using command. got exception of "child module not exist." i want checkout code , build them "mvn clean install." if build project under workspace of project, built wished. could me? many in advance. here images: project output

assembly - IDA Pro python idaapi -

hello have fast question. i have been trying save full memory dump in ida pro in variable perform search python script did not find correct function using idaapi. i want like: import idaapi dump=get_memory_dump() # or whatever function if "foo" in dump: print "foo in dump" how can dump? can see want script found pattherns in memory while debugging application. thank much use idaapi.nextthat() search byte sequence use dbg_read_memory() read memory of program being debugged. since latter appears make copy, reading, say, 4gb unwise.

php - Confused about storing data from this form -

Image
i have been practising mysql , have came across issue can't solve. making large form able store information user in database. have managed make , store data simple form fields name, country, age, interest , etc using mysql , php. i have table called users in database have approximate 15 column different data name, country, age etc. now have added field , confused how store data field. here img of form .... now if create column emp_name how going store 1-4 values each user 5 fields each? even if create different table ex - emp_history how store data form each user? your form should this: <form name="xyz" method="post"> <table> <tr> <td>emp name</td><td>country</td><td>position</td> </tr> <tr> <td> <input type="text" name="data[emp_name][]" value="" /> <input type="text" name="data[country][]" value=&quo

dom - Get particular child node class name javascript -

i want particular child node(i.e. want div). how can this. code <html> <head> </head> <body> <div id="test"> <input type="text"> <div class="nod1"></div> <input type="text"> <div class="nod2"></div> </div> </body> <script> var tst=document.getelementbyid('test'); var childrens=tst.children; for(var i=0; i<childrens.length; i++){ console.log(childrens[i]); } </script> </html> try this for(var i=0; i<childrens.length; i++){ console.log(childrens[i].classname); }

objective c - Changing the JSON string Format -

how change following json structure, [ "registerdevice", { "type": "7", "pushbadge": "1", "pushsound": "1", "enabled": "1", "devicetoken": "e03d25f4f1bd40678cd693fe66fe7946ffdb03e1b23cfc5f9dc747fd5869fbcd", "pushalert": "1" } ] to format using objective-c @"[\"registerdevice\",{\"type\":\"7\",\"pushbadge\":\"1\",\"pushsound\":\"1\",\"enabled\":\"1\",\"devicetoken\":\"e84ab955cd3b9af439f1567b9f80e70d52d3b0209151fe9b3392efc8af9f5e1f\",\"pushalert\":\"1\"}]"; try this, yoursting=[yourstring stringbyreplacingoccurrencesofstring@"\"" withstring:@"\\\""];

android - Get the particular address using latitude and longitude -

i need know there api ,from can receive address of current place.using location manager have receive latitude , longitude of current place ,but need address. i have tried below api. http://maps.googleapis.com/maps/api/geocode/json?latlng="+ lat + "," + lon + &sensor=true" but not showing exact place .can me.@thanks from geocoder object, can call getfromlocation(double, double, int) method. like :- private string getaddress(double latitude, double longitude) { stringbuilder result = new stringbuilder(); try { geocoder geocoder = new geocoder(this, locale.getdefault()); list<address> addresses = geocoder.getfromlocation(latitude, longitude, 1); if (addresses.size() > 0) { address address = addresses.get(0); result.append(address.getlocality()).append("\n"); result.append(address.getcountryname()); } } c

jquery - unable to change fullcalander event color ('fc-event-inner' CSS) (used under JIRA) -

i went through other posts related fullcaldner event color couldn't work me. i tried below calendar.fullcalendar('renderevent',{ id: resp[i].id, title: resp[i].desc, start: s, end: e, allday: true, comments: resp[i].comments, classname: ["event", "greenevent"], eventcolor: '#378006' } also, tried applying @ calendar obejct: disabledragging: false, eventcolor: '#378006', //eventbackgroundcolor: 'red', eventclick:... but make events border color change not cha

jquery scroll, change navigation active class as the page is scrolling messed up, and making wrong links active? -

http://jsfiddle.net/5cfm6/1/ so whenever click on watch, goes div video, if click other link on nav bar, highlights active link, , it's wrong link. example, if click on about, highlight links. me highlight correct div i'm at? this have far. $(window).scroll(function () { var windscroll = $(window).scrolltop(); if (windscroll >= 100) { $('.container div').each(function (i) { if ($(this).position().top <= windscroll - 20) { $('nav a.active').removeclass('active'); $('nav a').eq(i).addclass('active'); } }); } else { $('nav a.active').removeclass('active'); $('nav a:first').addclass('active'); }`enter code here` }).scroll(); i point out (at least in fiddle) "sponsors" div outside of div.container , not work sponsors (e.g. if add more sections after "sponsors") ,

apache - CassUI server not starting -

Image
i trying hands-on cassui. given cassandra server url , port number mycassandraserver:9160 when try see whether server running or not browser giving error - oops! google chrome not connect mycassandraserver.com:9160 any idea? should do? downloaded cassui, deployed local webserver , got work: port 9160 rpc port cassandra, won't able navigate port web browser. make sure navigate server:port of webserver , , should able add cassandra server. rather first step of creating new server under cassui done. i assume referring steps listed here: https://code.google.com/p/cassui/ i'll try keep in mind answers below. now next step run typing :9160 (mycassandraserver:9160) in browser. getting error... this step mis-interpreting. getting error because never going able browse cassandra server web browser on port 9160. 3- add cassandra server's ip address (and port if not 9160 separator being colon) example 127.0.0.1 or 192.168.1.1:916

python - Regex multiline replace -

so have this: z='===hello there===, how ===you===?' and want be: z='<b>hello there<\b>, how <b>you<\b>?' i tried doing this: z = re.sub(r"\={3}([^\$]+)\={3}", r"<b> \\1 </b>", z, re.m) and works sort of got instead: z='<b>hello there===, how ===you<\b>?' i'm still new believe it's ^ , $ makes match beginning , end of string. how change matches ones in middle? re.sub(r"\={3}([^\$]+?)\={3}", r"<b> \\1 </b>", z, re.m) copy python doc click here : *?, +?, ?? '*', '+', , '?' qualifiers greedy; match text possible. behaviour isn’t desired; if re <.*> matched against '<h1>title</h1>', match entire string, , not '<h1>'. adding '?' after qualifier makes perform match in non-greedy or minimal fashion; few characters

android - onCreateDialog() not taking two cases -

i want display timepicker 2 times. retriving start time n stop time. code showing error "duplicate case". tried alot unable find answer silly question. please guide me. protected dialog oncreatedialog(int id) { switch (id) { case time_dialog_id1: // return new timepickerdialog(this, // mtimesetlistener, starthour, startminute, true); toast.maketext(getapplicationcontext(),"hr:"+starthour+"min:"+startminute, toast.length_long).show(); break; case time_dialog_id2: // return new timepickerdialog(this, // mtimesetlistener, starthour, startminute, true); toast.maketext(getapplicationcontext(),"hr:"+stophour+"min:"+startminute, toast.length_long).show(); break; } return null; } i think defined 2 constants have same value. need different values.

python - Writes, Deletes, but won't read text file -

i started learning python today. simple script either read, write 1 line to, or delete text file. writes , deletes fine, when choosing 'r' (read) option error: ioerror: [errno 9] bad file descriptor what missing here...? from sys import argv script, filename = argv target = open(filename, 'w') option = raw_input('what do? (r/d/w)') if option == 'r': print(target.read()) if option == 'd': target.truncate() target.close() if option == 'w': print('input new content') content = raw_input('>') target.write(content) target.close() you've opened file in write mode, can't perform read on it. , secondly 'w' automatically truncates file, truncate operation useless. can use r+ mode here: target = open(filename, 'r+') 'r+' opens file both reading , writing use with statement while opening file, automatically closes file you:

highcharts - Highstocks, line missing but data is there -

Image
i've been playing around highstocks while , reason 1 of lines has disappeared when zooming in, yet still visible once zoomed out. still shows dot once hovering on including data belongs it. needless i'm pretty clueless went wrong, suggestions great. zoomed in: zoomed out (hard see red line there) ps. website can found here skami.net your series contains doubled values same data, example: [1368450000000, null], [1368450000000, 117.200050354004], [1368451800000, null], [1368451800000, 117.599990844727], [1368453600000, null], [1368453600000, 117.710151672363] which not allowed in highcharts. remove point , working fine.

php - PDF generation with Dompdf not working for large data -

i using dom pdf generate pdf file. if there 1000 records in table format of html takes minimum 20 minutes generate of time displaying following error no data received error 324 data segmentation error. error 500 server down is there other easy way generate ? or solutions ? my controller code: $view = new view($this, false); $html = $view->element('reports_affiliate'); ini_set("max_execution_time","-1"); $q = new dompdf($html); $q->load_html($html); $q->render(); $pdf = $q->output(); $q->stream( gmdate("d,d m yh:i:s") . " gmt".".pdf"); please note there no problem in sql queries or template files. i've lot of problem same library. avoid them, i've changed script, adopting tcpdf library . it's install , use, performance. if need high performance, use zend_pdf module.

c++ - Static member variable initialization -

as posted below. how initialize alphabet using alphabet's own member function static member variable? need initialization within "text.cpp" implementation file. text.h class text { private: struct font { enum enum { arial, menlo, times }; }; static alphabet alphabet[3]; // library of letters }; // class i need seen below, correct way of accomplish task. need initialize alphabet once duration of runtime, have made alphabet static. thank you. ^^ text.cpp alphabet text::alphabet[text::font::arial].load("./alphabet/", "arial", ".xml")); alphabet text::alphabet[text::font::menlo].load("./alphabet/", "menlo", ".xml")); alphabet text::alphabet[text::font::times].load("./alphabet/", "times", ".xml")); assuming alphabet has parametrized constructor, can way in single translation unit (in text.cpp file

c++ - How not to repeat myself without macros when writing similar CUDA kernels? -

i have several cuda kernels doing same variations. reduce amout of code needed. first thought use macros, resulting kernels (simplified): __global__ void kernela( ... ) { init(); // macro initialize variables // specific stuff kernela b = + c; end(); // macro write result } __global__ void kernelb( ... ) { init(); // macro initialize variables // specific stuff kernelb b = - c; end(); // macro write result } ... since macros nasty, ugly , evil looking better , cleaner way. suggestions? (a switch statement not job: in reality, parts same , parts kernel specific pretty interweaved. several switch statements needed make code pretty unreadable. furthermore, function calls not initialize needed variables. ) (this question might answerable general c++ well, replace 'cuda kernel' 'function' , remove '__global__' ) updated: told in comments, classes , inheritance don't mix cuda. therefore first part of answer applie

javascript - Jquery show/hide div script broken by HTML -> PHP Arrays, any workaround? -

i working on huge multi page form multiple sub sections , answer dependent sub-questions. i using jquery show/hide divs based on select values works perfectly. when comes handling data able break down post values page. i using following syntax in fields <label>what reference?</label> <input type="text" name="[title][0][reference]" value="<?php echo $out['reference']?>" /><img src="images/hint.png" class="hint" title="edit me!!" /><br /> and calling if else on $_post['title'] , using iterative function handle database side of things. however i'm finding if breaks jquery show/hide div, functionality of integral form (which has 100's of questions reading many seperate tables). this jquery script, there anyway enhance/change allow me use html->php arrays? // works $('#reference').change(function () { var whattoshow = $('#reference&

Kendo UI Mobile not working -

have been trying build sample kendo ui mobile application in mvc. never worked shown in demos. tried same code given in demo in following demo. http://demos.kendoui.com/mobile/forms/index.html#/ but geting following error. no idea, how solve it.! **typeerror: kendo.mobile.application not constructor** var app = new kendo.mobile.application(document.body); please me out. have been stuck on more 1 week.

LINQ Statement for Generic List -

i have bool array , list: bool[ ] searchable list<t> alldata what want following alldata.where(c => searchable[0] && c[0].contains("das") || searchable[1] && c[1].contains("das") || searchable[2] && c[2].contains("das") ... ); how can construct linq function? use this overload of where provides filtering callback index of element being considered along element itself: var results = alldata.where((c, i) => searchable[i] && c.contains("das"));

git - How to deploy my bitbucket code easily to my production server -

i got private git repo on bitbucket, update local repo. works fine. project done , need find solution deploy code production server. i easy , fast solution did not find bitbucket, solution seems designed github... of course can connect serv , make git pull want find automate this. do know service, tool ? i use choose dandelion . it's easy install : gem install dandelion , easy use, have edit dandelion.yml put connection info there , dandelion deploy ! works fine, integrated git , service agnostic :)

java ee - Error deployement on Glassfish 3 -

i'm developing javaee application on glasfish application server. i'm developing i'm continously deployig/undeploying application. everything has worked great until few hours ago when got error while deploying: info: error: org.springframework.web.context.contextloader - context initialization failed java.lang.noclassdeffounderror: lfr/fam/declarationreglementaire/service/comparaison/tableaucomparaisondecregservice; caused by: java.lang.classnotfoundexception: fr.fam.declarationreglementaire.service.comparaison.tableaucomparaisondecregservice @ org.glassfish.web.loader.webappclassloader.loadclass(webappclassloader.java:1518) @ org.glassfish.web.loader.webappclassloader.loadclass(webappclassloader.java:1368) ... 59 more grave: pwc1306: startup of context /declaration-reglementaire-serviceweb failed due previous errors grave: pwc1305: exception during cleanup after start failed org.apache.catalina.lifecycleexception: pwc2769: manager has not yet been started grave

jquery - Repeating functions -

i seem repeat alot of functions when coding simple, there better way of doing this? $('#bt1').click(function() { $('#txt1').show(); $(this).css("background-image", "url(site_images/08/btn_over.png)"); }); $('#bt2').click(function() { $('#txt2').show(); $(this).css("background-image", "url(site_images/08/btn_over.png)"); }); $('#bt3').click(function() { $('#txt3').show(); $(this).css("background-image", "url(site_images/08/btn_over.png)"); }); $('#bt4').click(function() { $('#txt4').show(); $(this).css("background-image", "url(site_images/08/btn_over.png)"); }); so i'm not repeating code? give buttons class , such btn , , can like:- $('.btn').click(function() { $('#' + this.id.replace('bt', 'txt')).show(); $(this).css

xml - How to XSD-Validating single fields on setting them using moxy -

in this fine post learned how validate xml using moxy. problem validation comes @ last , there many failures due invalid parameters given setter methods. there way validate each setter (model based). if set 1 value value validated against constraints. @ time of each set call - complete model may invalidate hell want validation info current set call. in case want throw illegalargumentexception if passes illegal (by xsd constraint) parameter 1 of setters (all setters wrapped interface).

Rails gem for adding quizzes to my rails application -

i started writing own quiz handling module, realized needed lot more options. adding multiple choice questions, need short answer questions, fill in blanks , on. tried looking gem find survey provides mcqs. there gems out there can me add quizzes application? by add quizzes mean, allow user through application create quiz different types of questions , define answers, , other users able answer them. thank you, you can try make yourself. learn rails , ruby , have more appropriate needs. you can @ railcasts shows how work forms , example uses surveys. http://railscasts.com/episodes/197-nested-model-form-part-2?view=asciicast

stack trace - PHP - is it a good idea to use the results of debug_backtrace to display different error messages? -

i've got several places in php application where, depending on functions have been called before, need display different error messages if goes wrong. for instance, in example below if call startedit() function on 'file' directly , file locked, should return error message. if startedit() function called result of startedit() function in parent 'folder' should display different error message (see example below): <?php class folder{ public $files = array(); public function startedit(){ //when start editing folder, start editing files within foreach($this->files $file){ $file->startedit(); } } } class file{ public $islocked = true; public function startedit(){ try{ //if file locked need throw exception if($this->islocked==1){ //loop through stack trace see if called folder class.

r - To create a regular time series -

how can create regular time series of 5 minute ohlc data volume , number_ticks summed? here's i've tried: trades <- structure(list(date = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l), .label = "26-10-2012", class = "factor"), time = structure(1:8, .label = c("09:15", "09:16", "09:17", "09:18", "09:19", "09:20", "09:21", "09:22", "09:23", "09:24", "09:25", "09:26", "09:27", "09:28", "09:29", "09:30", "09:31", "09:32", "09:33", "09:34", "09:35", "09:36", "09:37", "09:38", "09:39", "09:40", "09:41", "09:42", "09:43", "09:44", "09:45", "09:46", "09:47", "09:48", "09:49", "09:50", "09:51",

Localize Prevalue sources in Umbraco Contour -

i have country dropdownlist in contour form want localize. currently, uses "get values textfile" source type. possible, , how? you try , create own fieldprevaluesourcetype , based on cultureinfo.currentculture.twoletterisolanguagename here example; http://www.nibble.be/?p=217 that has been made package. http://our.umbraco.org/projects/backoffice-extensions/contour-countries

How do you change MongoDB user permissions? -

for instance, if have user: > db.system.users.find() { "user" : "testadmin", "pwd" : "[some hash]", "roles" : [ "clusteradmin" ], "otherdbroles" : { "testdb" : [ "readwrite" ] } } and want give user dbadmin permissions on testdb database, can remove user record add new permissions: > db.system.users.remove({"user":"testadmin"}) > db.adduser( { user: "testadmin", pwd: "[whatever]", roles: [ "clusteradmin" ], otherdbroles: { testdb: [ "readwrite", "dbadmin" ] } } ) but seems hacky , error-prone. and can update table record itself: > db.system.users.update({"user":"testadmin"}, {$set:{ otherdbroles: { testdb: [ "readwrite", "dbadmin" ] }}}) but i'm not sure if creates correct permissions - looks fine ma

javascript - jQuery Table row toggle show/hide associated with buttons -

need little jquery , html(table). pls take @ jsfiddle page see gonna try do. http://jsfiddle.net/nori2tae/u25ek/ each td contains value (from 01 06) , has class name related value , lists of buttons above table. when page loaded, buttons enabled means table data visible. when click turn on/off button, want jquery observe on/off status of buttons , if status matches values of each table row, want jquery toggleslide(show/hide) table row. (sorry poor english , explanation...) for example, if turn off button01 row1 hidden. turn button4 , button6 off, row5 hidden. , on or vice versa... html: <ul id="listbtns"> <li><a href="#" class="on">01</a></li> <li><a href="#" class="on">02</a></li> <li><a href="#" class="on">03</a></li> <li><a href="#" class="on">04</a></li> <li><a href=&q

c# - Replace SOH character in string -

i reading small msword document , storing contents in string. there soh special characters included in string. replace them placeholder string, "#placeholder1" before written new text (.txt) file. note not wanting modify/edit msword document i'm not sure if string.replace suit or if need go different route. may parameter using soh character. suggestions? there's no reason why you're doing shouldn't work. here's minimal example can test on ideone : using system; public class test { public static void main() { string s = "\u0001 test \u0001"; s = s.replace("\u0001","yay!"); console.writeline(s); } } the other thing can think might doing wrong, not storing result of call replace .

Trying to pass a subdirectory as a parameter in Perl -

i have perl program read .html's , works if program in same directory .html's. able start in different directories , pass html's location parameter. program (shell example below) traverses subdirectory "sub" , subdirectories .html's, works when perl file in same subdirectory "sub". if put perl file in home directory, 1 step subdirectory "sub", doesn't work. in shell, if type "perl project.pl ./sub" home directory, says not open ./sub/file1.html. no such file or directory. yet file exist in exact spot. file1.html first file trying read. if change directories in shell subdirectory , move .pl file there , in shell: "perl project.pl ./" ok. to search directories, have been using file::find concept found here: how traverse files in directory; if has subdirectories, want traverse files in subdirectories too find::file search directory of list of files #!/usr/bin/perl -w use strict; use warnings; use

Aligning form elements in a bootstrap dialog -

i created demo of problem here: http://jsfiddle.net/xwcba/ the form here asks email , password, , below "remember me" checkbox, , "forgot password" link (button). here problem - "forgot password" link below checkbox. want on the same row checkbox, , right-aligned . i've been knocking around while, , can't seem "forgot password" link need be. suggestions? <div class="controls controls-row"> <label class="checkbox span4"><input type="checkbox" id="inlinecheckbox1" value="option1"> remember me 2 weeks</label> <button type="button" class="btn-link span2">forgot password?</button> </div> you put button inside 'checkbox' label, , use pull-right on controls-group this... <div class="control-group pull-right"> <div class="controls controls-row"> <label class=&

actionscript 3 - Breakout game in AS3 error #2007 -

i came upon error can't fix. i'm making game , should "you lose" after losing 3 lives, in case freezes , error. typeerror: error #2007: parameter hittestobject must non-null. @ flash.display::displayobject/_hittest() @ flash.display::displayobject/hittestobject() @ fatality/enterframeevents()[c:\documents , settings\labo\bureaublad\gip 12 mei\fatality.as:26] have @ code. code i've written in class basicly class "game over" power in breakout game. when touches paddle, it's game over. problem freezes after touches paddle instead of showing "you lose". package { import flash.display.*; import flash.events.*; public class fatality extends movieclip { private var yspeed:number = 1; private var _root:movieclip; public function fatality() { // constructor code addeventlistener(event.added, beginclass); addeventlistener(event.enter_frame, enterframeev

java - OK to use JSON output as default for toString()? -

@override public string tostring() { return new gson().tojson(this); } am breaking practice, "joshua"-pattern thing, general design pattern or other convention doing default behavior model objects? tostring() anyhow used in debugging in paradigm (android) using. that's reason why seeing object in json since orm/json persistence happening through http->php/python->mysql , local sqlite. there's no harm in doing way. suggest create static variable gson instance , enable pretty printing: static gson gson = new gsonbuilder().setprettyprinting().create(); this way output tostring method formatted.

javascript - Fix navigation position when scrolling -

i want fix position of navigation @ top when navigation position , scroll position equal. please let me know how can position of navigation , page scroll position? want this: http://new.livestream.com/live-video-tools i've tried: $(function() { // grab initial top offset of navigation var sticky_navigation_offset_top = $('#main-heading').offset().top; // our function decides weather navigation bar should have "fixed" cs s position or not. var sticky_navigation = function(){ var scroll_top = $(window).scrolltop(); // our current vertical position top // if we've scrolled more navigation, change position fixed stick top, // otherwise change relative if(scroll_top > sticky_navigation_offset_top) { $('#fixed_nav').css({ 'position': 'fixed', 'top':6, 'left':0, 'width':'100%', 'z-index':999, 'height':80, 'backgrou

c# - Identical entities generating different ids -

how can ensure ef generates same id same occurence of object? e.g. if have class like: class foo{ icollection<bar> bar1; icollection<bar> bar2; } if create new entity foo , add single instance of bar (no id set) both bar1 , bar2 - use same id both or create new 1 each time? e.g.: var bar = new bar(); var foo = new foo{ bar1 = new list<bar>(){ bar }; bar2 = new list<bar>(){ bar }; } context.savechanges(); will bar1 , bar2 contain same record bar same id? update: if have 2 instances same respect equals , hash code? var first = new bar(); var second = new bar(); /// first.equals(second ) var foo = new foo{ bar1 = new list<bar>(){ first }; bar2 = new list<bar>(){ second }; } or ef not check equals? yes, entity framework create 1 record foo , 1 record bar in database. since both lists contain same instance of bar respective database entries point same record.

javascript - Is context.clearRect() really THAT expensive? -

i have piece of canvas animation exhibiting weird characteristics: http://jsbin.com/olasol/2/edit i'm on latest version of chrome. i'm using chrome's inbuilt fps monitor (you can activate going about:flags ). have marked line in javascript section think potential culprit: fallingctx.clear(); this line nothing special. calls function in-turn calls clearrect() . the "weird" things notice are: the clear(); function causes noticeable fps drop on laptop (core 2 duo), not on desktop (i5 2500k). removing line alone sufficient produce 60fps on laptop well. expected, canvas doesn't clear after each frame, still, produces stable 60fps. the fps drop happens when chrome window on larger side! when shrink window , reload, doesn't happen! (is more expensive clear larger rectangle?). i tried replacing clear() drawimage() of full white jpeg cover canvas. javascript able 200 drawimage() executions each cycle smaller image particles (evident second p

php - Removing null columns in SQL query -

i'm using select * query table. $query = $this->db->get($table_name); what want discard records value column empty example array { topic_1 -> topic_2 -> cats } it discard topic_1 key , value pair entirely. i'm using codeigniter active record tried doing $query = $this->db->get_where($value, array(test_id != 'null')); but cannot specify each column, want test_id columns in table? there can or can run loop after query returned discards unmatched key value pairs? first, doing null wrong. should go this: $query = $this->db->where('test_id !=', null)->get($value)->result_array(); that query work when field null, in case not null, empty. in order field null must specify default when creating table. query case be: $query = $this->db->where('test_id !=', '')->get($value)->result_array(); for fields, guess need go foreach loop: $data = array(); $field = array('field1&

Send Glympse API Web API? -

besides showing web mapview of glympse. is there js lib sending of glympse via web api? useful develop mobile / desktop web application uses geolocation html5. at moment map control public api provide web. going extend set of exposed apis , supported platforms on time. keep eye on our announcements!

sql - EF5 Code First Automatic Migrations to Azure Database -

i posted more detailed question not getting many responses. so, in simplest terms, has set automatic migrations on azure database using ef 5.0 code first? please respond if have , can go there. yes, have managed set up, , works. can refer this post see problem had.