Posts

Showing posts from June, 2015

fstream - read word to file c++ -

i want user word , put place in file certian word. have problem getline. in new file don't have new line. when add newline string write file, line read 2 times , writeto file times (i think bcoz saw newfile) #include <iostream> #include <fstream> #include <string> using namespace std; int main() { string contain_of_file,bufor,word,empty=" ",new_line="\n"; string conection; string::size_type position; cout<<"give word"; cin>>word; ifstream newfile; ofstream nowy1; nowy1.open("tekstpa.txt", ios::app); newfile.open("plik1.txt"); while(newfile.good()) { getline(newfile, contain_of_file); cout<<contain_of_file; position=contain_of_file.find("zuzia"); if(position!=string::npos) { conection=contain_of_file+empty+word+new_line; nowy1<<conection; } nowy1<<contain_of_file; } nowy1.close(); newfile.close(); cin.get(); return 0

ruby on rails - Handling an exception in an ajax action -

i have ajax action in rails : def ajax_action1 begin item = model1.where(id: params[:id]).first if item #.... else render json: { errors: ['not found'] }, status: 404 end rescue render json: { errors: ['unexpected exception, try again later.'] }, status: 503 end end i wonder, sensible enough have action this? there better way of doing out there? you can use rescue keyword this: def ajax_action1 item = model1.where(id: params[:id]).first if item #.... else render json: { errors: ['not found'] }, status: 404 end rescue render json: { errors: ['unexpected exception, try again later.'] }, status: 503 end method def can serve begin statement: def ajax_action1 ... rescue ... end

jquery - Passing the counter of a for loop to queue()? -

this question has answer here: javascript closure inside loops – simple practical example 31 answers i trying use value of loop counter inside queued function, example: for(var i=0; i<5; i++) $(document.body).queue(function(){alert('i=' + i); $(this).dequeue();}).delay(1000); then get: i=0, i=5, i=5, i=5, i=5 i think because i has changed while delay(1000) .. can right values of i , i.e: i=0, i=1, i=2, i=3, i=4 using closure e.g: for (var = 0; < 5; i++) $(document.body).queue(returnfromqueue(i)).delay(1000); function returnfromqueue(i) { return function () { alert('i=' + i); $(this).dequeue(); } }

html - Get "Text-Only" Text With PHP Strip Tags -

i'm using php simple html dom parser. can use in solutions okay. so, i'm loading file this: $html = file_get_html('http://localhost/seo/testfile.php'); and echo code echo strip_tags($html); so far, good. the problem occours when user enter inline code like <script>alert(1)</script> so want not display present inside <script>, <style>, etc. tags. how do that? cheers! i think php dom , can required html of element , indirectly of whole page. same below. $dom = new domdocument(); libxml_use_internal_errors(true); $dom->loadhtml($content); $data = $dom->getelementsbytagname("tr"); foreach($data $value){ if($value->getattribute('class')== 'notesrow'){ $aa = $value->nodevalue; } }

php - joomla get content in onBeforeCompileHead function -

i'm developing joomla system plugin. need add javascript , css files if [myshortcode] shortcode found in content. how can content in onbeforecompilehead function function onbeforecompilehead() { $document = jfactory::getdocument(); //add scripts if shortcode found ... $document->addstylesheet($cssfile, 'text/css', null, array()); the $content = jresponse::getbody(); not work. thanks try this, for style sheet, $document = jfactory::getdocument(); $document->addstylesheet('http://domain.com/templates/css/style.css'); for javascript file $document = jfactory::getdocument(); $document->addscript('full url'); also can this, $document = jfactory::getdocument(); // add javascript $document->addscriptdeclaration(' window.event("domready", function() { alert("an inline javascript declaration"); }); '); // add styles $style = 'body {'

curl - How to merge result of 2 PHP script outputs -

i getting result first script. want response both php scripts in 1 output. in program developing, querying several remote servers. have search information on different servers , return result in 1 response. <?php // build individual requests above, not execute them $ch_1 = curl_init('http://lifesaver.netai.net/example/pharm.php'); $ch_2 = curl_init('http://192.168.1.2/example/pharm.php'); curl_setopt($ch_1, curlopt_returntransfer, false); curl_setopt($ch_2, curlopt_returntransfer, false); curl_setopt($ch_1, curlopt_post,1); curl_setopt($ch_2, curlopt_post,1); curl_setopt($ch_1, curlopt_postfields, "name=$value"); curl_setopt($ch_2, curlopt_postfields, "name=$value"); // $_post["name"] // build multi-curl handle, adding both $ch $mh = curl_multi_init(); curl_multi_add_handle($mh, $ch_1); curl_multi_add_handle($mh, $ch_2); // execute queries simultaneously, , continue whe

Search on select_tag in rails? -

i have 3 models lcities , lservices , search class lcity < activerecord::base has_many :lservices attr_accessible :lname , :lcode , :lexperience , :lrating , :llocation end and class lservice < activerecord::base belongs_to :lcity attr_accessible :lcode , :lscode , :lcharg , :lname end class search < activerecord::base attr_accessible :city , :services end after submitting in search form want lname lcities model know sql query how apply on rails >select lname lcity llocation.lcity = lname.lservice form_for search <%= form_for (@search) |f| %> <%= f.select(:city, city_for_select, :prompt => 'select city') %> <%=f. select(:service, service_for_select, :prompt => 'select services') %> <% end %> to start with, symbols have downcased: has_many :lservices and belongs_to :lcity second, sql right-to-left... also, makes little no sense. however, satisfy custommer, should (mind plural

javascript - Div height to animate smoothly to its new height after portfolio is sorted -

i in midst of making portfolio template not familiar js, jquery , css transitions. got ( http://pixellytrain.com/sortportfolio/index.html ) , running through different tutorials. make .blue div slide/ease nicely new height of .red div after portfolio sorted (e.g. "all" "cat a"). something how footer of portfolio: http://hogash-demo.com/kallyas_wp/features/portfolio/sortable-layout/ slide in nicely when portfolio become shorter. due portfolio tutorial on queness, have got jquery, mixitup.js , easing.js linked page. i tried randomly doing nothing not sure how going or whether on right track. thank kind-hearted pros in advance!! $('.filter').click(function () { $('.red').slidetoggle('8000', "easeoutbounce", function () { }); }); http://jsfiddle.net/xy2ju/ here working implementation. enjoy! 0) create wraps inside .red. <div class="red"> <div class=&qu

.net - How To Get A Website's Screenshot On A Linux PHP Server? -

i want screenshot of website stored in variable png/jpg file random name. know there's function in windows server there on linux server? moreover, want screenshot, @ cost. there other , simplest way round screenshot of site. please note: file .php should compatible. maybe can like: <img src='/screenshots/script.asp?url=google.com' /> thank you! it not obvious @ all. you need install browser engine on server, run specified url, set it's output kind of virtual monitor , capture screenshot it. read more here . use php, you'll need exec() function (be careful - may present security threat!) , wait until screenshot done.

css3 - CSS or probably a Jquery solution for Menu -

i have menu, responsive, problem has sub-level, please check example here http://jsfiddle.net/6vp3u/409/ .sf-menu ul { position:static !important; display: none !important; } .xpopdrop ul { display: block !important; } in above example, under "item 2" there sub-menu under "item 2.1", doesn't work according media query, want work other sub menus working, please drag fiddle center area see in action.. know has css "ul".. tried lot, couldn't find solution, appreciate if experienced css can spend 5 minutes , me fix this.. regards i add 2 selectors: .xpopdrop ul ul { display: none!important; } .xpopdrop .xpopdrop ul { display: block!important; } it seems worked... fiddle

c++ - Merging vectors -

i wrote function supposed merge 2 vectors in ascending order without duplicates.the function should return resulting vector, when try display nothing happens although display function works other vectors. don't error acts resulting vector it's empty.i trying learn iterators , first time using them maybe have misunderstood concept. here code: vector<int> sort(vector<int> &a, vector<int> &b){ vector <int> sorted; (vector<int>::iterator = a.begin(); != a.end();) { (vector<int>::iterator it2 = b.begin(); it2 != b.end();) { if (*it < *it2){ sorted.push_back( *it); ++it2; } else if (*it >*it2){ sorted.push_back(*it2); ++it; } else if (*it == *it2){ sorted.push_back(*it); ++it; ++it2; } } }

java - Creating a unique date each time between calls -

i writing java program using selenium. need function returns unique date (mm/dd/yyyy) each time called. conditions though that it can never return date returned before is must return date between 01/01/2071 , 12/31/9999 the program run many times program memory lost upon termination. must remember dates has returned before. see next item the easiest way keep incrementing date 1 day each time, needs remember 1 date. unfortunately cannot write last date returned file in system read next time program runs because not have ability. the program reading data excel spreadsheet theoretically store latest date in cell, spreadsheet open , not seem have ability write open file. any thoughts? 1 thing thought doing using base date 1/1/2014 @ 00:00:00 , taking current date, calculating number of minutes between two, , adding number of days 11/31/2070. unfortunately work couple of years because there more minutes between 2 dates there days 1/1/2017 12/31/9999 any appreciated

Add different first view to GridView in Android -

i want have in gridview first item different others. gridview's adapter can either adapter extending cursoradapter or arrayadapter . depending on images path taken - db, or arraylist. for works fine, want have first element different rest. first element, no matter adapter, has empty element button can add elements. image in first element has resource, while images rest of elements form uri. also, there emptyview of gridview set. i've tried adding first element arraylist @ beginning, empty view not shown. also, don't know how work content db. honest haven't got more idea, , cannot find in google. do know way can add first view? i need work on api10 , above. you have 2 options in adapter, can check if position 0 inflate other view. more complex seems better 1 override (assuming using arrayadapter) methods: getitemviewtype(int position) getviewtypecount() you can find nice , friendly example here --- edit --- to show empty view need s

r - qplot call overwrites list elements -

running r script list1<-list() list2<-list() for(i in 1:3){ list1[[i]]<-i } for(i in 1:3){ list2[[i]]<-qplot(i) } i recognize list1 contains elements 1,2,3. list2 contains 3 times element qplot(3). is qplot not compatible looping? how can save plots in list using loop? in ggplot aesthetics stored expressions , evaluated when plot rendered. qplot(i) not generate plot, rather plot definition , using reference variable i . 3 plots same in sense reference i . if type list2[[1]] after second loop has run, cause ggplot object stored in list2[[1]] rendered, using whatever value i set @ moment (which 3 after loop). try this: i <- 4 list2[[1]] now plot rendered equivalent qplot(4) . the workaround depends on trying achieve. basic idea not use external variables in aesthetics. in trivial case, for(i in 1:3){ list2[[i]]<-ggplot(data.frame(x=i), aes(x))+geom_histogram() } will work. because reference external variable i not in

java - Android Alarm Manager isn't working on proper time -

i using alarmmanager scheduling task. problem is, it's not working should do. like, want set time show toast message ]. if set, show after 5,10 or 20 minutes. works fine. but, if set after 1 hour show toast message.sometimes, works , not.maximum times,it failed.it showed message right after hit set button. unable figure out problem.here code intent myintent = new intent(setschedule.this,schedulereceiver.class); larmmanager alarmmanager = (alarmmanager) getsystemservice(alarm_service); alarmmanager.set(alarmmanager.rtc_wakeup, calendar.gettimeinmillis(), pendingintent.getbroadcas(setschedule.this, 1, myintent,pendingintent.flag_update_current)); so, how can solve problem ?

c++ - To check if a graph is connected using BFS and print MST -

i have stored graph nodes 1,2,3,4,... in adjacency list. wrote code breadth first search (bfs). bfs works perfect don't know procedure find out if graph connected or disconnected , print minimum spanning tree of graph if connected? example of graph stored in adjacency list: 1 3 4 2 4 3 1 4 4 2 1 3 and code bfs: int visit[999] = { 0 }; q.enqueue(0); while (!q.isempty()) { y = q.dequeue(); traverse = g[y]; while (traverse->link != 0) { if (visit[traverse->data-1] == 0) { visit[traverse->data-1] = 1; parent = traverse->data; q.enqueue(traverse->data-1); } traverse = traverse->link; } if (visit[traverse->data - 1] == 0) { visit[traverse->data - 1] = 1; parent = traverse->data;

Remove specific xml elements using PowerShell -

i have following xml: <ns1:pricemaintenancerequest xmlns:ns1="http://retalix.com/r10/services" majorversion="2" minorversion="0" fixversion="0"> <ns1:header> <ns1:messageid>1234</ns1:messageid> <ns1:bulk unitofwork="false"/> </ns1:header> <ns1:productprice businessunitid="9200" action="addorupdate"> <ns1:productid>2840000133</ns1:productid> <ns1:price action="addupdate" sequence="1234"> <ns1:unitofmeasurecode>ea</ns1:unitofmeasurecode> <ns1:effectivedatetimestamp>2012-09-20t00:00:00</ns1:effectivedatetimestamp> <ns1:enddatetimestamp>2056-12-12t23:59:00</ns1:enddatetimestamp> <ns1:catalogprice currency="usd">4.2900</ns1:catalogprice> <ns1:batchid>491364c5-73f5-45a4-8355-79cc0a720ea0</ns1:batchid> <ns1:cha

c# - How to implement Save in an in-memory repository -

i have following code foreach (var obj in mylist) { // bl repository.add(obj) // bl repository.update(obj) } i have 2 classes implement irepository. 1 class uses mssql , 1 in-memory. in-memory implementation uses list store data. if use mssql class data stored in db. if use in-memory need insert data repository's list db after foreach loop. i'm not sure best way oop wise. i can add save method irepository means mssql class implement method doesn't need. option add method in in-memory class , this: irepository rep = repository inmemoryrepository if (rep != null) { rep.save() } what think? you should have methods common repository implementations (mssql, in-memory) in base interface. savetodatabase in-memory specific method , should part of inmemory repository implementation class. not make part of base interface since may not have meaning other concrete implementations. the other option implement persist method of in-memory repository

Get python to end the program in an if statement -

i creating game style program , looking command end program @ point. there no syntax errors , correctly indented in idle. i want command execute after 'you died game over' bit of if statment. tried online couldn't find hints. code below buy2a = input ('type y drink strange liquid , type n not to') if buy2a == 'y' or buy2a == 'y': chance2a = 2 #random.randint(1,4) if chance2a == '2' or chance2a == '4' : print ('you start choke , black out') print ('you died') print ('game over') # >thing im looking goes here!<# else : print ('you feel strange') time.sleep(1) print ('you blackout wake several hours later') time.sleep(1) health = 20 print ('you feel lot better , have ' + str(health) + ' health') else : print ('you pass on offer weak reason , head off in hurry') print ('you enter next town on weir

javascript - TypeError: d.textarea1 is undefined , d.textarea1.value = sChoices; -

hi have javascript code when click qualities want on select dropdown list display textarea. got error typeerror: d.textarea1 undefined d.textarea1.value = schoices; is there wrong in code? <!doctype html> <html> <head> <title>list box 4 example</title> <script type="text/javascript"> function tellme(d){ var schoices =""; for(i=0; i<d.listbox.options.length; i++){ if(d.listbox.options[i].selected == true){ schoices += d.listbox.options[i].text +"\n"; } } d.textarea1.value = schoices; } </script> </head> <body bgcolor="lightgreen"> <form name="form1"> <p>girl's quaalities want?</p> <select name="listbox" onchange="tellme(this.form)" multiple> <option>pretty</option> <option>sexy</option> <option>hot</opti

ios - check user App Store wishlist -

is there possibility (using ios sdk 6.x or 7.x) check user app store wishlist within third party app? need list in app, can't find informations checking user app store data. no ,there no api within ios(public or private) can access information. because itunes , app store apps fancy websites native extensions, therefore accessing information require direct access apple's servers. privacy concern many users might not third party apps access wish list.

Matrix-type Django admin for two-dimensional data -

suppose have two-dimensional data model: class a(models.model): name = models.charfield() # ... more metadata class b(models.model): name = models.charfield() # ... more metadata class value(models.model): = models.foreignkey(a) b = models.foreignkey(b) value = models.integerfield() so normalized version of matrix of data: | a1 | a2 | a3 | a4 ----------------------- b1 | 5 | 9 | 2 | 1 b2 | 8 | 3 | 3 | 8 b3 | 4 | 9 | 5 | 7 b4 | 2 | 6 | 2 | 7 is there way present matrix in django admin, such can edited in case many values in matrix need updated simultaneously?

jquery - Sliding a navbar-fixed-bottom left off screen and back -

the "problem behind problem" want navigational bar along bottom of site. want able put button on bar causes bar slide right way off screen. leftover part of bar button slides onto screen again. the site uses bootstrap 3 layout, i'm trying implement "navbar-fixed-bottom" has close button on it. i'd use boostrap grid inside nav bar, can lay out icons way want to. (although close button break grid or sit outside of somehow - needs smaller , way left work) my jquery code sliding coming site: http://www.learningjquery.com/2009/02/slide-elements-in-different-directions/ my jsfiddle: http://jsfiddle.net/8jlxw/4/ the issue i'm having contents of navbar "squish" upwards instead of sliding offscreen. reference site says fix set parent element of sliding element overflow:hidden , example shows working properly. i dutifully wrapped nav in div overflow:hidden , hasn't helped. i'm guessing either i'm doing wrong or there

Why isn't this local variable initialized in Java? -

i learning java , know must initialize local variable when use it. however, found code book , code is: wonder why in case variable volume not initialized? public static double cubevolume(double sidelength) { double volume; if (sidelength>=0) { volume=sidelength*sidelength*sidelength; } else { volume=0; } return volume; } the rule must initialised before used , since on both branches of if statement volume has been initialised before returned (aka used) compiler can guarantee have been initialised before being used. if attempted use volume before if statement again receive compilation error. equally if wasn't initialised on branches (in case both sides of if statement) error. examples the following examples may give incite when problem: ok (but pointless): double volume; //<--declared volume=6; //<--initialised double volumeused=2*volume; ok: boolean useupper=true; //<-- useupper declared , init

javascript - access to appended/prepended elements -

i have form has "phone" field , button of "add phone number". <div class="form-group form-inline phone"> <label class="col-sm-2 control-label">phone</label> <div class="col-sm-10"> <input type="text" class="form-control" id="phonetype1" placeholder="type of phone"> <input type="text" class="form-control" id="number1" placeholder="write here phone number"> </div> </div> <span id="newphone"> add phone number</span> when click button, group of fields shows fill phone number: $("#newphone").on('click',function(){ var numitems = $('.phone').length +1; var newphone= '<div class="form-group form-inline phone">'; newphone+= '<label class="col-sm-2 control-label"></label>&#

audio - Unexpected '}' On Line 135, but all } needed JavaScript GameEngine -

i making javascript game engine called rage engine. after 1.5 hours of working on version 1.0 build 1, had enough features , decided test. ran problem. console saying unexpected token } on line 135 . went line 135 , found console said there unexpected } , removed it. console next told me there unexpected else on line 135. use sublime text 2 idle , made sure of there no brackets unintended. update: i have identified, in part +jason, think problem method rageengine.data.file.requestquota large. have run problem before , think javascript compiler cannot handle functions larger size without breaking down. don't know how fix that. method error appeared in: rageengine.data.file.requestquota = function(type,size,success) { if (rageengine.data.file.check().filesystem) { if(type == 'temp') { window.requestfilesystem = window.requestfilesystem || window.webkitrequestfilesystem; window.requestfilesystem(window.temporary,size,success,functio

Make image with C# (Grid table) -

i have 100 buttons, want print them in paper or output image. don't work c# print , image @ all. now need simple printable output. note: have 2 dimensional array of int private int[,] map = new int[10,10]; and cell contain "x" have value 1. http://p30up.ir/images/1wddsvsm7i4z5idzr6r.gif http://p30up.ir/images/vvz5nnbe79u81p2ap6rp.jpg

php - simple html dom extracting table by its id -

Image
i'm using simple html dom in php extract table depending on id. have done without issues when id doesn't involve characters hyphens(-). suspect due hyphen because used same code id no hyphens , no trouble receiving data. data want extract in tab hidden, effect process? here code <?php include('simple_html_dom.php'); //insert url want extract data $html = file_get_html('http://espnfc.com/team/_/id/359/arsenal?cc=5739'); $i = 0; $dataintable = true; while($dataintable){ if($html->find('div[id=ui-tabs-1] table tbody', 0)->children(0)->children($i)){ for($j=0;$j<3;$j++){ if($html->find('div[id=ui-tabs-1] table tbody', 0)->children(0)->children($i)->children($j)){ $gk[] = $html->find('div[id=ui-tabs-1] table tbody', 0)->children(0)->children($i)->children($j)->plaintext; }else{ $dataintable = false;

Multiplication of a 2D array by a 1D array in java -

i'm having trouble figuring out how multiply columns of 2d array 1d array... item store 0 1 2 3 4 0 25 64 23 45 14 1 12 82 19 34 63 2 54 22 17 32 35 item cost per item 1 $12.00 2 $17.95 3 $95.00 4 $86.50 5 $78.00 i have multiply columns of 2d array symbolize items cost (i.e. column 1 2d array $12.00, column 2 (2d array) $17.95. what i'm having trouble understanding how program multiply columns instead of rows , columns, appreciated. edit: import java.util.*; public class asd { public static void main(string[] args) { double items[][]= new double[3][5]; double cost[]=new double[5]; loadarray(items, cost); system.out.println("total amount of sales each store : "); computecost(items, cost); printarray(items, cost); } public static void loadarray(double items[][], double

php - Can't set url value for $_GET when linking to another page via <a> tag -

i have login page starts session, sets email , session_id value in loggedin database table. when login successful, goes dashboard.php?sesid="session_id" now when on dashboard page, set $userid session id url value. i have link: <a href="?sesid=".$userid."">dashboard</a> but when click on it, url says dashboard.php?sesid= why id not popping up? your link should this: <a href="?sesid='<?php echo $userid; ?>'>dashboard</a>

java - getting ClassCastException when iterating parameter ArrayList received from put -

using restlet, trying receive list of class foo through put method class foo { public string name; public int age; } public class bar extends serverresource { @put public string update(arraylist<foo> foos) { string names = ""; try { (foo foo : foos ) { names += ","+foo.name; } } catch (exception e) { e.printstacktrace(); } return names; } } however when sending json [ { "name":"bar", "age":1 }, { "age":27, "name":"baz" } ] i getting exception @ loop first line java.lang.classcastexception: java.util.linkedhashmap cannot cast foo @ bar.update(bar.java:55) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.ja

Jquery slideshow with fadeOut - without fadeIn -

i have simple jquery slideshow on website uses fadein , fadeout. fadein/out creating flash of background find irritating. i've tried replacing other transitions no luck. my goal have images fade each other seamlessly, without dark images showing flash of background during transition. my jquery: $(function(){ $('.fadein img:gt(0)').hide(); setinterval(function(){ $('.fadein :first-child').fadeout() .next('img').fadein() .end().appendto('.fadein');}, 3000); }); i had similar problem sometime ago. without providing fiddle difficult give example of exact code need. concept is, need begin show next image fade out current image demo http://jsfiddle.net/nyxut/161/ var speed = 2000; run = setinterval("switchslide()", speed); $(document).ready(function () { $('#caption').html($('#slideshow img:first').attr('title')); $('#slideshow img:gt(0)').hide(); $('#previou

Differences between maven archetype commands and maven command mvn package? -

could tells me, differences between command mvn archetype:generate , commands mvn clean package or mvn clean install. thanks lot! maik archetype:generate generates brand new project template clean package clean , package project clean install clean, package project , install local repo. (i.e. ~/.m2/repository ) for more info, see the documentation

This declaration has no storage class or type specifier in C++ -

i have multiple classes in program . a) when create object of class in class getting no error when use object call function above error . b)also if create object of class , call function using in constructor of class no error . c) cout function not work in body of class except when put function d) main class able of these , not getting error . it great hear . thank in advance . following code : these 2 classes in cpp. facing no problems except using object after creating . code huge posted . can done in main not in other classes why ? #include <iostream> #include <fstream> #include <iomanip> #include <string> #include <cstdlib> #include <vector> #include <map> using namespace std; class message { public: void check(string side) { if(side!="b"&&side!="s") { cout<<"side should either buy (b) or sell (s)"<<endl;; } }

web services - Message ID in an E-Mail -

i working on enron email dataset , doing nlp analyses pertaining it. while going through emails along meta-data, confused message id field. in particular, wanted know how message-id affected (changes/remains same) when:- we reply email forward email create new email etc. the email data contains following fields (from sample email):- message-id: <24968359.1075855415739.javamail.evans@thyme> date: wed, 26 dec 2001 07:33:36 -0800 (pst) from: kimberly.watson@enron.com to: steven.harris@enron.com subject: fw: red rock weekly reports mime-version: 1.0 content-type: text/plain; charset=us-ascii content-transfer-encoding: 7bit x-from: watson, kimberly x-to: harris, steven x-cc: x-bcc: x-folder: \steve_harris_jan2002\harris, steven\inbox x-origin: kean-s x-filename: skean (non-privileged).pst //content follows thanks in advance! the message-id header provides "unique" value each , every message. when reply message, not re-use message-i

node.js - Mongoose select array item in array -

i'm having issue trying select array element id without having parent id. using following example, want select section _id of 5 save change it. here looks like: site: { menus: [ { _id: 1 sections:[ { _id: 1 }, { _id: 2 }, { _id: 3 }, { _id: 4 } ] }, { _id: 2 sections:[ { _id: 5 } ] } ] } schemas.site.findone({ _id: req.session.siteid, 'menus.sections._id': req.params.sectionid }).select('menus.$.sections').exec(function(err, site){ if (err) return next(err); var section = site.menus[0].sections.id(req.params.sectionid); // update things section.whatever = something; // save changes site.save(); }); the problem works in first menus array, not in second. if try on second menu section (_id: 5), updates in first menu. i'm sure have close problem selecting. these arrays, not embedded models. update: seems selection working fine. when console.log ou

apache - Periodic action under mod_perl -

how perform periodic actions under mod_perl, apache2? for instance, need reload data remote location, process it, , store in memory. ideally, don't want while request being served. i highly doubt alarm never used across our codebase, setting periodic alarm won't work. external storage (like redis/memcached) can fast still not fast process's own memory. i believe can done using custom signal, pkill , cron. signal handler execution may postponed until cleanup phase if needed. but maybe there's more straightforward way? obvious don't see? if built perl embedded apache threading support, create thread in startup script. if not, it's going complicated make sure every apache process updates itself.

java - How long does the JVM wait for a thread -

hi every java developper, have juste simple question jvm, want know how long jvm wait thread ? example, take @ code : public static void main(string[] args) { p = runtime.getruntime().exec("myshellcommand -p1 v1 -p2 v2"); p.waitfor(); system.out.println("end ....:)"); } suppose "myshellcommand" running ever, whats happen ? jvm still waiting ever ? the waitfor method causes current thread wait, if necessary, until process represented process object has terminated. method returns if subprocess has terminated. if subprocess has not yet terminated, calling thread will blocked until subprocess exits .(from javadoc ). based on documentation, think run forever.

What flavor of SOAP is defined by this WSDL, and how to consume it with PHP? -

we have php application needs connect soap web service—here's wsdl: https://arixss.arifleet.com/qa/driveawayws/driveawaysrvc.svc?wsdl the vendor claims uses "ws-security (wshttpbinding)". doesn't mean me, don't have experience beyond "normal" unauthenticated soap. furthermore, understand there several ways implement ws-security, , vendor hasn't provided full specification. so far, wssoap class given in this answer , have been able connect, authenticate, , run getallrequests method successfully. however, i'm stuck when trying run getrequestdetail method, because don't know kind of parameter argument use. vendor offers snippet of .net code example: driveawayclient client = new driveawayclient(); client.clientcredentials.username.username = "…"; client.clientcredentials.username.password = "…"; arirqst rqst = new arirqst(); rqst.rqsttype = "order"; rqst.orderid = "12345"; string requestdetail;

mysql - INSERT into a table using data from 2 other tables -

okay have 3 tables; enduserdevicemap,enduser, , device. i'm inserting enduserdevicemap need information both enduser table , device table. insert enduserdevicemap (fkenduser,fkdevice,defaultprofile,tkuserassociation) select enduser.pkid,device.pkid enduser,device enduser.userid = 1001, device.name '%6%' values (enduser.pkid,device.pkid,'f','1') i need device.pkid , enduser.pkid keep getting syntax error. know wrong in many ways... first number of attributes insert should matching number of attributes of select. second, don't need last values line third, sure not missing relation between tables: enduser , device, because insert possibilities. example, (it might not make sense choice of attributes example of how use insert table): insert enduserdevicemap (fkenduser,fkdevice,defaultprofile,tkuserassociation) select e.fkenduser,e.fkdevice,d.defaultprofile,d.tkuserassociation enduser e,device d enduser.userid = 1001 , device.n

class - Java - Costum Classes, code not working -

for reason when run file answer seems 0. i'm still new java explain me i've done wrong.. seems fine me. public class bus { public static void main(string[] args) { bus fivepm = new bus(23, 120); bus elevenam = new bus(27, 140); system.out.println(fivepm.gallonsused()); system.out.println(elevenam.gallonsused()); } private int mpg; private int milestravelled; private double used; public bus(int mpg, int milestravelled){ this.mpg = mpg; this.milestravelled = milestravelled; } public double gallonsused(){ this.used = this.mpg/this.milestravelled; return this.used; } } in both of instantiated bus objects, milestravelled less mpg. when divide int int, int. this.mpg/this.milestravelled; this return 0 because digits after decimal point don't matter if it's int. to make them not ints, things like: this.mpg * 1.0 / this.milestravelled or this.mpg/((double) this.milestravelled)

ios - how do i add style to a textfield in AS3? -

when press button display text, how add style? such position , color. import flash.text.textfield; var tf:textfield= new textfield(); convob.addeventlistener(mouseevent.click, fl_mouseclickhandler); function fl_mouseclickhandler(event:mouseevent):void { tf.text="hello world"; addchild(tf); } something this: var format:textformat = new textformat(); format.color = 0x555555; format.size = 18; format.align = textformatalign.center; format.bold = false; tf.settextformat(format); check class reference textformat: http://help.adobe.com/en_gb/flashplatform/reference/actionscript/3/flash/text/textformat.html

sublimetext2 - Sublime code folding of comments (as in Ace) -

in cloud9 (based on ace editor) can define arbitrary code folding regions within comments, example: // descriptor { function() { // code } // } folds to: // descriptor {<->} try here see mean . is there existing way replicate in sublime? from http://wesbos.com/sublime-text-code-folding/ to fold block, place cursor anywhere within block want fold. hit folding keys collapse block. command + option + [ the thing have remember sublime text's folding mechanism dependent on code intention levels , not scope.

What does XXX stand for in facebook graph's mention tagging format @[ID:XXX:NAME]? -

for album description facebook page tagged/mentioned, i'm getting value: "some description text @[page-id:xxx:page-name]" xxx 3 digit number, can't find info on number stands for. everywhere see @[page-id:page-name] format. what's best way parse format. should parser expect @[page-id:page-name] , @[page-id:xxx:page-name] ? for might worth, response i'm seeing when opening graph url through chrome browser some description text \u0040[page-id:xxx:page-name] , \u0040 instead of @.

c++ - Proper use of the cin object? -

i using microsoft visual studio build simple windows console application exhibits simple i/o. when input more 1 word assigned string variable using cin object, program automatically displays of following questions immediately. can allow multiple word inputs? for situations when need string allows spaces, use std::getline in place of >> operator: std::string withspaces; getline(cin, withspaces);

java - trouble with implementing classes -

i have trouble implementing classes car ship , plane. made interface is: public interface movable public void moveforward(); public void moveforward(int x); public void movebackward(); public void movebackward(int x); public void moveleft(); public void moveleft(int y); public void moveright(); public void moveright(int y); public void displaycoordinates(); but want have 2 int fields keep track of coordinates (x, y). • default coordinates (0, 0), , overloaded constructor allow user initialize them other values. • movement of objects change coordinates (x, y) 1 step @ time default depending on direction (i.e. moveforward() add 1 x , moveleft() subtract 1 y ). overloaded methods allow user change coordinates n number of steps @ time (i.e. moveforward( 7 ) add 7 x ). don't know do. can me? an interface defines methods implementing classes need implement. not define variables or maintain values variables. for exampl

python - Extract tuple from list -

i have list: [(hello(21,15),'now')] tuple inside list, , want extract tuple way output (hello(21,15,'now') just do: lst[0] to first element since list indices start @ 0 examples >>> = [1,2,3] >>> a[0] 1 >>> a[2] 3 your case >>> = [(hello(21,15),'now')] >>> a[0] (hello(21,15), 'now') if further want 'now' text do: >>> a[0][1] 'now' extension if want range of values list, can use [:] follows: >>> = [1,2,3,4,5,6,7,8] >>> a[2:6] #this gets elements index 2 5 [3,4,5,6] >>> a[-1] #this gets last element of list 8

How do I Write/Read an Arraylist of Objects to/from a file? -

im doing extra-credit assignment computer science teacher, have improve upon program. and 1 of things wanted do, able write arraylist file, , read arraylist file later on in different instance of program. so, arraylist called "acctarray," , filled objects called "account" take string name, long account number, , double balance. ive tried following other posts involving serialization, confusing , couldnt work. can guys me out? (the methods ill using write , read "savestuff" , "loadstuff" respectively, if help. ;-; ) thanks in advance help. :)

javascript - Passing confirmation to an alert in java script -

i writing function delete records. on deletion there alert message 'yes' , 'no' user needs click delete record. the problem want pass yes confirmation without manually clicking on yes. how can this. please provide pointers. not saying should following, here's how 1 might try bypass confirmation dialogs. replace confirm function own function returns true . var realconfirm = window.confirm; window.confirm = function () { return true; } deleterows(); window.confirm = realconfirm;

python - IPython Cell Magic to Run this Cell in Client and in All Engines -

in ipython parallel execution have multiple engines. jobs dispatched them using: %%px cell magics set environment in clients , using directview map_sync run various experiments. the experiments return named-tuple of results. named-tuple need declared in both client , in each engine. currently each time run it, run twice, 1 %%px , once without. is there flag of %%px make run both locally , in each engine? as of ipython 1.0, can instruct %%px execute cell locally. done using "--local" flag. %%px --local http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/parallel%20computing/parallel%20magics.ipynb

include - Including jquery in .js file -

i trying clone object using var newobject = jquery.extend(true, {}, oldobject); as per john resig's answer what efficient way deep clone object in javascript? . all information can find on using libraries in javascript show how use library within html file... in: <script src="http://code.jquery.com/jquery-2.1.0.min.js"></script> my code in .js file , error jquery not defined. how use jquery within .js file? edit: i'm running code in server.js file on node server. server.js has event handler gives index.html file upon getting "/" url. server.js file isn't included in index.html file , therefore including jquery in html file doesn't me, if understanding correct. you can't include or link within .js file. have include on html page ( <script src="/path/to/jquery"></script> ), before include .js file. technically could copy , paste jquery code above code in .js file, better idea includ

ios - Animate to a storyboard state / position -

i've got view controller in storyboard has bunch of images, labels , buttons correctly positioned how view supposed after initial animations. is there simple way save original position of each , every element (that position they're in on storyboard) on init it's possible take elements, move them out of view , animate them storyboard layout / positions? yes can done saving view's constraints in array, removing them, , replacing them new off-screen constraints (the example have work if want move in self.view -- if want move of views, need loop through of self.view's constraints, , add pertain views want move array). when want move views storyboard defined positions, remove current ones, re-add saved ones, , call layoutifneeded in animation block. @interface viewcontroller () @property (weak, nonatomic) iboutlet uibutton *bottombutton; @property (weak, nonatomic) iboutlet uibutton *topbutton; @property (weak, nonatomic) iboutlet uibutton *middlebutto

c# - how to add an asterix for the LabelFor helper? -

i building mvc 4 app. have field called organisationid, mandatory. @html.labelfor(m => m.organisationid) i need put asterix after label field required. how access labelfor templates? stored? how create own? thanks on model use data annotations [required] [uihint("requiredtemplate")]//this trick should match file name. [display(name="organization id")] public string name { get; set; } drop new folder in views/shared/displaytemplates create new partial view requiredtemplate.cshtml. <font style="color:red">*</font>@html.labelfor(m => m) in view organization should use displayfor <div class="display-field"> @html.displayfor(m => m.name) </div>

sas MACRO ampersand -

%let test = one; %let 1 = two; %put &test; %put &&test; %put &&&test; %put &&&&test; %put &&&&&test; well. i'm totally beaten these ampersands. don't understand why need many ampersands before macro variable. there trick master usage of ampersand? btw, 5 results, correspondingly? with single set of ampersands, pretty boring; after one, odd number of ampersands leads resolving twice, number of ampersands resolves once. use 1 ampersand resolve once , 3 ampersands resolve twice, unless have stock in company owns rights ampersand. more interesting following test, shows why numbers of ampersands have value: %let test = one; %let testtwo = one; %let 1 = two; %let two=three; %put &test&one; %put &&test&one; %put &&&test&one; %put &&&&test&one; %put &&&&&test&one; %put &&&&&&test&one; basically, e