Posts

Showing posts from August, 2014

c++11 - c++ <vector> does not name a type -

so i'm having type problems in c++ program. here code: #include "nhsfileparser.h" #include "nhsfilecontroller.h" #include <string> #include <vector> std::string databasepath = "/media/sf_documents/skola/mvk/testdb/"; std::string dblang = "english"; std::vector<std::string> directories; std::string directory1 = "/media/sf_documents/skola/mvk/testdata/"; std::string directory2 = "/media/sf_documents/skola/mvk/testdata2/"; directories.push_back(directory1); directories.push_back(directory2); std::vector<std::string> queryterms; std::vector<std::string> return_files; int main() { nhsfilecontroller fc(directory1, databasepath); bool b = fc.adddirectory(directory1); nhsdatabase database(databasepath, dblang); split( queryterms, "test", boost::is_any_of("_")); //split on lots of chars std::cout << "queryterms set." << std::endl; database.query(

vbscript - How to I control my computer master volume by batch file -

i have batch code can turn pc volume wont turn down volume here code please possible: @if (@a==@b) @end /* :: batch portion @echo off cscript /e:jscript "%~f0" :: jscript portion */ var shl = new activexobject("wscript.shell"); (var i=0; i<5; i++) { shl.sendkeys(string.fromcharcode(0xaf)); } this code enable turn pc volume how turn down pc volume me these tested , work here - keycodes in microsoft link in comment below. volume control up.bat @if (@a==@b) @end /* :: batch portion @echo off cscript /e:jscript "%~f0" :: jscript portion */ var shl = new activexobject("wscript.shell"); (var i=0; i<5; i++) { shl.sendkeys(string.fromcharcode(0xaf)); } volume control down.bat @if (@a==@b) @end /* :: batch portion @echo off cscript /e:jscript "%~f0" :: jscript portion */ var shl = new activexobject("wscript.shell"); (var i=0; i<5; i++) { shl.sendkeys(string.fromcharcode(

sockets - How to I make UDP and TCP flows simultaneously without multi-thread program -

my program following sender side: while(1){ sendto(); // send data packets usleep(); // delay avoid overflow } receiver side: while(1){ recvfrom(); // receive } i have tcp socket appeared in receiver while loop, send control message (to change time of usleep) receiver side sender side every 2 seconds( or every 100 received packets). in mean while, sender should able listen control message in while loop. can achieved without multi-thread program?

How to search in rails from two models? -

i have 2 models lcities , lservices 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 i want data searching on llocation of lcities , lname of lservice

jquery - Javascript Click function now working -

i trying make new website more interactive have decided lift javascript old website used make body background in css change color when button pressed. have added code new website doesnt work @ all, have no idea why, feel have tried everythink can work correctly, here html <input id="bodycolorgreen" type="button" value="green"> here javascript $(document).ready(function () { $("#bodycolorgreen").click(function () { $("body").css("background-color", "green"); }); }); , css code body is; body { background-color:black; } basically trying when button named "bodycolorgreen" pressed want change page background green. here linking pages in case have lined them wrong. <link rel="stylesheet" href="stylesheet.css" type="text/css"> <script type="text/javascript" src="javascript.js"></script> <script type="text

android - What does this error in my Logcat mean -

i having problem understand error in logcat,can me please how can fixed this. 04-06 08:17:54.738: e/androidruntime(4491): fatal exception: asynctask #1 04-06 08:17:54.738: e/androidruntime(4491): java.lang.runtimeexception: error occured while executing doinbackground() 04-06 08:17:54.738: e/androidruntime(4491): @ android.os.asynctask$3.done(asynctask.java:299) 04-06 08:17:54.738: e/androidruntime(4491): @ java.util.concurrent.futuretask.finishcompletion(futuretask.java:352) 04-06 08:17:54.738: e/androidruntime(4491): @ java.util.concurrent.futuretask.setexception(futuretask.java:219) 04-06 08:17:54.738: e/androidruntime(4491): @ java.util.concurrent.futuretask.run(futuretask.java:239) 04-06 08:17:54.738: e/androidruntime(4491): @ android.os.asynctask$serialexecutor$1.run(asynctask.java:230) 04-06 08:17:54.738: e/androidruntime(4491): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1080) 04-06 08:17:54.738: e/androidr

java - stop and restart flashing colors in processing -

i have following code flashes colors red , white. want make change i'm not sure how do. flashing 2 colors stopped 3 seconds , begins again. float delay = 1; // 1 frame void setup() { size(200, 200); } void draw() { background(96); fill(255); if(framecount%(2*delay)<delay) fill(255, 0, 0); rect(20, 20, 100, 100); } method 1 as guy hat suggested, draw rectangle when framecount%360 < 180 method 2 use timer: float delay = 1; // 1 frame long n; void setup() { size(200, 200); n = millis(); } void draw() { background(96); fill(255); if (framecount%(2*delay)<delay) { fill(255, 0, 0); } if (millis() - n < 3000) // if 3 seconds haven't yet passed, show rectangle { rect(20, 20, 100, 100); } else if (millis() - n > 6000) // if 6 seconds have passed, reset timer { n = millis(); } }

javascript - calling js function from jsrender template code -

i'm using jsrender javascript template in view. have issue date since i'm getting data json. mytime property displayed this /date(1395927615038)/ so i've tried js function converts date this <script type="text/javascript"> function convertdate(jsondate) { var = jsondate.match(/\d+/); var fdate = parseint(a); var date = new date(fdate); return date; }; </script> i'm calling function template on same page this <li>time: {{:convertdate(time)}} </li> error occured when calling function error: data.convertdate not function. p.s. if it's matters @ all, function convertdate loaded before template code.

Integrate Doxygen API documentation with Codeplex website -

we use doxygen generate api documentation, works well. cannot host files on codeplex, because when using svn url of html files file code shown not parsed html. here's simple test: https://mapwingis.svn.codeplex.com/svn/mapwingis/trunk/doxygen/index.html how can share our doxygen documentation our users through codeplex site? i know alternative host doxygen files on separate hosting provider. have data on 1 place.

Polymaps and Angularjs -

i'm trying add polymaps map inside angularjs app. typeerror: object [object object] has no method 'setattribute' @ object.a.container (http://localhost:8000/lib/polymaps.min.js:15:341) @ new <anonymous> (http://localhost:8000/js/controllers.js:22:4) @ d (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:335) @ object.instantiate (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:33:464) @ http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:65:486 @ link (http://localhost:8000/lib/angular-route.min.js:7:248) @ j (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:52:492) @ h (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:46:28) @ http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:45:200 @ http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js:46:431 <div ng-view="" class="ng-scope"> javascript not able seta

decision tree - Unable to install C50 package in r language -

i installing c5.0 package "c50" in r-language , following error: installing package(s) ‘c:\users\rxn\documents/r/win-library/2.12’ (as ‘lib’ unspecified) --- please select cran mirror use in session --- warning message: in getdependencies(pkgs, dependencies, available, lib) : package ‘c50’ not available i have tried on multiple machines , on both xp , windows 7.

android - make a single button width to fill parent programmatically -

how make single button width fill parent programmatically? have done cannot seem work still located on top left width wrapping content... here of code on button creation... public class test_gifdisplay extends activity implements view.onclicklistener { surfaceview sview; gifrun gr = new gifrun(); button btnback; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); sview = new surfaceview(this); sview.setzorderontop(true); gr.loadgiff(sview, this, r.drawable.smiley); linearlayout linearlayout1 = new linearlayout(this); linearlayout1.setorientation(linearlayout.vertical); linearlayout1.setbackgroundcolor(color.parsecolor("#27ae60")); linearlayout1.setlayoutparams(new viewgroup.layoutparams( viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content)); linearlayout linearlayout2 = new linearlayout(thi

html - Why I can't move an image by JQuery? -

i have tryed move image whi jquery, when press key on keyboard, doesn't work. problem? here's code: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script> $(document).ready(function(){ $(document).keydown(function(){ $(document).find("img").animate({ top:"+=100px", }); }); }); </script> </head> <body> <img src="player.jpg"> </body> </html> thanks lot! this thing should change: <img style="position: relative" src="player.jpg">

r - Identify every submatrix satisfying condition -

Image
in following matrix i'm trying identify every largest rectangles formed 1's shown in picture. rectangles can have 1 row if have more 3 columns. rectangles can have 1 column if have more 3 rows. rectangles should have less maxcol columns , maxrow rows , more mincol , minrow . in picture mincol=minrow=2. maxrow=maxcolumn=6 tried use subset function provides 1's submatrixs not every superimposed rectangles. mdat <- matrix(c(0,1,1,1,0,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0), nrow = 4, ncol = 6, byrow = true) dimnames(mdat) <- list( c("row1", "row2", "row3","row4"), c("col1", "col2", "col3", "col4","col5","col6"))

string - Format a date for PHP -

this question has answer here: convert 1 date format in php 12 answers i have date: mon, 31 mar 2014 12:19:10 gmt how can convert format: date('y-m-d h:i:s') i have found this: $time = strtotime('10/16/2003'); $newformat = date('y-m-d',$time); but how convert 'mar' '03', can use that? how using datetime $date = new datetime("mon, 31 mar 2014 12:19:10 gmt"); echo $date->format("y-m-d h:i:s");

javascript - CoffeeScript Object Property Pointing to the Same Object -

i have class use 2 separate objects. class has property myvar , object itself. should different each object. however, in instantiated objects myvar properties point same object, see code below. how can have unique/private myvar property each object? class test myvar: {} obj = new test obj2 = new test obj.myvar['key'] = 'value' console.log obj.myvar # result: { key: 'value' } / correct console.log obj2.myvar # result: { key: 'value' } / incorrect! expected {}! compiled javascript: // generated coffeescript 1.6.3 (function() { var test, obj, obj2; test = (function() { function test() {} test.prototype.myvar = {}; return test; })(); obj = new test; obj2 = new test; obj.myvar['key'] = 'value'; console.log(obj.myvar); console.log(obj2.myvar); }).call(this); update. have found possible "solution": put properties objects constructor, see below. there better solution? class test

How to parse an attributed XML in Android -

friend, i'm totally exhausted looking parse remote xml file have attribute values, have used dom method parse, here xml structure <horoscopo fecha="2014-04-06 00:00:00.000"> <zodiaco signo="aries"> <prediccion tipo="texto"> tienes la sensación de que alguien intenta traicionarte. no te dejes sorprender y enfréntate el primero este tipo de situaciones </prediccion> <prediccion tipo="amor">3</prediccion> <prediccion tipo="salud">3</prediccion> <prediccion tipo="trabajo">1</prediccion> <prediccion tipo="dinero">2</prediccion> <prediccion tipo="numero_suerte">10</prediccion> <prediccion tipo="pclave"/> </zodiaco> <zodiaco signo="tauro"> <prediccion tipo="texto"> en el día de hoy te verás sorprendido por la reacción de alguien de tu entorno. no te esperabas tal reacc

Java if statement: How to find if value is not equal null? -

i trying allow user key in 2 inputs , check user have key in both value or not come out error. here example code public static void add train{ int a,b; system.out.println("enter train id"); system.out.println("(**example '1001'**)"); b=sc.nextint(); system.out.println("1. night safari"); system.out.println("2. river safari"); system.out.println("3. zoo main entrance "); system.out.println("enter destination train"); a= sc.nextint(); } this previous code getting input user, , need book train ticket public static void book(){ system.out.println("where want go?"); system.out.println("1. night safari"); system.out.println("2. river safari"); system.out.println("3. zoo main entrance "); a=sc.nextint(); if (a==1 && b !=null){//incomparable types: int , <nulltype> system.out.println("valid"); } else if (a==2 && b !=n

mysql - self join query to get result in one table -

i have table below. +------+----------+--------+ | id |sender_id |receiver_id| +------+----------+--------+ | 1 | 1 | 4 | | 2 | 1 | 34 | | 3 | 4 | 1 | | 4 | 11 | 8 | | 5 | 24 | 4 | | 6 | 11 | 5 | +------+----------+--------+ i want to see result bellow. +------+----------+--------+ |user_id|sent |receive | +------+----------+--------+ | 1 | 2 | 1 | | 4 | 1 | 2 | | 5 | 0 | 1 | | 8 | 0 | 1 | | 11 | 2 | 0 | | 24 | 1 | 0 | | 34 | 0 | 1 | +------+----------+--------+ i want show result in 1 table, column user_id(all unique sender_id & receiver_id) user_id, sent (count(sender_id) sent, count(receiver_id)) receive. can result in 1 table every user sent & receive message number. trying self join query don't expected result. i use query: select user_id, sum(sent), sum

d3.js - why does one chart not filter another in dc.js? -

i not able understand how dc groups chart. change in 1 filter reflects in others. have simple code 2 series charts. when draw brush on one, not filter other. not sure why ? can please have quick @ small code , suggest. d3.csv("data/comparedata.txt", function(data) { ndx = crossfilter(data); rundimension = ndx.dimension(function(d) {return [+d3.time.format.iso.parse(d.timestamp), +d.meterid]; }); frequencygroup = rundimension.group().reducesum(function(d) { return +d.frequency; }); magnitudegroup = rundimension.group().reducesum(function(d) { return +d.magnitude; }); frequencychart .width(768) .height(480) .chart(function(c) { return dc.linechart(c).interpolate('basis'); }) .x(d3.time.scale().domain([1366621166000, 1366621179983])) .y(d3.scale.linear().domain([90, 100])) .brushon(true) .yaxislabel("measured speed km/s") .xaxislabel("run") .elasticy(true) .dimension(rundimension) .group(f

android - Reading data selected in TimePicker called from a Fragment -

i have fragment has own layout , has choose time button along textview beneath it. opening timepickerfragment fragment when user clicks button. when user selects time, , clicks done, want populate textview contained in fragment. not sure how this. all materials/tutorials online invoke timepicker activity. (obviously) have parent activity, since timepicker being used in fragment, limit scope as possible. flow follows: parentactivity > fragment (contains textview , button) > dialogfragment (timepicker) here implementation: public class timepickerfragment extends dialogfragment implements timepickerdialog.ontimesetlistener { @override public dialog oncreatedialog(bundle savedinstancestate) { int hour = 0; int minute = 0; boolean is24hour = false; // ... code read shared preference, correct time format, theme, etc. return new timepickerdialog(getactivity(), dialog_theme, this, hour, minute, is24hour); //datef

php - Load jQuery into <body> -

my structure following: <html> <head> </head> <body> <?php include('form.php')?> <script src='jquery.js'> </body> </html> my php include not executes jquery functions... i put jquery functions in form.php a: $(document).ready(function() { $('.newbooking').click(function() { alert($(this).attr("data-date")); }); }); but nothing... is normal ? try with: <script src='jquery.js'> <?php include('form.php')?> your code doesn't work because try use jquery before loaded. use $(document).ready call jquery function. use it...

set json data from ajax and make it serarchable in select2 jQuery -

i had 2 drop down input fields, both implementing select2 jquery. here set data static first drop down . works fine . per selection of value in first drop down, next drop down filled set of json data ajax. need second drop down should searchable once loaded ajax data. not correctly. not able make workable. i used following scripts function format(item) { return item.name; } var data=[{"id":"1995","name":"banahatti"},{"id":"5074","name":"kolhapur(maharashtra)"},{"id":"2356","name":"sangola"},{"id":"906","name":"shahada"}]; $("#txtsource").select2({ data:function() { return { text:'name', results: data }; }, formatselection: format, formatresult: format }); for second drop down loaded following var theid,desdata;

ruby on rails - Session variable not accessible across controllers -

i ror beginner , trying implement basic google-openid (using omniauth-openid) authentication in ror app. here code snippets: sessions_controller.rb : class sessionscontroller < applicationcontroller def create user = user.from_omniauth(env["omniauth.auth"]) session[:user_id] = user.id session[:my] = 'some' puts "session[:user_id] = ", session[:user_id] puts "session[:my] = ", session[:my] redirect_to root_url end end routes: photobucket::application.routes.draw "welcome/index" match 'auth/:provider/callback', to: 'sessions#create', via: [:get, :post] match 'auth/failure', to: redirect('/'), via: [:get, :post] match 'signout', to: 'sessions#destroy', as: 'signout', via: [:get, :post] application controller: class applicationcontroller < actioncontroller::base # prevent csrf attacks raising exception. # apis, may want use :n

javascript - How do you account for time-zone offset when retriving an "All Day" event from Google Calendar API? -

i have ajax call retrieve information public google calendar: $.ajax({ url: "https://www.google.com/calendar/feeds/{calid}/public/full?start-min={starttime}&start-max={endtime}&alt=json-in-script&callback=?"; datatype: 'json', timeout: 3000, success: function( data ) { processdata(data);}, }); within function processdata(data) have following statement: starttime = new date(data.feed.entry[i].gd$when[j].starttime); which stores in starttime date() object date particular event starts. google uses iso 8601 time format: yyyy-mm-ddthh:mmtzd (eg 1997-07-16t19:20+01:00) , works fine. however, "all day" events format in form: yyyy-mm-dd (eg 1997-07-16) (which allowed w3 http://www.w3.org/tr/note-datetime ) , in case new date() interpret gmt. is, correct particular date local time zone if event created in local time-zone. in particular case, when retrieving "all day" event on, say, april 7th 2014 happening

javascript - How to use req.responseText, in Ajax to return only the content inside a div of a page -

i using xmlhttp request in ajax, have problem. want use document.getelementbyid('partid').innerhtml=request.responsetext in way return content inside div called 'cars' of page export.php. when use above return content of page export.php. there way make line of code return content inside div? trying use like: document.getelementbyid('partid').innerhtml=request.responsetext.getelementbyid('cars'). , not function. please,help me. have spend hours searching have not find this..please help.thanks in advance when responsetext comes back, -- name suggests -- text. before can access html, have turn html. this typed off cuff, like: var tempdiv = document.createelement("div"); tmpdiv.innerhtml = request.responsetext; var wanteddiv = tmpdiv.queryselector('[id="cars"]'); // might want empty out 'partid' first document.getelementbyid('partid').appendchild(wanteddiv);

swing - Java JButton not updating -

i have jbutton when call settext(), text not update. hover on button, updates. how can fix when call settext(), button updates? post methods edt takes it. goes in order :) public void mouseclicked(mouseevent e) {//this differn't event. not executed clicking on same button. it's differn't one. click(new point(e.getx() + gridscrollpaneviewport.getviewposition().x, e.gety() + gridscrollpaneviewport.getviewposition().y)); } public void click(point point) { map.selectplot((plotgui) map.getcomponentat(point)); } public void selectplot(plotgui plot) { chickentycoon.getinstance().getscreen().getplayingscreen().sidebar .setplot(plot); selectedplot = plot; } public void setplot(plotgui plot) { title.settext(plot.getname() + plot.getx() + plot.gety()); (component comp : stuffpanel.getcomponents()) { stuffpanel.remove(comp); } (component comp : plot.ge

c# - "Invalid operator for data type. Operator equals minus, type equals varchar." -

im trying make code checks table existing records same name receiving error "invalid operator data type. operator equals minus, type equals varchar." understand error dont understand why cant convert int. this code, make work appreciated! using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data.sqlclient; using system.configuration; public partial class register : system.web.ui.page { protected void page_load(object sender, eventargs e) { if (ispostback) { sqlconnection studconn = new sqlconnection(configurationmanager.connectionstrings["studconnectionstring"].connectionstring); studconn.open(); string checkuser = "select count(*) studtable where-'" + textboxname.text + "'"; sqlcommand studcom = new sqlcommand(checkuser, studconn); int temp = conv

scripting - vlc lua subtitle "reader" -

i want write extension vlc in lua. have never worked in lua, , can't find information problem. there function current subtitle line directly (which on screen) ? another problem: time of unit stored in variable? local elapsed_time = vlc.var.get(input, "time") i couldn't find except 2 year old post might relevant: https://forum.videolan.org/viewtopic.php?f=29&t=102482 . about get function, according http://www.videolan.org/developers/vlc/share/lua/readme.txt gets time property of input object. think same input.time maybe not.

python - How should I go about subsampling from a scipy.sparse.csr.csr_matrix and a list -

i have scipy.sparse.csr.csr_matrix represents words in document , list of lists each index represents categories each index in matrix. the problem having need randomly select n amount of rows data. so if matrix looks this [1:3 2:3 4:4] [1:5 2:5 5:4] and list of lists looked this ((20,40) (80,50)) and needed sample 1 value end this [1:3 2:3 4:4] ((20,40)) i have searched scipy documentation cannot find way generate new csr matrix using list of indexes. you can index csr matrix using list of indices. first create matrix, , @ it: >>> m = csr_matrix([[0,0,1,0], [4,3,0,0], [3,0,0,8]]) <3x4 sparse matrix of type '<type 'numpy.int64'>' 5 stored elements in compressed sparse row format> >>> print m.toarray() [[0 0 1 0] [4 3 0 0] [3 0 0 8]] of course, can first row: >>> m[0] <1x4 sparse matrix of type '<type 'numpy.int64'>' 1 stored elements in compressed sparse row

linux - socket programming with getaddrinfo -

i'm using getaddrinfo in socket programming in linux. have created client , server. client has hardcoded static port number. works fine. but want system dynamically assign port number client whenever connects server. how do using getaddrinfo? i'm using tcp socket. just don't call bind before calling connect , tcp stack assign client "random" source port. if need know port you're connecting (and don't), can call getsockaddr after calling connect . alternatively, can call bind specifying port 0. in case, again, stack assign client "random" unused source port connect from. option preferred if don't want special case allowing implementation select port or if need specify local ip address reason.

Haskell Trees Mapping -

i've been trying write simple mapping function using haskell, , came following problem: data tree = leaf | node (tree a) (tree a) deriving(show) let g (leaf l) = leaf(l+1) let map g (leaf l) = g(l) let lf = (leaf 2) for g(lf) output leaf 3 excepted, map g lf i'm getting following error : couldn't match type `integer' `tree a0' expected type: tree (tree a0) actual type: tree integer in second argument of `map', namely `lf' in expression: map g lf in equation `it': = map g lf i don't know why error , i'd grateful if point me solution. this type system showing logic of program doesn't work out. can track details adding lot of type information in hand see if our intuition matches details of checker. data tree = leaf | node (tree a) (tree a) deriving (show) g :: num => tree -> tree g (leaf l) = leaf (l + 1) map :: (a -> b) -> tree -> b map g (leaf l) = g(l) lf :: num => tree lf = (leaf 2) now

Angularjs removes header on http delete request -

i'm trying make http request method delete server , server responds 411, length required. when try set in request seems angular removes it. code have: var delete = function (url) { return $http.delete(url,{ method: 'delete', url: url, headers: { 'content-length': 0 } }); }; this see when @ actual request made: user-agent: mozilla/5.0 (macintosh; intel mac os x 10.9; rv:31.0) gecko/20100101 firefox/31.0 referer: http://localhost:8877/ host: localhost:8877 connection: keep-alive accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate accept: application/json, text/plain, */* no content-length. why remove , how can fix it? try add body request though empty 1 data: ''

c# - Thread.Sleep - how to use it in a proper way? -

system.threading.thread.sleep(1000); pauses whole program 1 second, when second on done period. example: thread.sleep(1000); console.writeline("a"); thread.sleep(1000); console.writeline("b"); it wait 2 seconds , write a b how use pause properly? thread.sleep() behaves think; pauses current thread approximately given number of milliseconds. the problem here standard output stream not flush console (or wherever pointed at) on each call write. instead, may buffer content write out in larger chunks efficiency. try calling console.out.flush() ; after each writeline() , should see results expect.

indexing - Create a search engine on specific sites and gather specific info -

i need create search engine crawls thru list of websites , searches there query, , website return data in various formats , structures, need collect specific info (in unique structure) these websites. is there way can existing engine such google custom search engine? or better of creating own? if yes, what's first step should take towards learning indexing , searching these website efficiently , without filling servers unuseful trash. so sum up, besides searching query on each of these websites' search box, need handle results of each of them appropriately , lay on in union structure in 1 place altogether. results parsed , extracted 4-6 fields (unless, of course, there way google cse. google cse provides interfaces standard google web search. can control user interface , search parameters, have no control on indexing, nor direct access index data. you might more interested in google search api's available gae. these quite different: search services in

Convert odd Stata string variable to date -

i have economic data in format yyyy.qx q indicates "quarter" followed x, in [1,4]. interpreted string. i've tried use date(series, "ymd") , formatting command, encode function. ideally, i'd end numerical variable indicating like: yyyy.x yyyy.m, "m" first month of quarter yyyymm01, "mm" first month of quarter. it's best show code tried , stata did or said in response. such dates quarterly dates treating them else @ best indirect , @ worst quite wrong. . set obs 1 obs 0, 1 . gen example = "2013.q4" . gen qdate = yq(real(substr(example, 1,4)),real(substr(example, -1,1))) . list +-----------------+ | example qdate | |-----------------| 1. | 2013.q4 215 | +-----------------+ . format qdate %tq . list +------------------+ | example qdate | |------------------| 1. | 2013.q4 2013q4 | +------------------+ note code indicating date daily date can wrong.

ios - Trouble getting device token into global variable -

i trying device token , put device token global variable (or access view). code in appdelgate follows: - (void)application:(uiapplication*)application didregisterforremotenotificationswithdevicetoken:(nsmutabledata*)devicetoken { dataclass *obj=[dataclass getinstance]; obj.userdevice = devicetoken; nslog(@"%@",obj.userdevice); } this displays token. when try access through global variable in view, displays "null". code follows: dataclass *obj=[dataclass getinstance]; nslog(@"%@",obj.userdevice); any ideas? or solution? want access token view i'm open other suggestions. edit: dataclass static dataclass *instance =nil; +(dataclass *)getinstance { @synchronized(self) { if(instance==nil) { instance= [dataclass new]; } } return instance; } i've found answer . involves saving token user defaults.

operating system - What does fflush(stdin) do in C programing? -

this question has answer here: using fflush(stdin) 3 answers i new in c programing , trying understand how fflush(stdin) works. in following example fflush(stdin) clears buffer or clears ever entered after third item? mean user enters account number , space, name , space , balance .is true point on, ever user enters flushed fflush(stdin) ? , stdin won't empty. why because enters while loop , start writing text file. my second question whether crtl-z tell os stop asking user entering input? printf( "enter account name , balance. (separated spaces)\n" ); printf( "enter eof end input. (crtl-z)\n" ); printf( "? " ); scanf( "%d%s%lf", &account, name, &balance ); fflush(stdin); // write account, name , balance file fprintf while ( !feof( stdin ) ) { //fflush(stdin); fprintf( cfptr,

java - org.hibernate.PersistentObjectException: detached entity passed to persist: com.horariolivre.entity.Key -

in spring application, trying persist in database follow entity: @entity @table(name = "usuario") public class usuario implements java.io.serializable { private static final long serialversionuid = -7283129128268761582l; private int id; private string login; private string senha; private string primeironome; private string ultimonome; private tipo tipo; private list<atributo> atributo; private confighorariolivre config; private list<autorizacao> autorizacao; public usuario() { } public usuario(string login, string senha) { this.setlogin(login); this.setsenha(senha); } public usuario(string login, string senha, string primeironome, string ultimonome, tipo tipo, list<atributo> atributos) { this.setlogin(login); this.setsenha(senha); this.setprimeironome(primeironome); this.setultimonome(ultimonome); this.tipo = tipo; this.atrib