Posts

Showing posts from February, 2011

MIPS instructions to set a register to 1 -

this question has appeared in few past papers cannot find on internet. what 6 single instruction mips can set $v1 hold decimal value of 1? against common misconception, li , la or move not single instruction, pseudo instructions, taking multiple machine instructions execute. because of guess don't come option. here instructions can such thing addi $v1, $zero, 1 addui $v1, $zero, 1 ori $v1, $zero, 1 xori $v1, $zero, 1 # these use comparison slt $v1, $zero, $31 # last 1 can non-empty register slti $v1, $zero, 1 sltu $v1, $zero, $31 # last 1 can non-empty register sltiu $v1, $zero, 1 # these use memory lb $v1, one($zero) lbu $v1, one($zero) lh $v1, one($zero) lhu $v1, one($zero) lw $v1, one($zero) one: .word 1 when counting pseudo instructions, li , la come available too.

java - Extracting Word count / frequency count using Wordnet database -

i looking word count/frequency extraction according word's usage in general english http://www.wordcount.org/main.php . using jwnl api accessing wordnet dictionary , unable find way this. you might want google n-grams corpus. unigram counts give relative frequencies of each word. @ 1 point, did go through , link of words in wordnet corresponding n-gram count; can find list here: https://raw.githubusercontent.com/gangeli/sim/master/etc/weighted_wordnet_vocabulary.tab note in no way "canonical" list that's in way officially supported, it's put once.

php - How to preg_replace content between {{ }} -

the following code replace content between {{ }} . example use {{example}} load custom text db replace content in html output. works @ times not , unsure why. maybe in same line if use 2 {{one}} , {{two}} .. thought maybe doing preg_replace wrong. function translate($tagname){ global $$tagname; return $$tagname; } function replacetags($body){ $body = preg_replace('!{{(.*?)}}!uei', "''.translate('$1').''", $body); return $body; } you should drop u modifier, turn ungreedy (.*?) greedy, , not want. also, e modifier deprecated in php 5.5.0. use preg_replace_callback instead: $firstname = 'jane'; $lastname = 'doe'; function translate($tagname){ global $$tagname; return $$tagname; } function translatematch($matches) { return translate($matches[1]); } function replacetags($body){ $body = preg_replace_callback('!{{(.*?)}}!i', 'translatematch', $body); return $bo

android - Gradle cannot find target sdk -

i need write small library submodules. when try sync project error. if use gradle gradle:1.0.1 error:configuration name 'default' not found. if build:gradle:1.2.3 error:cause: failed find target 21 but sdk installed. here build.gradle uildscript { repositories { mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' } } apply plugin: 'com.android.library' android { compilesdkversion 21 buildtoolsversion "21.1.2" defaultconfig { minsdkversion 9 targetsdkversion 21 versioncode 1 versionname "1.0" } compileoptions { sourcecompatibility javaversion.version_1_7 targetcompatibility javaversion.version_1_7 } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } }

assembly - NASM: in/out instead of int -

when writing bootloader how make calls ports instead use of interrupts (i.e. int 10h )? there list someplace online unaware of known vectors? there place can go mapping of hardware not covered bios interrupts (i.e. pci - gpus)? well, problem is not mapping of hardware , not bootloader in computer. what talking writing of driver. bios manages simplest devices , uses best available methods achieve programmer wants. , programmer there api access it, x86 real mode means interrupts, simplest way of doing complete context switch. if still want remain in real mode, there several more interrupts not aware of, can found in somehow complete ralf brown´s interrupt list . however, pci , gpus works on high frequencies lots of data, , requires more memory , performance, can not operated on real mode. protected , long mode way go. i8086 has mentioned in , out instructions method of accessing devices. whilst used true , devices keeps true, there many other ways of communicating

scala - continuously fetch database results with scalaz.stream -

i'm new scala , extremely new scalaz. through different stackoverflow answer , handholding, able use scalaz.stream implement process continuously fetch twitter api results. i'd same thing cassandra db twitter handles stored. the code fetching twitter results here: def urls: seq[(handle,url)] = { await.result( getall(connection).map { list => list.map(twittertoget => (twittertoget.handle, urlboilerplate + twittertoget.handle + parameters + twittertoget.sinceid) ) }, 5 seconds) } val fetchurl = channel.lift[task, (handle, url), fetched] { url => task.delay { val finalresult = calltwitter(url) if (finalresult.tweets.nonempty) { connection.updatetwitter(finalresult) } else { println("\n" + finalresult.handle + " not have new tweets") } s"\ntwitter fetch & database update completed" } } val p = process val process = (time.awakeevery(3.second) zipwith p.emitall(urls))(

php - build website in hosting then transfer it to vps -

i'm trying move site hosting vps didn't work. what i'm doing build website in : zyro.com then move when i'm trying open website (after transfer of site) show me empty web page. and i'm transfer website hosting , it's working 100% not working on vps. is there program should install on vps ? update : the error : notice: undefined variable: lang in /home/www/html/public_html/zyro/1.php on line 1 notice: undefined variable: lang in /home/www/html/public_html/zyro/1.php on line 80 notice: undefined variable: lang in /home/www/html/public_html/zyro/1.php on line 159 and in line 1 there : <?php if ($lang == 'en') { ?> and line 80 there : <?php } else if ($lang == 'ar') { ?> and line 159 there : <?php } else if ($lang == 'fr') { ?> enable php error reporting in php.ini. add line (or modify existing): display_errors = on you can post errors here, after. or, if don't know how tr

text detection from an image with perspective distortion using matlab -

can know different methods text detection image perspective distortion using matlab or code available.is opencv better matlab text detection i think, matlab text detection (ocr). there ara few libraries ocr. important ones : abbyy tesseract tesseract considered 1 of accurate open source ocr engines available. i have worked on ocr perspective distortion , use matlab-tesseract library. i have handle perspective distorsion problem rotate image finding image border , lines houghlines method. i share code snippet , hope gives vision issue function [ output_args ] = rotate_image( ) clc; close all; clear; = imread("any_images") i2 = imcrop(i,[85 150 590 480]); i3 = imcrop(i2,[-85 0 440 480]); imwrite (i3,'original.tiff', 'resolution', 300); thresh = graythresh(i3); bimage = im2bw(i3, thresh); bimage = edge(bimage,'sobel'); [

Getting "shared memory ID" error on Linux -

running version of linux: linux trhtmxslsp01b02 2.6.32-358.14.1.el6.x86_64 #1 smp mon jun 17 15:54:20 edt 2013 x86_64 x86_64 x86_64 gnu/linux i attempt start process getting following error openshmmemory(): cannot shared memory id, no such file or directory. the app/process i'm running read shared memory segment. don't know how troubleshoot this. third party app. can provide guidance please?

css - Nested media queries output -

i've switched sass less (work) , wondering if possible output less (using mixin): footer { width: 768px; @media screen , (min-width: 992px) { width:900px; } @media screen , (min-width: 1200px) { width:1200px; } } i can seem output in separate breakpoints (instead of under selector): @media screen , (min-width: 720px) , (max-width: 959px) { footer { width: 768px; } } @media screen , (min-width: 960px) , (max-width: 1199px) { footer { width: 3939px; } } this mixin i've been using: .respond-to(@respondto; @rules) when (@respondto = "lg") { @media screen , (min-width: 1200px) { @rules(); } } .respond-to(@respondto; @rules) when (isnumber(@respondto)) { @media screen , (min-width: @respondto) { @rules(); } } and using so: div.class { .respond-to(120px, { float:left; }); .respond-to("lg", { float:none; }); } any appreciated! short answer: no, cannot output require u

cmd - How to detect the terminal that is running python? -

i've tried sys.platform, platform.system() , os.name none of them return related cygwin (i win32, windows , nt output). maybe because python installed on windows (8.1) , not through cygwin. need detect if python file being executed cygwin or cmd. cygwin uses linux-style paths; might able check path separator: import sys import os.path def running_cygwin(): return sys.platform == 'win32' , os.path.sep == '/' (i don't have cygwin here, untested.)

android - imageView.setImageBitmap(bitmap) allways null while bitmap not null -

i pass string photo path activity, convert uri (because photo path converted uri), made inputstream uri, , made bitmap inputstream. bitmap created , not null, when call imageview.setimagebitmap(bitmap) , system give error that: void android.widget.imageview.setimageuri(android.net.uri)' on null object reference. private void showimage(uri mpath) { photopath=mpath.tostring(); inputstream = null; try { = getcontentresolver().openinputstream(mpath); bitmap bitmap = bitmapfactory.decodestream(is); is.close(); photo.setimageuri(mpath); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } what problem met, please me ! thank you it sounds imageview null. resolving problem fix error.

ruby - Rails - Maximum Use of Symbols in Views -

i have stumbled upon thinking block , wanted have input pros. i using rails , here sample code views: <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { id: "confirmation", method: :post }) |f| %> <%= devise_error_messages! %> <div class="form-group"> <%= f.label :email %> <%= f.email_field :email, autofocus: true, class: "form-control" %> </div> <div class="form-group"> <%= f.submit "resend confirmation instructions", class: "btn btn-primary" %> </div> <% end %> i think can replace strings symbols memory efficient so: <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { id: :confirmation, method: :post }) |f| %> <%= devise_error_messages! %> <div class="form-group"> <%= f.label :email %> <%= f.email_field :ema

javascript - setTimeout function not triggering on first mouseenter / hover -

overview: creating menu shows div 'showme' when hover on list item class 'showhim'. want delay when switching between list item included settimeout function. problem: settimeout function not being triggered on first mouseenter event. if remove settimeout function mouseenter event works fine. mouseenter tried: i've tried mouseover , mouseout see if make difference. if put mouse on span (the menu item name) settimeout function trigger. also, when put border on top parent div , hover on border before entering 'showhim', settimeout function triggered , menu works fine. have no clue why border make work.. // fake these snippet var ishomepage = false; function ismobile() { return false; } // end of fake $('.showhim').mouseenter(function() { if (!ismobile()) { var $this = $(this); timer = settimeout(function() { $('.mastermenuitem').removeclass('menu-active'); $('.mainmenuitem'

servicestack - Service Stack set HttpCookie.Secure Flag / Attribute? -

i'm trying set secure flag on session cookies (ie https://www.owasp.org/index.php/secureflag ). i've attempted: public override void configure(container container) { ... config.onlysendsessioncookiessecurely = true; ... } without success - when viewing in fiddler, chrome developer tools, etc - secure flag not being set. appreciated. you need use setconfig() when configuring servicestack, e.g: setconfig(new hostconfig { onlysendsessioncookiessecurely = true, });

sql - Overwrite ONE column in select statement with a fixed value without listing all columns -

i have number of tables large number of columns (> 100) in sql server database. in cases when selecting (using views) need replace 1 of columns fixed result value instead of data row(s). there way use select table.*, 'value' column1 table if column1 column name within table? of course can list columns expected result in select statement, replacing 1 value. however, inconvinient , having 3 or 4 views have maintain them if columns added or removed table. nope, have specify columns in case. , have more serious problems if tables being changed often. may signal of large architectural defects. anyway, listing columns instead of * practice, because if columns number will change, may cause cascade errors.

jspdf - Extract graph image using PhantomJs -

i use jqplot create complex data graph clinical web application using ie7. now, need create pdf , graph part of pdf. since ie7, can't export jqplot graph image. my plan is: from web app, user clicks on button send graph data (json) web service on remote server. on remote server, have html page built dynamically phantomjs using json data passed web service. when page load complete, "rasterize ??" page graph image. i use image in building pdf using package jspdf. return pdf uri web app. does make sense @ all? struggle on how integrate moving parts together. suggestions?

Open the lookup dialog of a field in CRM 2011 from javascript -

how can launch lookup dialog of lookup field, using javascript? here example of how launch lookup dialog custom page - based on crm2011 (post rollup 12). var organizationurl = "http://servername:5555/organizationname"; //object type code of entity needs shown in lookup. var objecttypecode = 1000; var urltoopen = organizationurl + "/_controls/lookup/lookupinfo.aspx?lookupstyle=single&browse=0&showpropbutton=1&allowfilteroff=1&objecttypes=" + objecttypecode; //get modal window var modalwindow = json.parse(window.showmodaldialog(urltoopen, " ", "dialogheight:600px;")); //selected id returned here var selecteditemid = modalwindow.items[0].id;

regex - Perl: Sort part of array -

i have array many fields in each line spaced different spacing like: inddummy drawing2 139 30 1 0 0 0 0 0 rmdummy drawing2 69 2 1 0 0 0 0 0 pimp drawing 7 0 1444 718 437 0 0 0 i'm trying make sorting array number in 3rd field desired output should be: pimp drawing 7 0 1444 718 437 0 0 0 rmdummy drawing2 69 2 1 0 0 0 0 0 inddummy drawing2 139 30 1 0 0 0 0 0 i tried make split using regular expression within sorting function like: @sortedlistoflayers = sort { split(m/\w+\s+(\d+)\s/gm,$a) cmp split(m/\w+\s+(\d+)\s/gm,$b) }@listoflayers; but doesn't work correctly. how make type of sorting? you need expand out sort function litt

ios - Disablic spell check while keeping autocorrect in swift -

in uitextview when user spells incorrectly, gets underlined in red. how can remove without disabling autocorrect? text views have properties both autocorrection , spelling checking. these can set in attributes inspector. or in code via spellcheckingtype , autocorrectiontype . in case want disable spell checking whilst leaving autocorrect enabled. the various possible constant values detailed at: uitextinputtraits

ssl - How to use the Comodo certificate in Web2py? -

when using web2py, asks single ssl certificate file. but got comodo 2 files, 1 .crt file , 1 .ca-bundle file. i tried using provide .crt file when setting web2py, in beginning works. when go website day, shows "this certificate cannot verified trusted certification authority." my suspicion related case of not using .ca-bundle file. knows how use both files in web2py settings? finally got working! it turns out web2py 'one step production deployment' script not complete. leaves out 'sslcertificatechainfile' option when configures apache server. so adding line: sslcertificatechainfile = path_to_your_ca-bundle_file below line 'sslcertificatekeyfile /etc/apache2/ssl/self_signed.key' work.

AngularJS creates infinite loop when $http request returns error -

my problem pretty simple, i'm not able find out happens. all want read posts local rest api. when i'm responding http 401 api, angularjs keeps repeating requests in infinite loop. var request = { method: 'get', url: 'http://jentzschserverdev-46690.onmodulus.net/index.php/issues', headers: { 'anonymous': true } }; $http(request) .success(function(data){ console.log('success', data); deferred.resolve(data.issues); }) .error(function(){ console.log('error'); deferred.resolve([]); }); the console tells me: error: [$rootscope:infdig] 10 $digest() iterations reached. aborting! watchers fired in last 5 iterations: [] http://errors.angularjs.org/1.3.15/$rootscope/infdig?p0=10&p1=%5b%5d @ angular.js:63 @ scope.$digest (angular.js:14346) @ scope.$apply (angular.js:14571) @ done (angular.js:9698) @ completerequest (ang

c# - How to get status of remote windows service -

i'm trying status of remote windows service. use code this, nothing happens. labels have not value. please! connectionoptions options = new connectionoptions(); options.password = "password"; options.username = "username"; options.impersonation = system.management.impersonationlevel.impersonate; managementscope scope = new managementscope("\\\\computer_name\\root\\cimv2", options); scope.connect(); servicecontroller sc = new servicecontroller("service_name", "computer_name"); label1.text = sc.servicename; label2.text = sc.status.tostring();

python - How can I extract the text between comment tags with Beautiful Soup? -

i have following html code: <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html><!-- instancebegin template="/templates/banddetails.dwt" codeoutsidehtmlislocked="false" --> <head> <!-- instancebegineditable name="doctitle" --> <title>&lt;blr&gt;</title> <!-- instanceendeditable --> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <!-- instancebegineditable name="head" --><!-- instanceendeditable --> </head> <body> <div align="center"> <table width="0" border="0" cellpadding="0" cellspacing="0" id="maintable"> <tr> <td colspan="2" id="navbar"><!--#include file="menu.htm" --></td> </tr> &l

database - JSON: read array from DB -

i need location database, it's array. i try lot of code every code me error "could not cast value of type nsarray nsdictionary" or that. this last try: let jsondata:nsdictionary = nsjsonserialization.jsonobjectwithdata(urldata!, options:nsjsonreadingoptions.mutablecontainers , error: &error) as! nsdictionary var location = ((jsondata nsdictionary)["locations"] as! nsdictionary)["location_name"] as! string println(customernamedb) this response: {"status":"1","city_name":"mumbai","city_id":"3","locations":[{"location_id":"1","location_name":"andheri"},{"location_id":"2","location_name":"lower parel"},{"location_id":"59","location_name":"lower parel"},{"location_id":"102","location_name":"lower parel"},{"

jquery - TableSorter - when creating new child rows, it is ignored by the sorter -

tablesorter works child rows - need give child tr tablesorter-childrow class , parent tr tablesorter-haschildrow class, , table sorter able sort table while ignoring child rows... however, when creating new children on fly using jquery, tablesorter no longer ignores these newly created children... when trying sort new table (i.e. after creating children), newly created children pushed top of table , rest of table sorted normal. this demonstrated jsfiddle: https://jsfiddle.net/szzp0aq9/1/ is possible tablesorter ignore these newly generated child rows? edit background: had empty hidden child rows under each row show() when required... however, table produced program can quite large, on 5000 rows, these empty hidden rows increases file size quite bit... trying see if create these rows when required , still keep table sorter happy... (btw, html file produced program viewed on local machine , not uploaded onto internet) when new row added, tablesorter inte

spring - Loading Image into byte array in entity bean -

i using spring data jpa , hibernate retrieve entities db table. 1 of entity fields path image located on filesystem. possible load image byte array entity? e.g @entity @table(name="users") public class user { @id @generatedvalue int id; string name; string picturename; @transient byte[] image; // other properties public void setpicturename(string picturename) { string path="d:\\images\\"; file f = new file(path + picturename); this.image = new byte[(int)f.length()]; fileutility.tobytearray(f,this.image); //custom class this.picture = picture; } //other stuff } i tried jpa byte array image field comes null while else fine. yes, possible, have map whatever column has picture name hibernate can populate it. thus, if have column called "picture_name" entity should have: @column(name="picture_name") private string picturename; then, when hibernate loads

jquery - When running multiple javascript functions, only first few work -

i want run function on click runs multiple other javascript functions. works, first few functions called. more detail: trying filter grid. "savedsearch" function called button search multiple fields according saved search criteria (i.e. filter column "monday", in model). each "sub-function" (the "appliedsearch" functions) applies different field. first few work (i've tried formatting many different ways). example, filter columns a, b, , c, nothing happens columns d, e, , f. note: "applysearch" function trying call, "columna" field name sending function, @html.raw(json.encode(model.columna)) variable (i.e. "monday" in example above). function savedsearch(e){ if (@html.raw(json.encode(model.columna)) != "0") { applysearch1("columna", @html.raw(json.encode(model.columna))); } if (@html.raw(json.encode(model.columnb)) != &

out of memory - Android take more picture from camera "Couldn't allocate byte array for JPEG data" -

i'm trying take picture in sequence android, timelapse. i call camera.takepicture(null, null, jpegcallback); and jpegcallback is: picturecallback jpegcallback = new picturecallback() { public void onpicturetaken(byte[] data, camera camera) { time++; photocounter.settext(string.valueof(time)); saveimagetask sav = new saveimagetask(filenameind++); sav.execute(data); resetcam(); log.d(tag, "onpicturetaken - jpeg"); } }; private class saveimagetask extends asynctask<byte[], void, void> { int name; saveimagetask(int name){ this.name = name; } @override protected void doinbackground(byte[]... data) { fileoutputstream outstream = null; // write sd card try { file sdcard = environment.getexternalstoragedirectory(); file dir = new file (sdcard.getabsolutepath() + "/timelaps"); dir.mkdirs(); java.t

Fullcalendar – custom aspect ratio to each view -

i have read the documentation don't understand how use code. i'd have custom aspect ratio on each view – avoid scrollbar in day-view. how implement code change aspect ratio week , day view when fullcalender script this: $(document).ready(function() { $('#calendar').fullcalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaweek,agendaday' }, weekends: false, weeknumbers: true, googlecalendarapikey: 'aizasybgcsyro6grnvysge2uxerwpih78sjhm9w', eventsources: [{ googlecalendarid: 'oa4lj06jlgehp2sl7f1s7hubi8@group.calendar.google.com', rendering: 'inverse-background' }] }); });

Double quote in php json encode -

the json out of file is: [{"name":"ltrs","data":["25","80","110","113","139","1025","1026","1027","1028","1029"]},{"name":"total","data":["3","723","19","48","3","6","14","17","15","6"]}] i require: [{"name":"ltrs","data":["25","80","110","113","139","1025","1026","1027","1028","1029"]},{"name":"total","data":[3,723,19,48,3,6,14,17,15,6}] json required plotting bar chart in highchart.js . when run php query mysql json encode gives output double quote. i guess want if name = total here code try it: var = [{"name":"ltrs","da

scala - Passing a method as argument without converting it to a Function -

i've read here difference between functions , methods in scala. says methods can faster functions. when passing method m argument using m _ , m implicitly converted function. is performance difference significant enough ponder avoiding functions when going bottleneck in program? is there way pass method argument without converting function? kind of irrelevant 2 . in general, forget performance, methods more readable function declarations. might little faster in situations compiler optimizations, but: you cannot pass method argument without converting function. method special language construct, , not object itself. must use eta-expansion convert 1 if want use object.

r - Naive Bayes implementation -

in project, used naive bayes implementation "e1071" library , time execution large. then, used naive bayes implementation "nblearn", , results similar execution time 10 times smaller! has noticed same? can reason that? testnaivebayes <-function(formula, trainingdata, testdata) { model <- naivebayes(formula, trainingdata) pred <- predict(model, testdata) result <- calcratesfor(formula, testdata, pred ) result } testnb <-function(formula, trainingdata, testdata) { cl <- tostring(formula[[2]]) model <- naive.bayes(trainingdata, cl) pred <- predict(model, testdata) result <- calcratesfor(formula, testdata, pred ) result }

plot - Scatterplot of Year-On-Year Correlation of Data in R using ggplot2 -

Image
i have yearly football data test see if team metrics repeatable in next year. data in data.frame , looks this: y2003 y2004 y2005 team 1 51.95455 51.00000 53.59091 team 2 54.18182 56.31818 49.09091 team 3 48.68182 46.86364 49.22727 team 4 50.86364 47.68182 48.72727 what want able scatterplot "year n" on x-axis , "year n+1" on y-axis. example 2003 vs. 2004, 2004 vs. 2005, 2005 vs. 2006 etc. on same plot. i able draw line of best fit see how strong correlation is, whether repeatable or not. what best way in r ggplot2? can initial plot with: p=ggplot(df,aes(y2003,y2004)) p + geom_point() then have add them manually? there inbuilt function sort of thing? , if add them one-by-one how best fit? you want data frame row each team-year combination, containing data year , next year team name. can without split-apply-combine manipulation using base r functions: (to.plot &l

Getting java output in python -

based on last question here , trying run java in python , results. far code looks this: import subprocess = subprocess.popen(['java -xmx1024m -jar ./maui-standalone-1.1-snapshot.jar run /data/models/term_assignment_model -v /data/vocabulary/nyt_descriptors.rdf.gz -f skos'], cwd=r'/users/samuelburke/repositories/rake-tutorial/', shell=true, stdout=subprocess.pipe) out, err = a.communicate() print out the java on own, when run in command line returns list of keywords text so: 04 jun 2015 12:49:10 info vocabulary - --- loading rdf model skos file... 04 jun 2015 12:49:12 info vocabulary - --- building vocabulary index rdf model... 04 jun 2015 12:49:12 info vocabulary - --- statistics vocabulary: 04 jun 2015 12:49:12 info vocabulary - 498 terms in total 04 jun 2015 12:49:12 info vocabulary - 0 non-descriptive terms 04 jun 2015 12:49:12 info vocabulary - 0 terms have related terms keyword: food 0.010580524344569287 keyword: theater 0.0022471910

c++ - how to fill std::vector from istream using standard stl algorithms -

there old legacy code fills vector istream , objects within vector accept in ctor string raw data. typedef std::vector<myclass*> my_array; std::istream& operator >> (std::istream& s, my_array& arr) { if (s) { std::istream_iterator<std::string> i_iter = s; for(++i_iter; !s.eof(); arr.push_back(new myclass(*i_iter++))); } return s; } where myclass ctor looks like: myclass(const std::string& data); do see way avoid writing operator>> or other functions , use (?) standard algorithm fill container constructed objects? replace pointers on values within container emplace contructing. by way, code compiled vc10 doesn't work properly, looks infinite loop when i'm stepping on for. istream (really ifstream there) small file ~200 lines of text you use std::transform . code requires c++11, if won't work you, change lambda factory method , alias declaration typedef : using it_type = std::istream_itera

javascript - To check if ajax call is synchronous or asynchronous in Browser Dev Tools -

is there way confirm whether particular ajax request in async or sync in browser dev tools chrome developer tools or firebug. for ajax request http request header not indicate whether sync or async. x-requested-with:xmlhttprequest no cant can run in console or add code xmlhttprequest.prototype.open = (function(open){ return function(method, url, async, user, password) { console.log("xhr call: "+url +"isasync: "+async); open.apply(this, arguments); }; })(xmlhttprequest.prototype.open); it logs infomation :d hope helpful

Android Studio Key store -

i have apps uploaded play store. going change operating environment windows linux. need same keystore update app. how can use same key store in linux? why key store required? you have to copy keystore platform platform. it's highly recommanded doc : warning: keep keystore , private key in safe , secure place, , ensure have secure backups of them. if publish app google play , lose key signed app, not able publish updates app, since must sign versions of app same key. (source)

elisp - Emacs ECB methods window not updating -

so have emacs 24.3.1 installed, , 24 onwards comes cedet. installed ecb through list-packages , seems work - except methods window refreshing. when open file, methods displayed , can jump them no problem. issue never refresh without restarting emacs. have experimented every related variable find , nothing works. desperately looking solution, sice pretty nullifies methods window usability when i'm expanding project. i have these variables added, no emacs errors, still won't refresh - neither after saving, nor after idle time. (setq auto-update-methods-after-save 1) (global-semantic-idle-scheduler-mode 1) (global-semanticdb-minor-mode 1) i new this, may missing obvious solution. me? can provide configuration file or info you'll need. edit: of course tried c-c . r , no results.

Best practice for shared r/w storage between nodes in Google Container Engine -

i have ruby on rails cms app. images stored in folder based on db auto-increment id. best practice sharing folder between containers run on multiple nodes? the app caching cropped versions of image files. if use google sql, think ensure there never same filename on orginale written file. cached versions should maybe stored differently?

c# - Load and save to text from IList<T> -

here code - class appointments:iappointments { private readonly ilist<iappointment> _list = new list<iappointment>(); public appointments() { } public bool load() { throw new notimplementedexception(); } public bool save() { throw new notimplementedexception(); } public ienumerable<iappointment> getappointmentsondate(datetime date) { throw new notimplementedexception(); } public int indexof(iappointment item) { return _list.indexof(item); } public void insert(int index, iappointment item) { _list.insert(index, item); } public void removeat(int index) { _list.removeat(index); } public iappointment this[int index] { { return _list[index]; } set { _list[index] = value; } } public void add(iappointment item) { _list.add(ite

python - Does __ne__ use an overridden __eq__? -

suppose have following program: class a(object): def __eq__(self, other): return true a0 = a() a1 = a() print a0 != a1 if run python output true . question the __ne__ method not implemented, python fall on default one? if python fall on default method determine whether 2 objects equal or not, shouldn't call __eq__ , negate result? from the docs : there no implied relationships among comparison operators. truth of x==y not imply x!=y false. accordingly, when defining __eq__() , 1 should define __ne__() operators behave expected.

c - Wait for all processes reach some point in program, then resume -

i have application creates many processes via fork(). @ point want pause them , wait until of them finish earlier tasks. start them @ once. for (int = 0; < n; i++) { if(fork() == 0) { //some operations here <----- wait here n forked processes //some operations want processes start @ similiar time i don't want of children quit. this seems tailor-made semaphore. specifically, easy implement "system v semaphores". see semget(2) , semop(2) . the idea obtain semaphore in parent, initialize value n , have each child it's "ready" decrement value 1. children wait result become 0. voila. here's sample program #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #define n 5 int main(int ac, char **av) { int i, n, sem_id; sem_id = semget(ipc_private, 1, 0777); struct sembuf buf; b

Same style for every row in Android's TableLayout -

is there way in android xml set same style (or style paramerers, padding) rows in tablelayout @ once? what avoid doing is: <tablelayout> <tablerow style="@style/mystyle">...</tablerow> <tablerow style="@style/mystyle">...</tablerow> <tablerow style="@style/mystyle">...</tablerow> <tablerow style="@style/mystyle">...</tablerow> ... </tablelayout> you can define own styles creating xml files on res/values directory. so, let's suppose want have red , bold text, create file content: <?xml version="1.0" encoding="utf-8"?> <resources> <style name="myredtheme" parent="android:theme.light"> <item name="android:textappearance">@style/myredtextappearance</item> </style> <style name="myredtextappearance" parent="@android:style/textappearance&qu

PHP failed to return animated gif directly as image -

i have script generate animated gif. once work fine of sudden after file transfer , git push/pull, script not functioning! the problem weird. the following line used return generated gif. header('content-type:image/gif'); echo $this->image; standard flow image not displayed correctly, code 200 when check header in chrome developer tool. i once thought there problem code, when double check returning normal html this: echo '<img src="data:image/*;base64,'.base64_encode($this->image).'" />'; the image shows correctly. any idea what's possible reason behind?

Concatenating Bootstrap, jQuery and local JavaScript - breaks jQuery -

currently minify , concatenate javascript , css files local 'theme'. load bootstrap, jquery , local javascript/css files in head of website. whilst works, result in 8 separate resource loads, rather 2 (1 js, 1 css) accomplish. (at time not looking asynchronously load multiple libraries). i'm using grunt in build system in order invoke uglify action minifiy javascript. below relevant part of gruntfile.js uglify: { build: { files: [{ src: ['src/main/webapp/js/vendor/*.js', 'src/main/webapp/js/*.js', '!src/main/webapp/js/output.min.js'], dest: 'src/main/webapp/js/output.min.js' }] } } i thought specifying minified jquery , bootstrap libraries uglify action combine libraries minified 'theme' javascript. when doing so, receive following errors in browser: uncaught error: bootstrap's javascript requires jquery uncaught referenceerror: $ not defined uncaught referenceerror:

html - 3 columns same height -

Image
i'm trying set same hight 3 columns. i've been looking around internet , tried several options, of them seems working. here code: html <div class="container"> <div id="firstblockgroup" class="col-md-24"> <div class="columnlayout col-md-8 col-sm-8 col-xs-24"> <img class="imageofcolumn" src="images/leftimg.png" alt=""/> <div class="descriptionpic"> <span class="titlelabelpic">bordeaux 2014</span> <span class="desclabelpic">read our honest review of interesting recent vintage</span> <span class="morelabelpic">if it's lemon, call lemon >>></span> </div> </div> <div class="columnlayout col-md-8 col-sm-8 col-xs-24"> &l

x86 - how is machine-virtualization achieved without hardware support -

this reference machine virtualization. going through virtualization , got know hardware assisted virtualization technique, privileged instructions identified trap-fault method , replaced equivalent user-level instructions on fly. how is/was virtualization achieved in absence of hardware support? prior intel vti or amd-v, how privileged instrutions trapped on fly software itself? everywhere :"binary translation" term used fine far replacing privileged instruction user instructions concerned how privileged instructions ran guest os identified virtualization tool(hypervisor/vmm) edit : people thinking question not show research effort , down-voting. these of papers went through overview : https://www.vmware.com/pdf/virtualization.pdf intel doc: https://software.intel.com/sites/default/files/m/d/4/1/d/8/an_introduction_to_virtualization.pdf intorduction: http://www.kernelthread.com/publications/virtualization/ x86 virtualization http://en.wikipedia.org/wiki/x86_

ios - How can I pass `StatusCallbackEvent` while the number voice is configured with `Application`? -

Image
i have configured number's voice application . twilio apps configuration page don't have option statuscallbackevent . how set statuscallbackevent for other events beside default one? i found alternative . passing parameters <client> twilio evangelist here. you can set status callback url on twiml application opening optional settings pane: hope helps.

php - symfony2 best way to test/get a session attribute -

i test , session attribute in code : if ($session->has("myvar")) { $myvar = session->get("myvar"); /* */ } but, read code of session , : /** * returns attribute. * * @param string $name attribute name * @param mixed $default default value if not found. * * @return mixed * * @api */ public function get($name, $default = null); so, if session attribute not find, return "null". if ($myvar = $session->get("myvar")) { /* */ } or better false, if have "myvar" empty, can't rely on "null" : if ($myvar = $session->get("myvar", false)) { /* */ } according : null vs. false vs. 0 in php i think third best, 1 call $session->get, instead of has , in actual code. i read alternative comparaison ternary operator, http://fabien.potencier.org/article/48/the-php-ternary-operator-fast-or-not , don't use it, because i.m not familiar with, but, if it'

iterator - Figuring out return type of closure -

i'm having troubles figuring out type signature of fn filter function in following example. the node , descendant definition there syntax . it's not meant anything! use std::iter::filter; #[derive(clone)] pub struct node<'a> { s: &'a str, } pub struct descendants<'a>{ iter: node<'a> } impl<'a> iterator descendants<'a> { type item = node<'a>; fn next(&mut self) -> option<node<'a>> { some(node {s: self.iter.s}) } } impl<'a> node<'a> { pub fn descendants(&self) -> descendants<'a> { descendants{ iter: node{s: self.s} } } pub fn filter(&self, criteria: &str) -> filter<descendants<'a>, fn(&'a node<'a>)->bool > { self.descendants() .filter(|node| node.s == "meh") } } fn main() { let doc = node{s: "str"

php - Laravel 5 Customexception -

Image
i'm playing around laravel5 test out custom exception. returns error call member function send() on string and can't figure out why. 1.routes.php 2.app/exceptions/toshikier.php 3.composer.php 4.app/exceptions/hanlder.php if take @ render method annotations. /** * render exception response. * * @param \illuminate\http\request $request * @param \exception $e * @return \illuminate\http\response */ you'll see have return \illuminate\htttp\response. i made own exception too, handle new exception this return response()->view("your.view", [], 403);

c# - visually select datagridview cell -

i trying use datagridview "tag" mesh. have number of objects want set , edit "tags" for. each cell in datagridview has string tag in it, datagridview multi-select, user can select whole lot of tags. it works great setting tags... however, want able edit them. so, when load datagridview, want programatically select cells corresponding existing tags. code quite straight forward: public frmsavequery(string name, string description, string taglist, list<tagtype> alltags) { initializecomponent(); taglist = alltags; cancelled = true; txtqueryname.text = name; txtdescription.text = description; string[] tags = taglist.split(new string[] {"|"}, stringsplitoptions.removeemptyentries); foreach (datagridviewrow row in tagselector.rows) { foreach (datagridviewcell cell in row.cells) { if (tags.contains(cell.value.tostring().toupper()))

android - Intent putExtra is not working -

i writing 1 test application keystring in 1 module writing intent , broadcasting broadcasting part: intent broadcastintent = new intent("android.intent.action.my_action"); broadcastintent.putextra("my_key_code", "*#1234589*#"); context.sendbroadcast(broadcastintent); in receiver want string, getting error my_key_code not defined. receiver part: if (intent != null && intent.getaction().equals("android.intent.action.my_action")) { if (intent.getstringextra("my_key_code") .equals(context.getstring("*#1234589*#"))) can 1 regarding this i guess want enter if condition when value equal *#1234589*# . if case if condition wrong lets try this string xxx = intent.getstringextra("my_key_code"); if (xxx.equals("*#1234589*#")){ }

oracle - Stored procedure created but not returning output -

i have created stored procedure - it's created on server when executing it, procedure completed message, it's not returning output. procedure below create or replace procedure dfadmin.usp_getpicklist_df ( p_ord_type in varchar2, p_picklist_out out sys_refcursor, p_picklist_ord out sys_refcursor ) v_totalopenorder integer; v_astockqty integer; v_bstockqty integer; v_loopcounter integer; v_astock integer; v_bstock integer; v_totalbstockqty integer; begin select count(distinct ord_nbr) v_totalopenorder dfadmin.df_orders ord_status='open' , ord_type='df'; begin if v_totalopenorder>0 v_bstockqty:=round(((v_totalopenorder*60)/100),0); v_astockqty:=v_totalopenorder-v_bstockqty; select count(1) v_astock dfadmin.ro_hist process='astock' , order_type='df'; select count(1) v_bstock dfadmin.ro_hist process='bstock' , order_type='df'; if (v_bs

database - java.sql.SQLNonTransientConnectionException:Keyspace names must be composed of alphanumerics and underscores (parsed: '') -

i'm trying connect cassandra db , verify users login , sign i'm getting error: keyspace names must composed of alphanumerics , underscores (parsed: '') @ org.apache.cassandra.cql.jdbc.utils.parseurl(utils.java:195) @ org.apache.cassandra.cql.jdbc.cassandradriver.connect(cassandradriver.java:85) @ java.sql.drivermanager.getconnection(drivermanager.java:571) @ java.sql.drivermanager.getconnection(drivermanager.java:215) @ com.rest.inndata.services.connectcassandra.createconnection(connectcassandra.java:56) @ com.rest.inndata.services.callgoad.checkuser(callgoad.java:1123) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ com.sun.jersey.spi.container.javamethodinvokerfactory$1.invoke(javamethodi