Posts

Showing posts from September, 2012

java - Logging IP addresses for jsf page requests -

i have running jsf2 application , want add request logging feature. logging saved db , consist of standard user/page/ip trio other generated content. now calling dao method in @postconstruct annotated methods in managed beans seems code duplicate. @postconstruct public void init() { loggingdao.save(user,page,ip); } how can centralize logging/auditing process on jsf side using managed beans? since crosscutting scenario, not want add code every managed bean. edit question got lots of comments implies not asked in correct way. one last chance: need log/watch user interaction on site, either may login action or button clicked list items (which maps backing bean methods) or page navigation/redirect. i assume can use same architecture decide if user has rights specific action on site, story since outcomes different. you either use servlet filter or jsf phase listener that. use filter if want log every request, including css , javascript resources. if interest

iphone - how to set text of titleForHeaderInSection to AlignmentCenter -

i used follow code set title @ group tableview title header,but default text alignmentleft,how alignmentcenter? - (nsstring *)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section { if(section==0){ return nslocalizedstring(@"more_titlehead_one", nil); }else if (section==1){ return nslocalizedstring(@"more_titlehead_two", nil); }else{ return nslocalizedstring(@"more_titlehead_three", nil); } } try this, - (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section { uilabel * sectionheader = [[[uilabel alloc] initwithframe:cgrectzero] autorelease]; sectionheader.backgroundcolor = [uicolor clearcolor]; sectionheader.textalignment = uitextalignmentcenter; sectionheader.font = [uifont boldsystemfontofsize:10]; sectionheader.textcolor = [uicolor whitecolor]; switch(section) { case 0:sectionheader.text = @"

javascript - Tooltip image on cell hover, Google Spreadsheet -

i'm working on google spreadsheet has include bunch of image references. what want achieve this: when hover on cell image appear (like tooltip). i found this widget on google developers, when add code spreadsheet nothing happens. does of guys know how this? hints on how go highly appreciated! what wanting not possible in google spreadsheet, widgets available in uiapp or html service. what should doable recreate spreadsheet display in ui , there use kind of popup mouseover handler show images want. depending of use case - on spreadsheet specific features want have when looking @ data - or bad solution can answer last point.

iphone - Programatically created UITextField hides other controls -

Image
i've requirement create dynamically controllers. in image provided here i've programmatically added uitextfield (name), hides uitableview. uitableview hidden default. when user touches uibutton above it, uitableview gets appear. my question when uitableview gets appear, how can make uitableview top of other controls? any appreciated. try [self.view bringsubviewtofront: yourtableview];

ios - How to get notification when app closed? -

i'm using signalr app notification, when app running on background mode, app got notification, when close app can't notification. how can notification when close app ? thanking answer me in advance : please find below sample code more information: - (void)application:(uiapplication *)application didreceivelocalnotification:(uilocalnotification *)notification{ nslog(@"notifi %@ , %@",notification.alertbody,notification.alerttitle); uiapplicationstate state = [application applicationstate]; if (state == uiapplicationstateactive) { uialertcontroller * alert= [uialertcontroller alertcontrollerwithtitle:@"title" message:@"message" preferredstyle:uialertcontrollerstylealert]; uialertaction* yesbutton = [uialertaction actionwithtitle:@"yes, please" style:uial

Creating a list of functions using a loop in R -

in this introduction functional programming , author hadley wickham creates following function factory: power <- function(exponent) { function(x) { x ^ exponent } } he shows how function can used define other functions, such square <- power(2) cube <- power(3) now suppose wanted create these functions simultaneously via following loop: ftns <- lapply(2:3, power) this doesn't seem work, 3 gets assigned exponent entries of list: as.list(environment(ftns[[1]])) $exponent [1] 3 can please me understand what's wrong code? thanks! what you're seeing consequence of r's use of promises implement lazy argument evaluation. see promise objects . the problem in power() function exponent argument never evaluated, meaning underlying promise never called (at least not until generated function evaluated). you can force promise evaluated this: power <- function(exponent) { exponent; function(x) x^exponent; }; ftns <- lapp

ios - Game Center "Done" button issue? -

the "done" button in game center not dismiss controller. code dismiss view controller same everywhere look. i've looked @ similar questions on here no luck. can me? gamescene.swift (this serves start menu ) class gamescene: skscene, gkgamecentercontrollerdelegate { var startbtn = skspritenode(imagenamed: "play button") var title = sklabelnode(fontnamed: "avenirnext-ultralight") var leaderboardbuttonimage = skspritenode(imagenamed: "leaderboard button") override func didmovetoview(view: skview) { let bounds = uiscreen.mainscreen().bounds self.scene?.size = cgsize(width: bounds.size.width, height: bounds.size.height) scene?.backgroundcolor = uicolor.whitecolor() startbtn.position = cgpoint(x: self.frame.width / 2 - 100, y: self.frame.height / 2) startbtn.size = cgsize(width: 140, height: 55) self.addchild(startbtn) leaderboardbuttonimage.position = cgpoint(x: self.frame.width / 2 + 100, y: self.frame.

windows phone 7 - LongListSelector Foreground Color -

have been searching through here no luck, pretty simple problem, on emulator font colors white (which want). testing on device fonts black now, have managed change setting foreground colors on elements unable on longlistselector through code. this works me: longlistselector.background = new solidcolorbrush(colors.transparent); however has no effect: longlistselector.foreground = new solidcolorbrush(colors.white); any other way can attempt set text color on longlistselector? the reason foreground colors different because of default style. phoneaccentbrush changes based on if "phone" set have white background or black one. the reason why longlistselector.foreground not working may because phoneaccentbrush set on items inside longlistselector style?

bash - Crontab hanging on pipeline, scope, or poor syntax -

i have shell script works fine user , works halfway in crontab. finishes rm line, however, , hangs on awk line: #!/bin/bash get_listeners.pl > temp.txt #accesses icecast admin page , puts useful metrics in temp.txt date +\%s > unpaired.txt grep "current listeners" temp.txt | sed 's/[^0-9]//g' >> unpaired.txt #first line of unpaired.txt time, second line number of listeners sed '$!n;s/\n/ /' unpaired.txt >> data.dat #combine 2 lines , append data file rm unpaired.txt #tidy a=$(($(date +\%s) - 86400)) | awk -v a=$1 '{if ($1 >= a) print $1,$2}' data.dat > data2.dat #get variable of 24 hours ago; copy lines last 24 hours new file gnuplot < demo.plt #make plot data in new file all paths explicit in crontab; i've removed them here keep concise. all files set 777 , data.dat builds steadily (job runs once per minute) never migrates data on second file in awk line. if can point out looks wrong awk line, i'm n

mysql - Wordpress - Is there a way to recover the table wp_term_relationships? -

Image
i'm trying non-profit organization site (which built wordpress) became "buggy"/odd: menus missing, categories empty, etc. i'm no expert around wordpress, first thing did turn on debug mode , message: error en la base de datos de wordpress: [table 'racidb.rc_term_relationships' doesn't exist] so, next thing did check on database (mysql). when login on phpmyadmin, can see table on left column when try browse content, message error: #1146 - table 'racidb.rc_term_relationships' doesn't exist i tried repair table, drop , delete it's content no luck. keep getting error #1146. unfortunately, there no backups on database can't upload table again. according them, error happened @ same time in wordpress updated 4.2.6 (they got automatic email of wordpress day issue appeared). my questions: 1) know might have happened? 2) there way can recover data mysql? 3) there way recover table "xx_term_relationships"? besides c

c# - A complex string splitter- How do I make this working code better? -

i have below program class program { static void main(string[] args) { list<assembly> failedassemblies = loadassembly(); string batchfile = "d:\\1" + ".bat"; filestream fs = file.create(batchfile); fs.close(); using (streamwriter outfile = new streamwriter(batchfile)) { string command = @"echo off"; outfile.writeline(command); process(outfile, failedassemblies); } } private static void process(streamwriter outfile, list<assembly> assemblieslist) { string command = "mstest.exe "; string testcontainer = " /testcontainer:"; list<string> testcontainerassemblies = new list<string>(4); outfile.writeline("set path=%mstestpath%"); foreach (assembly assmbly

c# - Can Protobuf.Net Serialize a Dynamic Dictionary? -

i have dictionary dynamic. public dictionary<int, dynamic> data = new dictionary<int, dynamic>(); the dynamic portion contain simple classes consisting of 5-6 get/set properties instance classes like. public class class1 { public int property1 { get; set; } public int property2 { get; set; } } and public class class2 { public string property1 { get; set; } public string property2 { get; set; } } i tried adding these 2 classes dictionary , serializing dictionary received error. wondering if protobuf.net able serialize , de-serialize such dictionary? , if so, how accomplished? the short answer "not really". there ways made work, wouldn't recommend - hard maintain. protobuf-net (and protobuf generally) works best when serializer knows structure in advance.

Processing Urdu Bidirectional text in text editors and Python -

Image
i wanted process bidirectional text (in urdu , english) in ms word document python script transforms text table markup. can't directly access bidirectional text word document in binary format , if copy paste text word document text editor bidirectional text renders incorrectly losing directionality. example: the following text rendered in reverse direction original msword text copied (urdu text involved): images پر ہے۔ so how process such bidi text rendered correctly in text editor notepad++ , hence can faithfully processed python script? first, don't rely on bidi text appearing correctly in word file. doesn't guarantee same text appear correctly when in other environment. microsoft word has own way of handling bidirectional text in current , legacy versions not way unicode-compliant text-editors (like gedit ) handle text. might or might not resolved microsoft implement newer version of unicode bidirectional algorithm in products. secondly, rea

Database Design Product Recipe Ingredients -

i trying create simple application , needed aspect of db design. attempting ef code first, need in order know goes in classes , how link via navigation properties. i need have structure, can query this recipe margarita (product) "tomato sauce","cheese" product id pk desc recipe id pk prodid fk ingid fk ingredients id pk desc i not sure how create table show me product many ingredients? current structure wont able many ingredients against product? i stuck , cannot head around it. i misunderstanding question, think you're asking how relate dynamic number of ingredients recipe. i'd in sql server: create table recipes ( id int primary key identity(1, 1), name nvarchar(max) ) create table ingredients ( id int primary key identity(1, 1), desc nvarchar(max) ) create table ingredientslist ( id int primary key identity(1, 1), recipeid int foreign key references recipes(id), ingredientid int foreign key r

ruby on rails - How to take database backup on heroku without pgbackups addon? -

i'm looking way take database backup on heroku without using pgbackups addon. there gem can in situation? gem should not use command line command pg_dump . you can save copy development environment using command: heroku db:pull

NMAP save results to separate files -

i wondering if there way specify range of ip addresses , save scan results each sepperate file in same folder. so scan 1.1.1.1, 1.1.1.2, 1.1.1.3 , save file file name ip address in folder. i'm working on small screen , make results more understandable. no, there isn't. however, might want take various -o options. for example, -om <filename> store in "machine readable" format. option greppable format. both of these might serve purpose because, essentially, save results in file 1 line per host rather rather verbose standard output.

php - Unable to access associative array values -

i have 2 config files. first, called configs.php contains array values: $welcomeconfigs = [ "title" => "welcome", "description" => "a description" ]; the second file includes configs.php 1 , use array generate other variables. second file called views.php . $viewconfigs = view . 'configs'; $pathtoviewconfigs = view . '/configs.php'; include($pathtoviewconfigs); var_dump($$viewconfigs); in index.php : define("view", "welcome"); include('views.php'); i need store in $title variable, example, value of associative array, when try nothing happens. tried use var_dump check if syntax correct , used en external fiddle check if wrong, nothing wrong. when type var_dump($$viewconfigs); output { ["title"]=> string(7) "welcome" ["description"]=> string(13) "a description" } but when type var_dump($$viewconfigs['title']); outpu

python - sci-kit learn: Reshape your data either using X.reshape(-1, 1) -

i'm training python (2.7.11) classifier text classification , while running i'm getting deprecated warning message don't know line in code causing it! error/warning. however, code works fine , give me results... \appdata\local\enthought\canopy\user\lib\site-packages\sklearn\utils\validation.py:386: deprecationwarning: passing 1d arrays data deprecated in 0.17 , willraise valueerror in 0.19. reshape data either using x.reshape(-1, 1) if data has single feature or x.reshape(1, -1) if contains single sample. my code: def main(): data = [] folds = 10 ex = [ [] x in range(0,10)] results = [] i,f in enumerate(sys.argv[1:]): data.append(csv.dictreader(open(f,'r'),delimiter='\t')) f in data: i,datum in enumerate(f): ex[i % folds].append(datum) #print ex held_out in range(0,folds): l = [] cor = [] l_test = [] cor_test = [] vec = [] vec_test

Using Clickatell's REST api in PHP -

i'm trying programmatically send sms messages in php code using rest api clickatell. i've got code: <?php $message = "test message"; $numbers = array("1**********","1**********"); $data = json_encode(array("text"=>$message,"to"=>$numbers)); $authtoken = "none of buisness"; $ch = curl_init(); curl_setopt($ch, curlopt_url, "https://api.clickatell.com/rest/message"); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_httpheader, array( "x-version: 1", "content-type: application/json", "accept: application/json", "authorization: bearer $authtoken" )); $result = curl_exec ($ch); echo $result ?> it seems work, because result i'm getting: { "data": { "message":[ {

javascript - nicescroll activates scroll after the page scroll completes -

i having aspx page. in page have applied nicescroll div scroll vertically. nicescroll scroll div after page's native scroll completes in sony ericsson mobile android version 4.2. want div scroll first followed page scroll. here div tag inside aspx page. <div id="divexample"> <div class="row-fluid white-bg"> <div class="row-fluid"><b> <asp:label id="lblcode" runat="server" text="using card?" cssclass="modallabel"></asp:label></b> </div> <div class="row-fluid"> <asp:label id="lblcode2" runat="server" text="here instructions" cssclass="modaltext modallabeltext"></asp:label> </div> <div class="row-flu

java - how to read business card image and store information into contact? -

i have started scan card application in android.which following task... 1) take photo 2) scan photo this application scan information image,information contact name, phone number,address,email address(if available)....etc scan card app on play store can body solve this? i want develop application.please reply me if api or help available.

javascript - Dynamically create and apply CSS3 animations -

the .animate() function in jquery not allow css3 animatable properties animated (for example, background-color ). there nice, standard way dynamically create, apply, , remove css3 animations elements on page? i'm following example here clunky , feels wrong. while works, rather better solution (using library or that). yes, can dynamically create, apply , remove css3 animations element in page. to dynamically create animation, need use insertrule or addrule functions add @keyframes rules , append stylesheet. once animation appended, applying element simple, need set required property value animation property via inline styles. removing agian simple, need set value null when needs removed. in below snippet, have first inserted animation , applied element on load. when animation starts, element fires animationstart event. within event listener, i've obtained outerhtml of element being animated , printed show how inline style present , @ end of animation

pdf - PDFBOX : java.lang.NumberFormatException: -

when i'm trying execute below code throws me below error java.lang.numberformatexception: input string: "8#40" @ java.lang.numberformatexception.forinputstring(unknown source) code : import org.apache.pdfbox.pdmodel.pddocument; import org.apache.pdfbox.pdmodel.interactive.form.pdacroform; import org.apache.pdfbox.pdmodel.interactive.form.pdfield; public class pdfperform { public static void main(string[] args) { try{ string sourcepath = "c:\\users\\347702\\desktop\\fw4.pdf"; string destinationpath = "d:\\pdf_forms\\filled_fw4.pdf"; pddocument document; document = pddocument.load(sourcepath); pdacroform form = document.getdocumentcatalog().getacroform(); pdfield field_1= form.getfield("f1_09(0)"); field_1.getvalue(); system.out.println(field_1.getvalue()); field_1.setvalue("asdsd"); sys

php - mysql query where conditions -

i have mysql database, here columns; date computerlab period only 2 possible data values go computerlab column, a101 or a102 however, there can duplicate rows of data different computerlab data for example, date = 3-15-16 computerlab = a101 period = 1 date = 3-15-16 computerlab = a102 period = 1 my webpage gets input user receiving several periods 1,3,5 this need: if period 1 or 3 or 5 contains both a101 , a102 return date i think work doesn't mysql_query("select date reservations period in ($periods) , lab in ('a101','a102') group date having count(*) = 2"); i think need group both period and date want: select date, period reservations period in ($periods) , lab in ('a101', 'a102') group period, date having count(*) = 2; this check given period has both labs. checking set of 3 periods had 2 entries. hmmm, realize might intend check if 3 periods had both labs assigned, in combinat

googletest - mock gtest compilation error -

i had crated class "gtest_static_class.h" , created mock mockgtest_static_class.h, after creating gtest_static_example.cpp, call' mock class mockgtest_static_class. the problem getting compilation error.. compilation error /x/opt/pp/include/gmock/gmock-spec-builders.h: in copy constructor âtesting::internal::functionmocker<void ()()>::functionmocker(const testing::internal::functionmocker<void ()()>&)â: /x/opt/pp/include/gmock/gmock-spec-builders.h:1656: error: âtesting::internal::functionmockerbase<f>::functionmockerbase(const testing::internal::functionmockerbase<f>&) [with f = void ()()]â private /x/opt/pp/include/gmock/gmock-spec-builders.h:89: error: within context package/web/webscr/mockgtest_static_class.h: in copy constructor âmockgtest_static_class::mockgtest_static_class(const mockgtest_static_class&)â: package/web/webscr/mockgtest_static_class.h:7: note: synthesized method âtesting::internal::functionmocker<void

ios - UICollectionViewController reordering does not work when embedded in a container view -

reordering working in ios9 when add uicollectionviewcontroller subclass override func collectionview(collectionview: uicollectionview, moveitematindexpath sourceindexpath: nsindexpath, toindexpath destinationindexpath: nsindexpath) it not work when uicollectionviewcontroller subclass embedded in container view. i've made demo of problem here any ideas on why or how fix it? the issue here put uicollectionview inside uicontainerview residing inside uiviewcontroller. requires few more steps uicollectionview work expected. add following viewdidload in collectionviewcontroller: self.collectionview!.addgesturerecognizer(uilongpressgesturerecognizer(target: self, action: "handlelonggesture:")) then add following function collectionviewcontroller: func handlelonggesture(gesture: uilongpressgesturerecognizer) { switch(gesture.state) { case uigesturerecognizerstate.began: guard let selectedindexp

python - Can PyCharm's IdeaVim plugin be persuaded to use hard tabs? -

i'm vim user, @ work folks using pycharm, thought i'd @ least give pycharm serious try. to make transition little less... well... repetitively typed, installed pycharm's ideavim plugin. however, our coding style -requires- hard tabs, not spaces (yes, it's opposite of places today), , i'm having hard time getting ideavim insert hard tabs instead of 4 spaces. i've tried :set noexpandtab (and :%retab), , i've tried ^v^i, neither seems working. does have ideavim doing hard tabs? if yes, how? thanks! have set "use tab character" in "file | settings | editor | code style | python"? work expected ideavim disabled? please give code example , keystrokes expect tabs, got spaces instead.

android - Playstore detailed reviews -

Image
is there api me gather review information playstore, given app name? requirement replicate screen more or less similar playstore "detailed review" screen(attached here quick reference). any appreciated. i confused. want create screen has layout of screen attached or want able read actual review , them? if latter, there no play store api unfortunately. has privacy issues, think. if want screen has same layout, don't think need gather review information. i searched around , found this: https://code.google.com/p/android-market-api/ there more information play store api here: is there way see user has submitted review android marketplace?

Python Blackjack - Count Hand of Players -

so i'm trying count hands of multiple players , compare them each other. here's main code: def make_deck(): # randomly shuffle deck import random cards = [] suit in ['h', 'c', 's', 'd']: num in ['a', '2', '3', '4', '5', '6', '7', '8', '9', 't', 'j', 'q', 'k']: cards.append(num + suit) random.shuffle(cards) return cards deck = make_deck() num_of_players = int(input("how many players?: ")) def deal_blackjack(deck, num_of_players): # deal 2 cards number of players hands = [[] p in range(num_of_players)] = -1 k in range(0,2): h in hands: += 1 h.append(deck[i]) return hands phands = deal_blackjack(deck, num_of_players) def print_blackjack(phands): # prints players respective hand in range(len(phands)):

openerp - Getting the Employee id of the Log User in Odoo - 8 -

good day have problem in filtering of odoo 8 field want select employee id of log user add in xml <field name="employee_id" style = "width:500px" domain = "[('id', '=', user.id.employee_id.id)]" options="{'no_create': true}"/> but have error says uncaught error: nameerror: name 'user' not defined. is there right way employee id of log user here in odoo 8 ? to obtain employee of logged user way: resource = self.env['resource.resource'].search([('user_id','=',self.env.user.id)]) employee = self.env['hr.employee'].search([('resource_id','=',resource.id)]) of course not easy put inside domain, maybe can use stored computed field save user_id of employee inside table, can write domain way: [('user_id', '=', uid)]

core data - ios coredata table schema sync -

it better ask here, since could't see light on google search results. finally, ios app , web app can smoothly sync data. on ios side, core data used playing offline data. on web app, user able add custom fields database table.so, newly added field exists in newer request results. how should manage app, continue work offline data containing newly added fields. what best pattern solve issue? there framework related? edit: old rest result { "status":"success", "data":{ "id":1, "createddatetime":"2012-05-07 08:18:11", "modifieddatetime":"2012-05-07 08:18:11", "createdbyuser":{ "id":1, "username":"super" }, "modifiedbyuser":{ "id":1, "username":"super" }, "owner":{ "id":1, "username":"super" }, &quo

android - Commiting project on svn repository from eclipse -

i know how commit project repository i.e. doing right click on project>team>commit , select files commit. confusion @ point while select files need commit: 1) need select java files , xml files? 2) lead conflicts if commit bin or other folders or files java files , xml files? it might sound silly helpful if throws light on these points! or give references tutorial on commiting files svn. thanks 1) not recommend commit bin folder or classes files. recommended commit source files (java) , resources (xml files, images etc.). 2) if commit bin folder see difference each time after compilation. couple of additional clarifications why not commit result of compilation (a bin folder or classes files): 1) can compile product form same sources different platforms 2) take space in source control repository

How to undo meteor add accounts-google -

added accounts-google app, looking remove it, total beginner here. used command meteor add accounts-google, meteor undo , meteor destroy aren't valid commands. found it, meteor remove accounts-google thanks anyway.

PHP Date difference -

i've following code: $dstart = new datetime('2013-03-15'); $dend = new datetime('2013-04-01'); $ddiff = $dstart->diff($dend); echo $ddiff->days; i don't know why i'm getting 6015 result. try like $dstart = strtotime('2013-03-15'); $dend = strtotime('2013-04-01'); $ddiff = $dend - $dstart; echo date('h:i:s',$ddiff); or per code try with $ddiff = $dstart->diff($dend); $date->format('d',$ddiff); echo $ddiff->days; if want diff in days try also echo floor($ddiff/(60*60*24));

rubygems - Jekyll Dependency Error when Upgrading from 2.x to 3.x -

following the official update guide , upgraded jekyll 2.x jekyll 3.1.1. after installation, running jekyll serve produced following error: dependency error: yikes! looks don't have jekyll-markdown-block or 1 of dependencies installed. in order use jekyll configured, you'll need install gem. full error message ruby is: 'unable activate jekyll-markdown-block-1.1.0 , because jekyll-3.1.1 conflicts jekyll (~> 2.0) ' if run trouble, can find helpful resources @ http://jekyllrb.com/help/ ! so there sudo gem update jekyll-markdown-block , error still persisted. tried update of gems: sudo gem update `gem list | cut -d ' ' -f 1` and out of desperation, uninstalled all of gems (except core one, not permitted uninstall): sudo gem uninstall `gem list | cut -d ' ' -f 1` i proceeded install jekyll normal (assuming working clean slate): sudo gem install jekyll fetching: liquid-3.0.6.gem (100%) installed liquid-3.0.6 fetching: kramdown-1.9

c++ - What different between object created from initialization constructor and assign operator? -

this question has answer here: create std::string std::istreambuf_iterator, strange syntax quirk 1 answer compiler gcc 4.8.4 -std=c++11 flag assigned. i've got compile error while compiling sample project. ifstream f(this->pid_file_name()); string content(istreambuf_iterator<char>(f), istreambuf_iterator<char>()); pid_t pid = stoi(content); it pop error : error: no matching function call ‘stoi(std::string (&)(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> > (*)()))’ pid_t pid = stoi(content); however, if change string declaration this, every things goes fine : ifstream f(this->pid_file_name()); string content = string(istreambuf_iterator<char>(f), istreambuf_iterator<char>()); pid_t pid = stoi(content); i know there differe

javascript - Where does data returned by ember-data 'live'? -

ya'll have bit of structural/procedural question ya. so have pretty simple ember app, trying use ember-data , i'm not sure if i'm 'doing right'. user hits index template, grab location coordinates , encode hash of (that part works). on server have db stores 'tiles' named after there hash'd coords (if hit #/tiles/h1a2s3h4e5d route formatted json). what happen next, if display each of returned tiles user on bottom of first page (like in partial maybe? if handlebars that). i have ds.model tiles, if hard code hash'd cords app.find(h1a2s3h4e5d) ; can see server responding query. however, cannot seem able figure out how access returned json object, or how display user. i did watch few tutorial videos seem outdated old router. mainly know: 1. information returned app.find() ; live & how access it? 2. 'correct' way structure templates/views handle this? 3. how should pass id (the hash'd coords) app.find ? global variable

c++ - Why can templates only be implemented in the header file? -

quote the c++ standard library: tutorial , handbook : the portable way of using templates @ moment implement them in header files using inline functions. why this? (clarification: header files not only portable solution. convenient portable solution.) it not necessary put implementation in header file, see alternative solution @ end of answer. anyway, reason code failing that, when instantiating template, compiler creates new class given template argument. example: template<typename t> struct foo { t bar; void dosomething(t param) {/* stuff using t */} }; // somewhere in .cpp foo<int> f; when reading line, compiler create new class (let's call fooint ), equivalent following: struct fooint { int bar; void dosomething(int param) {/* stuff using int */} } consequently, compiler needs have access implementation of methods, instantiate them template argument (in case int ). if these implementations not in header, wouldn

python - display a log file in real time with tkinter text field (python2.7) -

i trying write gui can display log file in real time (tail -f log). new line log file can printed out terminal, cannot loaded text field (line #). can 1 tell me why won't put text field? from tkinter import * import os, time import tkfiledialog class controller(object): def __init__(self, master): """ main interface: master - top level window """ self._master = master frame1 = frame(self._master) label = label(self._master, text="select log file") label.pack(side=top) currentlogfile = stringvar(self._master) logfilelist = [f f in os.listdir('.') if os.path.isfile(f)] currentlogfile.set(logfilelist[0]) chooselog = optionmenu(self._master, currentlogfile, *logfilelist, command = self.file_open) chooselog.config(width = "300") chooselog.pack(side=top) self._master.config(menu=chooselog) self._text=

java - Codename One Map -

Image
i want display map coordinates, can on 1 gui element, when duplicate code other gui element map doesn't appear this code 1 gui element (page or screen) @override protected void beforemapagps(form f) { mapcomponent mapcomponent= new mapcomponent(); double latitude=-41.169782; double longitude =-71.444885; coord lastlocation = new coord(latitude, longitude); mapcomponent.zoomto(lastlocation, 15); f.setlayout(new flowlayout()); f.addcomponent(mapcomponent); f.show(); } and other gui element (other page or screen) copied first @override protected void oncreategui1() { mapcomponent mapcomponent= new mapcomponent(); double latitude=-41.169782; double longitude =-71.444885; coord lastlocation = new coord(latitude, longitude); mapcomponent.zoomto(lastlocation, 15); f.setlayout(new flowlayout()); f.addcomponent(mapcomponent); f.show(); } when run simulator map appear on first page or screen, , not on other m

How to get VirtualFile from a VirtualFile URL in IntelliJ -

i working on plugin in on intellij. now have virtualfile file , trying write file.geturl() local file system can file when restart plugin. seems can not virtualfile url ? to find file url, use virtualfilemanager.findfilebyurl() ( source ). or keep things simple, store path , use localfilesystem.findfilebypath() suggested @vikingsteve.

regex - Avoiding this use of sapply in R data.table -

i've written function remove first parentheses onwards in string: until_parentheses <- function(string) { 1 <- stringr::str_split_fixed(string, "\\(", 2)[1, 1] res <- stringr::str_trim(one) return(res) } and have data.table column looks (something) this: messy <- paste(letters[1:10], paste0(c(" (", letters[1:2], ")"), collapse = "")) dt <- data.table(messy) when try use until_parentheses() on messy column so dt[, ":=" (clean = until_parentheses(messy))] the function applied first element of messy , clean column result repeated 10 times. in order have clean column come out how want using sapply: dt[, ":=" (clean_2 = sapply(messy, until_parentheses))] this gives result want takes long time run when dt long. i feel there problems both until_parenthese() function , data.table method. have solution makes redundant use of sapply in instance? thanks! you can use gsub

scope - Access a javascript variable from a function inside a variable -

hello have following issue not quite sure how search it: function(){ var sites; var controller = { list: function(){ sites = "some value"; } } } so question how access sites variable top defined var sites edit: here more complete part. using marionette.js. don't want define variable attached module (code below) variable keep private module, hope makes sense. here code works: admin.module("site", function(module, app, backbone, marionette, $, _ ) { module.sites = null; module.controller = { list: function (id) { module.sites = app.request("site:entities"); } }; }); and instead of module.sites=null; to var sites; that sort of thing make difference right? because in first case defining accessible variable outside second case private one. bit new javascript please try make simple. if looking global access, declare variable outside function first, make ch

android - XML layout has a ListView - But still getting ListView id not found exception -

i see lot of questions being asked in stackoverflow on same topic, could not understand deep problem of exception. below xml layout. have listview. <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#ffffff"> <listview android:id="@+id/list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#656565" android:paddingleft="@dimen/list_padding" android:paddingright="@dimen/list_padding" android:dividerheight="20.0sp" android:divider="#656565"/> </linearlayout> below fragment class. public class fragme

iphone - Command /usr/bin/lipo failed with exit code 1 -

i using hudson continuous integration first time ios project , while building project getting following error. "/applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/usr/bin:/applications/xcode.app/contents/developer/usr/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/x11/bin" lipo -create /users/test/.hudson/jobs/edetails/workspace/build/edetail.build/debug-iphonesimulator/sssdetail.build/objects-normal/i386/sssdetail /users/test/.hudson/jobs/edetails/workspace/build/sssdetail.build/debug-iphonesimulator/sssdetail.build/objects-normal/i386/sssdetail -output /users/test/.hudson/jobs/edetails/workspace/build/debug-iphonesimulator/sssdetail.app/edetail /usr/bin/lipo: /users/test/.hudson/jobs/edetails/workspace/build/sssdetail.build/debug-iphonesimulator/sssdetail.build/objects-normal/i386/sssdetail , /users/test/.hudson/jobs/edetails/workspace/build/sssdetail.build/debug

javascript - can phantomjs work with node.js? -

i use phantomjs in node.js script. there phantomjs-node library.. unfortunately author used weird coffee script code explain he's doing: phantom = require 'phantom' phantom.create (ph) -> ph.createpage (page) -> page.open "http://www.google.com", (status) -> console.log "opened google? ", status page.evaluate (-> document.title), (result) -> console.log 'page title ' + result ph.exit() now if use phantomjs directly javascript, this : var page = require('webpage').create(); page.open(url, function (status) { var title = page.evaluate(function () { return document.title; }); console.log('page title ' + title); }); so i'm trying write equivalent of first snippet of code above in normal javascript (by reading coffee script documentation .. did: // file name: phantomtest.js var phantom = require('phantom'); phantom.create(function(ph) {

regex - how to replace a matched line in a file in perl? -

open fh, "+<testing.txt"; $keyfield = "ppd6"; @searchlist = qw(ppd6 16-dec-15 base5 no yes g_<<date>> no no "n4,q2"); $fieldnumber = 3; $valuetoset = "ravitej"; splice @searchlist, $fieldnumber,1, $valuetoset; @lines=<fh>; open(file,">foo.txt")|| die "can't open file write\n"; foreach $line (@lines) { if($line =~ /$keyfield/) { print file $searchlist; } else { print file $line; } }#end foreach close(fh); close(file); **inputs: ** ppd5 31-dec-15 basel5 no no ppd5 23-dec-15 bas_15 no no ppd6 16-dec-15 bas3_15 no no npd5 16-dec-15 bas15 no no npd6 16-dec-15 bas15 no no paru 9-jan-16 hjfhg15 no no output: ppd5 31-dec-15 basel5 no no ppd5 23-dec-15 bas_15 no no ppd6 16-dec-15 bas3_15 ravitej no npd6 16-dec-15 bas15 no no paru 9-jan-16 hjfhg1