Posts

Showing posts from August, 2014

javascript - In NodeJs how can I wait until my http get is finished? -

this question has answer here: how return response asynchronous call? 21 answers edit: want explain problem more clearly, purpose make http response before "webot.waitrule()" returns. should http request call webot.waitrule or other way around? below code implements module in program, , problem function returns before http request response. know http requests in node js async, there solution it? pretty new in javascript , nodejs. thanks. webot.waitrule('wait_class', function(info) { var coursename='lol'; var options = { host: 'api.uwaterloo.ca', path: '/v2/courses/cs/486/examschedule.json' }; callback = function(response) { var str = ''; //another chunk of data has been recieved, append `str` response.on('data', function (chunk) { str +=

How to make wordpress blog completely invisible to public [Not Private] -

i want close wordpress blog have public , keep myself. i know can set private shows uggly log-in page , dont want people trying access (using random usernames/pass etc) or think still open members accounts or that. i blog point " server not found " public , when logged in admin able see posts , backend aswell frontend. how can make possible? my suggestion following: function is_login_page() { return in_array( $globals['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ); } function wpse_make_blog_private() { if ( ! is_user_logged_in() && ! is_admin() && ! is_login_page() ) { global $wp_query; $wp_query->set_404(); } } add_action( 'wp', 'wpse_make_blog_private' ); it show 404 on pages still allow login. logged in users see site normal. on request show broken site add following code functions.php. aware instead of code above. function is_login_page() { ret

jquery - How can I overwrite the local JSON file in my steroids js application with Javascript? -

i'm building steroids js app , uses data local json file in www/data folder under "myapp.json" display things thumbnail image, description etc. want overwrite information upon launch of application each time json data server using josnp. need know if it's possible me overwrite local json file each time app launches json data server. if so, how go overwriting file , work across platforms (ios, android, windows)? if understand right, want offline mode online sync. best thing store in localstorage javascript object // json storage localstorage.mylist = json.stringify( list ); // storage json var list = json.parse( localstorage.mylist ); the mozilla foundation have released weak framework handle different kind of online storage (asynchrounous db) : https://github.com/mozilla/localforage you can on each load call refresh function data server , store in local, if app offline, directly run script local database

c# - Parsing values with arguments while using Select -

i have rather simple question, haven't been able solve while now, after googling. have following command execute: var datafragments = bufferline.split(';').select(double.parse).tolist(); however need parsing happen invariantculture. use invariant culture operation, haven't been able figure out how can set appropriate arguments issue. here example data want parse: 1;-0.002;-0.005;0.994;-0.975;2.560;4.024;-2.700;3.299;86.699;1009.599;28.67; you can use overload of double.parse takes iformatprovider , cultureinfo implements: var datafragments = bufferline.split(';').select(s => double.parse(s, cultureinfo.invariantculture)).tolist();

android - Fragment counterpart of getSupportFragmentManager -

is there counterpart of getsupportfragmentmanager fragments? or fragmentactivity? i have this adapter = new mypageradapter(this, this.getsupportfragmentmanager()); that goes here public mypageradapter(topfrag context, fragmentmanager fm) {} fragment has method getfragmentmanager() returns fragmentmanager. do: adapter = new mypageradapter(this, this.getfragmentmanager());

xml - Copy node and alter its content -

i'm kinda stuck on transformation i'd make on xml file. basically i'm trying copy xml change tags begins xml code : <test alt="foo" title="bar"/> what i'd after passing xsl : <test alt="foo"/> or <change alt="foo" title=""/> thing is, got tag lot of attributes, dont want make template match , change every attributes manually. actually i'm doing : <xsl:template match="test"> <change><xsl:apply-templates select="@*|node()"/></change> </xsl:template> <xsl:template match="test/@title"> <xsl:attribute name="title"> <xsl:value-of select=""/> </xsl:attribute> </xsl:template> but doesnt change content of title in output. for such tasks should start identity transformation template <xsl:template match="@* | node()"> <xsl:c

javascript - Moment js split time string -

am using moment js current time. based on time need execute search operation in elastic search database. my database entry way : "message_date": "2014-03-20t09:17:40.482z" moment code current time way : var m = moment(); var testresult = m.tojson(); // outputs : 2014-03-20t09:17:40.482z my problem don't want include seconds filed in database query. want search minute field i.e 2014-03-20t09:17 . can split moment date expected format. know not way that. please me expected time format in moment js way. try: var testresult = m.format('yyyy-mm-dd[t]hh:mm'); if want time in particular timezone: var m = moment().zone("+05:30"); var testresult = m.format('yyyy-mm-dd[t]hh:mm');

angularjs - How to disable clicking on an accordion group heading? -

this cut down version of accordion example here . <accordion> <accordion-group heading="static header"> content straight in template. </accordion-group> </accordion> how possible disable clicking on accordion group heading. tried ng-disabled=true on accordion element , accordion-group element not work. according source there isdisabled property on accordeon group, used in toggle function. should way disable panel. https://github.com/angular-ui/bootstrap/blob/master/src/accordion/accordion.js the toggle function: scope.toggleopen = function() { if ( !scope.isdisabled ) { scope.isopen = !scope.isopen; } }; edit: not part of 0.10 version using, have main version, or make change yourself.

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

i want use tooltipster plugin click element in body show tooltip , want have close button inside tooltip close it. however use jquery click() function handle won't fired. tried solution in post. worked when tooltip triggered hover event. tooltipster plugin not firing jquery function when link in in tooltip clicked the original solution using hover in jsfiddle trigger: 'hover', instead using click show tooltip trigger: 'click', http://jsfiddle.net/bcqyl/7/ it won't fire click event in jquery block. can captured normal javascript function only. checked should code in tooltipster plugin locked , captured "click()" event inside tips when in click trigger mode. i tried other event onchange event of radio button fired when using code in original solution @evan right. tooltip doesn't exist in dom , can't bind/delegate action (even if go way $(document) after domready). if you're after close button inside of too

html - Chrome hide menu items with background img -

i have menu background img in hover. crhome, dont see menu voices when load page. following, if go mouse select voice, appears menu voices img's background, , remains. i dont have problem firefox. that's css code: #header { width: 100%; text-align: left; display: block; height: 60px; margin: auto ; width: 100%; font-size: 130%; z-index: 10px; background-color: white; border-bottom: 1px solid lightgray; } #header .main_menu { height: 100%; margin: 0 auto; text-align: center; width: 700px; padding-top: 7.5px; z-index:100; } #header .main_menu .normal { display: inline-block; width: 100px; font-weight: bolder; border-radius: 20px; padding: 10px 0px; height: 14px; border: 2px solid white; } .main_menu .logo_main_menu{ display: inline-block; width: 140px; font-weight: bolder; border-radius: 10px; padding: 14px 0px; heigh

java - Android how to add transparent gradient to imageview -

i have android app need change of drawables in listview. have custom adapter can change color of drawable white. want add dissolve (photoshop blending option) transparent effect drawable. attached images below explain graphically (i used blue because easier see). original image: original green android icon change color: https://www.dropbox.com/s/7mrs1152hvn2d25/step%201.png final: https://www.dropbox.com/s/rvtp4q30jjxgd4e/final.png

java - Creating a class with a generic enum field. Enum field used to get enum's values -

i need class can give different enum types , in class need obtain values of given enum. this how tried do, have issue defining type of enum field: class myclass{ private class<t> enumtype; //how t? void <t extends enum<t>> setenumtype(class<t> enumtype){ this.enumtype = enumtype; } void dosomething(){ (enum<t> literal : enumtype.getenumconstants()) { // literal.name(); } } } update: can't make class generic ( myclass<t extends enum<t>> ). need other solution. something should work (however suggest pass enum class in constructor): class myclass<t extends enum<t>> { private class<t> enumtype; void setenumtype(class<t> enumtype){ this.enumtype = enumtype; } void dosomething(){ (t literal : enumtype.getenumconstants()) { // literal.name(); } } }

c# - Reading generic type using ReadByte() -

i c# beginner , trying read symbol inside binary file. read binary file @ sole argument using readbyte() in c#.by doing using(var stream = new binaryreader(system.io.file.openread(args[0]))) and after do while (stream.basestream.position < stream.basestream.length) { int symbol = stream.readbyte(); //and stuff } what until here every thing fine. but next step make symbol of generic type "<t>" . algorithm : namespace final { public class <t> t: icomparable <t> { public class node { public t symbol; //this symbol has generic type because symbol may int/long/uint etc. on 32/64 bit archtecture. public node next; public int freq; } public node front; public a(string[] args) //it's constructor { front = null; using(var stream = new binaryreader(system.io.file.openread(args[0]))) {

Lotus email client issue -

Image
i using lotus email client. have .net application send email notification users on operation. email client showing wrong data . lets user xyz in field , in cc field of email. when open email in lotus client , name appear both in , cc field :( . can 1 ? i not aware settings on lotus notes client related problem to , cc fields described in question. most code composes email message incorrectly (from lotus notes/domino's point of view), , client represents mail document described. in lotus notes client, open mail database, open email document properties , inspect 2 fields: sendto (it shown in "to" field when open email document in lotus client) copyto (it shown in "cc" field when open email document in lotus client) check contents of every field (blurred on example pictures not reveal email addresses in public, in case there (should be) correct email addresses). if there correct email addresses , when open email document sh

Simple Javascript doesn't return anything -

i'm trying learn javascript. i've written code should return a, b, c, d , if letter in var letters, should alert message "yes true". when run code doesn't return me anything. can see why? <script type="text/javascript"> var letters = ["a", "b", "c", "d"] var numbers = ["one", "two", "three", "four"] for(x=0; x < letters.length; x++) { document.write(letters); if(a in letters) { document.write("yes true"); } } </script> a variable have not defined, dont confused "a" (string) and letters array. x index in array iterating through. letters[x] specific element index x. so, "a" == letters[x] compare fix code. as side note, can suggest better way of solving problem. you trying solve iterating through whole list , comparing elements. ok, if want learn co

Websockets not working on my network -

websockets applications not working on network. however, websites http://www.websocket.org/echo.html , http://websocketstest.com/ tell me working. when trying application of own, appears handshake goes through successfully, after none of messages across. any ideas reason this? explanation appreciated.

.net - jQuery addClass not adding class? -

i have checked forum not found solution works me. have simple .net page masterpage. trying implement validationgroup customvalidators, clientside validation. the html straight forward (note, on of textboxes validating, test purposes only). <div style="border: 1px solid #000; padding: 30px; margin-top: 100px;"> <asp:textbox id="txt1" runat="server" cssclass="form-control"></asp:textbox> <asp:textbox id="txt2" runat="server" cssclass="form-control"></asp:textbox> <asp:button id="btn1" runat="server" text="test a" cssclass="btn btn-primary" validationgroup="vgroup1" /> </div> <asp:customvalidator id="cvtxt1" runat="server" validationgroup="vgroup1" controltovalidate="txt1" clientvalidationfunction="textvalidate" validateemptytext="true"></asp:c

user interface - Progress Indicators: Their History and Usage -

i undertaking research project progress indicators (i may expand more elements of gui) , looking gather material possible on them in terms of graphic design (not looking coding etc.) , appearance in history , use today. i'm asking in finding examples of progress indicators in past, believe xerox parc first gui assuming first place progress indicator found in context. i'm after in locating written articles them. can think of relevant progress indicators in context, computers, video games, including usage today (i doing survey of current trends , developments of pis). anything helpful, in advance! isaac good old robert bell wrote article on subject. http://chrisharrison.net/projects/progressbars/progbarharrison.pdf i heard somewhere software delays progress bar if user thinks software has installed or loaded quick there issue cannot find explains in further details. something read progress bars shouldn't based on time, should based on quantity

unix - How to detect if a C filestream points to a file or a serial device? -

i'm working on c application evaluates data usb laser scanner, acts serial device. testing purpose, i'm allowing test data read file, because not convenient have scanner connected. i open file/device this: file *fp = fopen(argv[1], "a+b"); and depending on whether want read file or device, pass file path or /dev/cu.usbmodemfd121 (i'm on mac). this works fine long i've initialized laser scanner, i'd rather have application that. in order that, though, must first figure out if i'm reading file or device. how can that, given file * returned fopen ? i've tried use fseek(fp, 1, seek_end) expected fail scanner, since it's stream doesn't have "end", reasons fseek not fail.. you file descriptor using fileno , fstat on it. struct stat populates contains thinks st_mode shows type of fd. guessing non-file device s_ischr true or @ least s_isreg false. if have control on it, don't fopen @ all. use open

imageresizer remote reader plugin only displays the remote image if no query strings are present in URL -

i'm trying resize/crop images stored on 1 of our servers , use them on another, our server. image resizer running on www.aapg.org. remote images stored on assets.aapg.org. not sure why doesn't work. followed process outlined in http://imageresizing.net/plugins/remotereader -- looks ok. tried both signed remote url , human-friendly syntax, , neither worked me. here plugins web.config file i'm using: <add name="mvcroutingshim" /> <add name="diskcache" /> <add name="seamcarving" /> <add name="simplefilters" /> <add name="pdfrenderer" downloadnativedependencies="true" /> <add name="dropshadow" /> <add name="whitespacetrimmer" /> <add name="prettygifs" /> <add name="animatedgifs" /> <add name="webpencoder" /> <add name="webpdecoder" /> <add name="remotereader" /> <ad

Can Aparapi handle string processing with Java 8? -

i'm learning use aparapi java 8 gpu can used speed apps, wonder if aparapi can handle string processing. for instance, if have 10,000 files go through , app needs read in text , go through each line extract , parse float numbers , computation , store result in place hashmap or list or array, cpu running @ near 100% when use multiple threads, , runs hour job done. can app benefit aparapi java 8 allocate computing gpu ? know can [ + - * / ], can aparapi things : string lines[]=text.split("\n"); (int i=0;i<lines.length;i++) { float number=float.parsefloat(lines[i]); number*=2000; } aparapi based on opencl can't because can't deal directly objects on heap. best move string state gpu marshalling objects single area of contiguous heap (ala rootbeer), perform parallel operation on strings. of time hard 'win back' marshall+transfer time. the hsa enabled lambda branch of aparapi (still being worked on!) enable on hsa enabled platform. hs

ruby on rails - AbstractController::DoubleRenderError Error and using redirect_to -

i have update method using save , delete methods having own render calls. below code: update method: def update_book self.delete_book params[:name] = params[:newname] self.save_book end delete method: def delete_book # rescue bookdoesnotexist => exception render status: 404 return end head 200 end save method: def save_book # rescue bookdoesnotexist => exception render status: 404 return end rescue bookalreadyexist => exception render status: 409 return end head 200 end when run input system throws " abstractcontroller::doublerendererror " error along message " render and/or redirect called multiple times in action. please note may call render or redirect, , @ once per action. note neither redirect nor render terminate execution of action, if want exit action after redirecting, need &quot;redirect_to(...) , return " i understand because throwing exception in both delete , save method input pass

java - Creating objects with a for loop -

i need create several contacts populate arraylist. when try create , object of type contact inside loop, keeps returning , object has same reference through of them. therefore, when change first contact, every other contact in array changes. overlooking? string[] split = ret.split(";"); this.clear(); for(int j = 0; j<split.length/6;j++) { contact contact = new contact(); for(int =j*6; i<split.length;i++) { if(i%6==0){contact.setfirst(split[i]);} else if(i%6==1){contact.setlast(split[i]);} else if(i%6==2){contact.setcell(split[i]);} else if(i%6==3){contact.setwork(split[i]);} else if(i%6==4){contact.setemail(split[i]);} } this.add((e) contact); } thanks evrything. this: for(int =j*6; i<split.length;i++) should be: for(int =j*6; i< (j+1)*6;i++) basically looping between j*6 , l

android - How to set Empty View for FragmentActivity? -

i want set empty view / show text in middle of viewpager when there no screens on fragmentactivity. use getcount() mpageradapter , add fragment layout empty string seems overkill. i'd know if there better option. think setemptyview() made cases haven't been able implement it. want show string hint of how add screens viewpager users. how can done? this i'm doing now: @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mpager = (viewpager) findviewbyid(r.id.pager); mpageradapter = new pageradapter(getsupportfragmentmanager()); //... if(mpageradapter.getcount() == 0) { setcontentview(r.layout.fragment_screen_empty); } my current implementation: @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mpager = (viewpager) findviewbyid(r.id.pager); mpageradapter = new pageradapter(getsupportfragmentmanager()); //...

SwiftMailer - Adding PHP elements to the Message Body -

i trying make body of mail [huge concatenation] $body='<table border=1>'.'<tr>'.'<th>description</th>'.'<th>quantity</th>'.'<th>cost</th>'.'</tr>'; for($x=0;$x<=$length-1;$x++) { $body .='<tr>'.'<td>'.$json2[$x]["description"].'</td>'.'<td>'.$json2[$x]["qty"].'</td>'.'<td>'.$json2[$x]["cost"].'</td>'.'</tr>'; } $body.='</table>'; and send using swift mailer $message = swift_message::newinstance('thanks order') ->setfrom(array('abc@gmail.com' => 'sender')) ->setto(array('xzy@gmail.com' => 'receiver name')) ->setbody($body,'html'); the mail received table not seen. for feroz $mailer = swift_mailer::newinstance($transport); $message = sw

php - Print an order from online shopping -

i wrote php shopping cart using mysql db. shopping part done, can't solve last part: have print orders receive website. i use a5 format paper, , thought send orders mail , print it's not scalable solution , introduces problems... know alternative way this? also on server side (in physical shop) have machine microsoft access instance. use print orders receive phone.. possible make access file contains order php on website , import access? i approach creating a5 pdf php (look dompdf although there other alternatives). once have order in pdf format can print or email wish.

excel vba - Assistance with comparing cells with If formula -

i comparing cells in column d , if match paste value of previous cell in column b next cell in column b if not match paste value of subseqent cell in column a cell in column b e.g if(d2=d3,b2,a2+1)" not working after running on 1st sequence of cells in d #valve!" rest of column b i sure problem if(d2=d3,b2,a2+1)" in-particular a2+1 reference not sure how call it (sorry if unclear) thanks sub targetid() dim lrow long dim ws worksheet set ws = sheets("unpivot") columns("b:b").select selection.insert shift:=xltoright, copyorigin:=xlformatfromleftorabove range("b1").formular1c1 = "source" range("b2").formular1c1 = [a2].value ws lrow = ws.range("d" & .rows.count).end(xlup).row .range("b3:b" & lrow) .formula = "=if(d2=d3,b2,a2+1)" .value = .value end end end sub as follow comments, 1 works: with .range("b3:b" &

python - Pin down exact content location in html for web scraping urllib2 Beautiful Soup -

i'm new web scraping, have little exposure html file systems , wanted know if there better more efficient way search required content on html version of web page. currently, want scrape reviews product here: http://www.walmart.com/ip/29701960?wmlspartner=wlpa&adid=22222222227022069601&wl0=&wl1=g&wl2=c&wl3=34297254061&wl4=&wl5=pla&wl6=62272156621&veh=sem for this, have following code: url = http://www.walmart.com/ip/29701960? wmlspartner=wlpa&adid=22222222227022069601&wl0=&wl1=g&wl2=c&wl3=34297254061&wl4=&wl5=pla&wl6=6227215 6621&veh=sem review_url = url #print review_url #------------------------------------------------------------------------- # scrape ratings #------------------------------------------------------------------------- page_no = 1 sum_total_reviews = 0 more = true while (more): #print "xxxx" # open url review data requ

ruby on rails - Using Redis for authentication tokens -

i making mobile app site users, in app, users need able sign in. this, creating remember token authenticate users on sign in. @ first thinking saving each token database , destroying when user signs out. when user signs in, have same token until sign out. saw somethings saying redis best way store tokens. question if time new token created when user signs in , time destroyed when user signs out, redis needed or saving database ok performance wise redis enable fast access token data keeps key value pair in memory. also, in case need expire token after particular span of time redis allow set expiration time along key .thus need not perform explicit computation determine expiry time in order delete it.

android - This is a test order, you will not be charged -

even after app published, when beta testers click purchase product, see message "this test order, not charged" i've removed google groups beta still. should done? cant buy normally image http://i58.tinypic.com/2irkqdg.png was having exact same issue until realized isn't being in beta or not. me migrating iab v2 v3. accounts have added in 'play console > settings > account details > gmail accounts testing access'. had accounts in there long before alpha/beta possible. after removing them + 3 hours or propagate, testing message stopped showing. might documented in v3 in-app billing somewhere didn't see it.

variables - PHP Request URI not passing full querystring -

i'm having simple issue can't seem figure out what's going wrong. in script, i'm capturing current page address using code: $return_link = 'https://'.$_server[http_host].$_server[request_uri]; if echo $return_link , returns correct url: https://sub.mysite.com/schedule?m=02&y=2015 however, when pass $return_link variable script , redirect link, it's dropping second half of query string. i'm getting this: https://sub.mysite.com/schedule?m=02 can't quite figure out why i'm losing &y=2015 portion.

ios - What do the arguments mean betweem the < >? -

this question has answer here: what < > mean / represent in class interface? 4 answers i looking @ code related parse framework. what following mean, paricularly referring parameters in < , > ? @interface appdelegate()<pfloginviewcontrollerdelegate, pfsignupviewcontrollerdelegate> this question moreso related objective-c parse itself, although knowing parse may answer question more effectively. thanks. those protocols appdelegate class conforms to.

ruby on rails 3 - how to find facebook page is restricted page using graph api or FQL? -

is possible detail page restriction using graph api or fql ? https://www.facebook.com/dufoodanddrink i'm using app access token , restclient gem facebook page detail in background. response page is, { "error": { "message": "unsupported request.", "type": "graphmethodexception", "code": 100 } } i not detail why it's fail. how find page restricted ? any suggestion ? thanks in advance that error received means method passed facebook invalid. can test methods @ https://developers.facebook.com/tools/explorer . passing {page-id} or {page-name} facebook api should return page information. here results page posted in question: { "about": "making life @ trinity taste better. ", "can_post": true, "category": "food/beverages", "description": "we put on different foodie events every week our members; tastings, cookery c

java - Passing parameters from one jsp file to an included jsp file? -

i have servlet controller jsp file. pass parameters file when loading it, via request.setattribute() , servlet. however, need include nested jsp main jsp file. nested file have access params sent? if not, how can pass params nested file? yes, nested jsp see request scoped attributes set servlet controller.

read svn revision at compile time with gwt eclipse plugin -

situation i try read svn revision number in gwt project in eclipse ide @ compile time. use gwt eclipse plugin. when i've googled problem find solutions maven. have subclipse installed, maybe helps. problem & tried solution when i'm writting code in c/c++ svn revision that: -d'myver="$(shell svnversion -c .)"' i can not find similar argument gwt compiler. tested same argument gcc, won't work. question is there similar argument gwt compiler? is there way svn revision without maven? maybe there solution subclipse plugin? solution i have work maven or similar, there no way gwt compiler. here article showing how realize maven: svn revision number , timestamp

video html5: Is it possible to display thumbnail from video on a specific time? -

i use have video player on browser <video width="320" height="240" controls> <source src="video.mp4" type="video/mp4"> </video> before clicking play, display image beginning of video, in of video, first several seconds black screen. possible make image @ specific time of video, "0:00:15", without creating thumbnail video? maybe helps: (i have not tested it. might able set "poster" attribute of video src of image object. try it. =) ) <video width="320" height="240" controls id="video"> <source src="video.mp4" type="video/mp4"> </video> $(document).ready(function() { var time = 15; var scale = 1; var video_obj = null; document.getelementbyid('video').addeventlistener('loadedmetadata', function() { this.currenttime = time;

c# - XMLNODE: how can i select this node with attribute in my xml -

i have xml following structure <student> <name fname="oliver"> </name> <name fname="de"> </name> <name fname="johnson"> </name> </student> my code this: //after loading xmldocument called xmlrecord xmlnode row = xmlrecord.selectsinglenode("/student"); student.fname = row.selectsinglenode("name[fname]"); but not returning anything. pls best way select fname='johnson' node? you want fname attribute of first <name> element, should write: student.fname = row.selectsinglenode("name/@fname");

content management system - Admin panel builder -

for years i've built myself admin panel websites. pros: full control on products; cons: time demanding. tried use wordpress hate it; each spared minute annulled if try personalize (for real) something. now, i'm looking solution , build control panel. i'd add pieces instead of customize huge prefixed panel. i'd have empty environment add functional module (example: gallery management, customizable texts, etc.). basically i'm looking adminpanel builder less invasive famous cms. i've tried web overflows post wordpress. may give me advices? you can save time using frameworks. zend php backend , bootstrap 3 html / css example. why not build own panel based on accepts modules ? when finished writing new modules new functionality.

How can I tell if a Perl module is actually used in my program? -

i have been on "cleaning spree" lately @ work, doing lot of touch-up stuff should have been done awhile ago. 1 thing have been doing deleted modules imported files , never used, or used @ 1 point not anymore. have been deleting import , running program's test file. gets really, really tedious. is there programmatic way of doing this? short of me writing program myself it. short answer, can't. longer possibly more useful answer, won't find general purpose tool tell 100% certainty whether module you're purging used. may able build special purpose tool manual search you're doing on codebase. maybe try wrapper around test suite removes use statements , ignores error messages except messages undefined subroutine &__package__::foo , other messages occur when accessing missing features of module. wrapper automatically perform dumb source scan on codebase of module being purged see if missing subroutine foo (or other feature) might defined

uitextfield - Add Text into Alertview textfield iOS -

when alert view shows want have existing text within textfield. code, must add? uialertview* dialog = [[uialertview alloc] initwithtitle:@"title" message:@"message" delegate:self cancelbuttontitle:@"cancel" otherbuttontitles:@"add", nil]; [dialog setalertviewstyle:uialertviewstyleplaintextinput]; // change keyboard type [[dialog textfieldatindex:0] setkeyboardtype:uikeyboardtypedefault]; [dialog show]; uialertview* dialog = [[uialertview alloc] initwithtitle:@"title" message:@"message" delegate:self cancelbuttontitle:@"cancel" otherbuttontitles:@"add", nil]; [dialog setalertviewstyle:uialertviewstyleplaintextinput]; [[dialog textfieldatindex:0] setkeyboardtype:uikeyboardtypedefault]; [[dialog textfieldatindex:0]settext:@"your string here"]; [dialog show];

c# - Exceptions vs Error codes -

right have set of called 'services' - classes, have methods common signature: result type have property t? error, t enum. , have separate enum each method set of values defined specific method. this works rather long final place use these services' methods controllers' actions — these errors returned client, handled javascript. but sometime want compose methods of calls of other services' methods, , place seem have problem. let's have service's method a(), has error of type aerror . , a() method calls internally method b() has error of type berror . first of all, have map possible berror aerror . , possible forget inspect b's error, , presence remain unobserved. of cource know common use exceptions indicate method has failed. right controllers have filter intercepts unhandled exceptions , returns answer single property error value 'internalservererror'. if start use exceptions loose 1 feature consider important: possible set of metho

.net - How can I make this MongoDB query more efficient? -

just simple query looking @ list of objects passed in , finding values match. aobjects list of aobjects. var queries = aobjects .select(g => query.and( query<bobject>.eq(m => m.sourcekey, g.sourcekey), query<bobject>.eq(m => m.sourcetypeid, g.sourcetypeid) ) ) .tolist(); var query = query.or(queries); var result = collection.find(query).tolist(); return result; right when run query large set of aobjects (2500,7500) query takes extremely long time; 1 , 8 minutes respectively. both sourcekey , sourcetypeid indexed bobject's collection. i feel there should better way build query make more efficient, i'm of noob when comes nosql query optimization. thanks. mongodb (like databases) can't use more single index @ time (unless it's or query). means although maintain 2 indexes 1 chosen , used. to build index specific query need compound index of both "sourcekey" ,

php - How can I write a Behat step that will capture a screenshot or HTML page? -

ideally opening screenshot automatically in image viewer. edit : bishop tip on opening apps. still not sure how windows, though. /** * works selenium , other real browsers support screenshots. * * @then /^show me screenshot$/ */ public function show_me_a_screenshot() { $image_data = $this->getsession()->getdriver()->getscreenshot(); $file_and_path = '/tmp/behat_screenshot.jpg'; file_put_contents($file_and_path, $image_data); if (php_os === "darwin" && php_sapi === "cli") { exec('open -a "preview.app" ' . $file_and_path); } } /** * works goutte driver , assume other html-only ones. * * @then /^show me html page$/ */ public function show_me_the_html_page_in_the_browser() { $html_data = $this->getsession()->getdriver()->getcontent(); $file_and_path = '/tmp/behat_page.html'; file_put_contents($file_and_path, $html_data); if (php_os === &qu

shell - "source" in ruby subshells -

i need run shell command ruby application. i'm using system() applies backticks. when running command, need load shell script first sets things try this: system("source my_script.sh && my_command") on mac laptop works intended on ubuntu server get: sh: 1: source: not found i wondering "sh" in there since shell should bash, tried this: system("echo $shell && source my_script.sh && my_command") which gives me: /bin/bash sh: 1: source: not found so, using right shell reason, source not work. why? , can it? update sergio tulentsev pointed out, ruby not use shell set in $shell. this gave me actual shell ruby using: system("ps -p $$ | tail -1 | awk '{print $nf}'") sh => true so, it's using sh. can somehow force use bash? you need try adding ./ in front of file want source, should work if subshell bash (check $shell ). irb(main):003:0> system("source ./tes

Hadoop Data Nodes based on Data Size -

i trying estimate resources based on data size. there thumb rule deciding number of required data nodes based on data size? no not really. in typical hadoop cluster, there 1 datanode per node. sorry short answer thats it! :) keep in mind hadoop prefers deal small number of huge files.

visual c++ - seperate the cuda host code in .cpp file -

main.cpp #include<iostream> #include "cuda.h" using namespace std; void cuda_calculation(); int main() { cuda_calculation(); return 0; } cu.h void call(int , int ,float* , int ); cuda.cpp #include <stdio.h> #include <cuda.h> #include "cu.h" void cuda_calculation() { float *a_h, *a_d; // pointer host & device arrays const int n = 10; // number of elements in arrays size_t size = n * sizeof(float); a_h = (float *)malloc(size); // allocate array on host cudamalloc((void **) &a_d, size); // allocate array on device // initialize host array , copy cuda device (int i=0; i<n; i++) a_h[i] = (float)i; cudamemcpy(a_d, a_h, size, cudamemcpyhosttodevice); // calculation on device: int block_size = 4; int n_blocks = n/block_size + (n%block_size == 0 ? 0:1); void call(n_blocks, block_size,&a_d, n); /*square_array <<< n_blocks, block_size >>> (a_d, n);*/ // ret

user32 - how to press and hold a key C# -

what trying accomplish in console program able press , hold key, using user32.dll. know not sending extended key. dont think sending scancode right either. , think passing right flag hold key.. know have key up. of right need key pushed down. appreciated, of right code below not work using system; using system.collections.generic; using system.linq; using system.runtime.interopservices; using system.text; using system.threading; using system.threading.tasks; namespace pressand_hold { class program { [dllimport("user32.dll")] public static extern void keybd_event(byte bvk, byte bscan, uint dwflags, uint dwextrainfo); const int vk_up = 0x26; //up key const int vk_down = 0x28; //down key const int vk_left = 0x25; const int vk_right = 0x27; const uint keyeventf_keyup = 0x0002; const uint scancode = 0x0008; const int key_0 = 11; internal enum scancodeshort : short { key_9 = 10, key_a = 30, key_b = 48,

android - Passing data from asynctask to activity view -

there many questions related problem none of them solved problem. tried of them. i'm trying change values in layout after getting data network source, i'm getting nullpointerexception everytime. error i'm getting 03-25 18:05:43.071: e/androidruntime(4832): fatal exception: main 03-25 18:05:43.071: e/androidruntime(4832): java.lang.nullpointerexception 03-25 18:05:43.071: e/androidruntime(4832): @ com.wishberg.app.communitypageactivity$sendrequest.onpostexecute(communitypageactivity.java:158) 03-25 18:05:43.071: e/androidruntime(4832): @ com.wishberg.app.communitypageactivity$sendrequest.onpostexecute(communitypageactivity.java:1) 03-25 18:05:43.071: e/androidruntime(4832): @ android.os.asynctask.finish(asynctask.java:631) 03-25 18:05:43.071: e/androidruntime(4832): @ android.os.asynctask.access$600(asynctask.java:177) 03-25 18:05:43.071: e/androidruntime(4832): @ android.os.asynctask$internalhandler.handlemessage(asyn