Posts

Showing posts from January, 2011

ruby - Sinatra Restarting Webrick Server after ctrl-c -

require 'sinatra' require 'rubygems' class testserver < sinatra::application set :port, 22340 '/' "hello world" end run! if app_file == $0 end very simple application ruby 2.0.0-p0 , sinatra 1.4.2 when ctrl-c webrick server restarts on default port... see output below lm-bos-00715009:server joshughes$ ruby test.rb [2013-04-19 16:07:48] info webrick 1.3.1 [2013-04-19 16:07:48] info ruby 2.0.0 (2013-02-24) [x86_64-darwin11.4.2] == sinatra/1.4.2 has taken stage on 22340 development backup webrick [2013-04-19 16:07:48] info webrick::httpserver#start: pid=63798 port=22340 ^c == sinatra has ended set (crowd applauds) [2013-04-19 16:07:56] info going shutdown ... [2013-04-19 16:07:56] info webrick::httpserver#start done. [2013-04-19 16:07:56] info webrick 1.3.1 [2013-04-19 16:07:56] info ruby 2.0.0 (2013-02-24) [x86_64-darwin11.4.2] == sinatra/1.4.2 has taken stage on 4567 development backup webrick [2013-04-19 16:07:

php - SQL query based on array -

this question has answer here: can bind array in() condition? 19 answers i have array called $restaurantarray contains selection of restaurant id's. is there anyway can execute mysql query return rows if id equal 1 of these restaurant id's in array? thanks. you can use in mysql query. implode array $restaurantarray string, using comma delimiter; cover string brackets; , use result string input query. like // uncomment if data needs sanitized // $restaurantarray = array_map("mysql_real_escape_string", $restaurantarray); $input = '(' . implode(',', $restaurantarray) . ')'; $query = "select foo id in $input";

C++ multiple undefined reference error MinGW -

i have add graphics.h , winbgim.h libraries, , libbgi.a mingw. can found here . archive has folders indicate directory should placed under /mingw . have added -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 link options, specified in following link: http://www.infobits.ro/medii-mingw-developer-studio3.php . (sorry, it's in romanian, images quite easy understand). when try run following code: #include <graphics.h> #include <iostream> using namespace std; int main() { int gdriver = detect, gmode; initgraph(&gdriver, &gmode, ""); if (graphresult()) { cout<<"tentativa nereusita ..."; } else { cout<<"everything working!"; setcolor(red); moveto(0,0); lineto(getmaxx(),getmaxy()); } cout<<endl<<"press close"; getch(); return 0; } i error log "undefined reference error". error log is: c:\oji\mingwstudio

java - Where are JavaDocs generated by Gradle if default is not set? -

i running gradle javadoc task (through java plugin) cannot find output. in gradle documnetation states default destination directory ${project.docsdir}/javadoc , cannot find ${project.docsdir} set. output location when ${project.docsdir} not set? update: had built project using idea plugin builds project build directory excluded/hidden; excludes/hides .gradle directory. explains complied classes disappearing to. build/docs/javadoc output directory.

c++ - Optimising boost::python::object instances -

i started using boost's python library wrap parts of rather large c++ library. quite chance, discovered every python object created boost python, @ least bigger size of python list. simple types using noddy_noddytype example c-python api docs , can quite expose new object type instance, noddy_noddyobject . using raw c-python api, small , simple custom python object can be:- >>> import noddy, sys >>> print sys.getsizeof( noddy.noddy ) # pytypeobject size? 872 >>> print sys.getsizeof( noddy.noddy() ) # pyobject size 16 and compare base object:- >>> print sys.getsizeof( object ) 872 >>> print sys.getsizeof( object() ) 16 that's expected, when expose noddy_noddyobject using boost python? >>> print sys.getsizeof( noddy.noddy ) 904 >>> print sys.getsizeof( noddy.noddy() ) 80 say what?!! that's not ideal... object instances 5 times bigger need be! (this differ on non-64-bit machin

How to check command line arguments in a kdb script? -

i want check number of command arguments in q script , return error message if .z.x doesn't match intended number of arguments. far came line: if[count .z.x < 4; '`badusage] "arguments ok" i never past if statement, returns `badusage, regardless of number of arguments i'm using. how check correct number of arguments, print error message , exit script? its because statements evaluated right left. .z.x < 4 evaluated first, , count of result. q)count .z.x < 4 0 q)4 > count .z.x 1b

c# - Expanders in WPF -

i new wpf , working on projects our ui. quote problem 1.) have openfiledialog box in user can select dll or text files. 2.) if select dll fine , user operates in normal way, if user selects text files have processing on text files. 3.) there few steps on text file around 4-5 steps. after steps convert specfic file , user proceeds in normal way. what have done when user selects text files openfiledialog processing , show in expander status image, labels (this label contains command executed),etc. but problem expander shows after every process completes, not show real time how ti changes. started coding in wpf learning stuff , dont show how bring step step , how update ui when corresponding valeus changes in processing. snippet of code: browser_button() { if ( button == ok ) see if text or dll if dll continue if text files processing 4-5 steps expander contains processing logic give result of each stage. } expander_expander(object,event) {

ruby on rails - Verification of approach for notification email sending -

every , again find myself building feature , doubting whether approach makes sense or entirely out of whack. hoping might able verify strategy here. i'm building system notifies users via email actions have been taken within site comments, posts, etc. have model called actionevent tracks of these interactions. anytime user posts comment, example, new actionevent created documents action (who posted it, posted to, , context). ideally, when these action events created, want send out notification email. there tons of events warrant emails, , events cause more 1 person notified. things little hairy @ point, because don't want flood people's inboxes emails if, say, posts 3 comments in 5 five minutes. decided build action_event_email model track emails have been sent, , reason. idea before emails sent, system check sent emails make sure no emails of particular type sent particular user within acceptable timeframe before delivering email. make sense, or missing obvious her

java - GAE datastore: Entity deleted only after multiple calls to delete() -

i'm playing gae datastore on local machine eclipse. i've created 2 servlets - addmovie , deletemovie : addmovie entity movie = new entity("movie",system.currenttimemillis()); movie.setproperty("name", "hakeshset beanan"); movie.setproperty("director", "godard"); datastore.put(movie); deletemovie query q = new query("movie"); preparedquery pq = datastore.prepare(q); list<entity> movies = lists.newarraylist(pq.asiterable()); response.put("nummoviesfound", string.valueof(movies.size())); (entity movie : movies) { key key = movie.getkey(); datastore.delete(key); } the funny thing deletemovie servlet not delete movies. consecutive calls return {"nummoviesfound":"15"} , {"nummoviesfound":"9"} , {"nummoviesfound":"3"} , {"nummoviesfound":"3"} . why aren't movies deleted datastore @ once? update:

ninject - Named binding - MVC3 -

i'm trying register implementations of same interface using named instances kernel.bind<irepository>().to<cachedrepository>().insingletonscope(); kernel.bind<irepository>().to<dbrepository>().insingletonscope().named("db"); the idea, if not specify name cachedrepository gets created, if need db oriented 1 i'd use named attribute, miserable fails when simple object created public class tripmanagercontroller : controller { [inject] public irepository repository { get; set; } // default cached repo must created public tripmanagercontroller() { viewbag.logedemail = "test@test.com"; } } the error is error activating irepository more 1 matching bindings available. activation path: 2) injection of dependency irepository parameter repository of constructor of type tripmanagercontroller 1) request tripmanagercontroller suggestions: 1) ensure have defined

integer - Incorrect epoch date in node.js using thrift -

i seem getting different epoch date value in node.js thrift object stored in mongo database , returned service thrift definition file (thrift v0.9.0), have struct profile { ... 4: i64 createdate, 5: i64 lastupdatedate mongo record "createdtimestamp" : numberlong("1366334385361"), "lastupdatedtimestamp" : numberlong("1366334385361") node reports createdate: 534785233, lastupdatedate: 534785233 the generated node thrift client seems have i64 referenced. if (this.createdate !== null && this.createdate !== undefined) { output.writefieldbegin('createdate', thrift.type.i64, 14); output.writei64(this.createdate); output.writefieldend(); } i appreciate insight comes along. thanks binary representation given numbers : 1366334385361 -> 10011111000011111111000000010110011010001 534785233 -> 00000000000011111111000000010110011010001 i.e. if take lower 32 bits of 136633

ruby on rails - Ransack's collection_select and HABTM return undefined method -

i've been looking on code on , on again , can't see problem. i have 2 models person , credential. have habtm relationship. person class person < activerecord::base attr_accessible :credential_ids has_and_belongs_to_many :credentials unransackable_attributes = ["id", "hidden_note", "created_at", "updated_at"] def self.ransackable_attributes auth_object = nil (column_names - unransackable_attributes) + _ransackers.keys end end credential class credential < activerecord::base attr_accessible :description, :name has_and_belongs_to_many :people unransackable_attributes = ["id", "created_at", "updated_at"] def self.ransackable_attributes auth_object = nil (column_names - unransackable_attributes) + _ransackers.keys end end and here's form in people index.html.erb: <%= search_form_for @search, :class => 'no-bottom-margin form-inline' |f| %&g

java - Android Navigation - Finding line perpendicular to a line drawn through two locations -

Image
i have 2 location specified in latitude , longitude (a , b). between these location line (green). @ third location (me). how determine how far away line , in direction closest point (the gray line)? i'm looking heading in degrees , distance in meters. if can find location @ gray line meets green line can use android location built in functions calculate distance , heading. does know given lat/long locations of a, b , me how solve above problem? bear in mind 'me' not know whether he's in first or second situation , navigation problem. also appreciate if bear in mind i'm crap @ maths , answer talking 15 year old. also, i've worked out example hand using google earth. given: double alat = 51.44376; double alng = -2.86525; double blat = 51.43574; double blng = -2.87026; double melat = 51.4391; double melng = -2.86437; answer should be: distance closest point on line (aprox): 235 meters heading closest point on line (aprox): 109 degrees as always

When I run guide in matlab it opens a blank all gray window. Whats going on? -

when run guide in matlab, window opens grayed out title "guide quick start". running r2012b in ubuntu 12.04.2 lts. has else run problem? update 1 so discovered if press enter on first blank grey window opens layout editor window , seems fine. guessing on first screen there ok button (which cannot see) when press enter clicking on ok button. update 2 i built quick gui , there issues. can create axes , buttons , sliders on layout tool. however, when run gui tool displays axes, buttons, sliders not there. i believe things in matlab not yet compatible java 7, stick java 6 moment. in case, can have both versions installed @ same time, instruct matlab use correct version setting $matlab_java environment variable. you can verify version being used issuing command: >> version -java

algorithm - Loop invariant proof -

i running issue coming post-condition , showing partial correctness of piece of code. { m = ≥ 0 } x:=0; odd:=1; sum:=1; while sum<=m x:=x+1; odd:=odd+2; sum:=sum+odd end while { postcondition } i'm not looking answer, assignment school, insight , perhaps pointing in right direction. have constructed table of values, , cannot come loop invariant. x odd sum m (x + 1)^2 odd - x (odd - x)^2 0 1 1 30 1 1 1 1 3 4 30 4 2 4 2 5 9 30 9 3 9 3 7 16 30 16 4 16 4 9 25 30 25 5 25 5 11 36 30 36 6 36 sum = (odd - x)^2 i have outcome of loop perfect square following m, i'm not sure how write that. as always, appreciated. loop invariant is: odd = 2x+1 sum = (x+1)^2 proof: induction base : trivial. induction step : new_x = x+1 new_odd = odd+2 = 2(x+1)+1 = 2*new_x+1 new_sum = sum+new_odd =

objective c - Classes used in a project -

Image
is there elegant way list of classes used in project? i aware of objc_getclasslist(...) gets classes in objective-c, , trying avoid using class_conformstoprotocol filter out classes. thanks. in xcode, press cmd + 2 open symbol navigator , press c icon on lower left corner filter classes. you can filter more pressing document icon next c icon. result contain classes defined in project. here's picture buttons have click marked in red:

Indic font(Kannada) is not rendering properly in Android ICS -

i trying kannada font support android ics. rooted xperia neo l phone running android ics 4.0.4 , installed kannada font (lohit-kannada.ttf). have included lohit-kannada font family-set in fallback_fonts.xml in framework. after that, able see kannada fonts render in browser complex script not supported. glyphs not rendered in proper way, though readable. other indic languages tamil, hindi, bengali etc renders language not rendering properly. suggested me go thru blog. http://androidandsandu.blogspot.in/2011/12/how-to-add-indian-languages-to-android.html i'm not able find out make file changes. mean lohit-fonts directory, android.mk file? i'm not able find folders or files in phone. please? the link provided explains how change source code of custom android image want: prerequisites : ics (4.0.3) aosp source code ... so guess not possible without building own custom rom.

Android NDK: using other C++ libraries -

i trying run existing c++ code in android application. have ndk set up, , have source files copied jni folder in eclipse project. my c++ files have includes , namespace uses come elsewhere though, , i'm unsure how import (install?) them android project. code in c++ file: #include <gvars3/instances.h> #include <toon/svd.h> #include <fstream> #include <stdlib.h> using namespace cvd; using namespace std; using namespace gvars3; all of these libraries "unresolved inclusion". how can these libraries project? thanks. it not different usual way. can 1 of following: pull source , build single .so build other libraries separate .so files, , load them before own .so in android project (the order important)

Kendo UI Tooltip Bugs -

i have few bugs while using tooltip kendo ui. wanted show message input fields , set position of tooltip right shows towards top right corner of input field. when bring mouse on input field title of page changes. if setting autoclose: false there 2 x buttons in tooltip. sample markup , javascripts <input type="text" title="please enter firstname." id="txtfirstname" /> $("#txtfirstname").kendotooltip({ autohide: false, callout: false, showon: "focus", position:"right" }); please fix these bugs thanks prabhanjan i think issues addressed in q1 2013 sp1 (version 2013.1.514) - may 2013 release. here release notes tooltip of release: fixed: document title removed when tooltip open fixed: tooltip content not cleared when title attribute missing , shown target have tried use new version?

how to post data as an array using jquery for multiple same field names -

i have 1 form there same text field names, 5 columns , 5 rows in form, each column of rows had same text field names. problem how send data using jquery array. example form: <input type="text" name="fname[]" /> <input type="text" name="fname[]" /> <input type="text" name="fname[]" /> <input type="text" name="fname[]" /> <input type="text" name="fname[]" /> <input type="text" name="lname[]" /> <input type="text" name="lname[]" /> <input type="text" name="lname[]" /> <input type="text" name="lname[]" /> <input type="text" name="lname[]" /> <input type="text" name="age[]" /> <input type="text" name="age[]" /> <input type="text" name="age[]"

ios - how to access value json object in objective c -

i have json file down code: {"filecontent":[{"name":"directorffdsgfg","type":"file","ext":"sql","modified":"2013\/04\/11 - 10:00","created":"2013\/04\/11 - 10:00","size":"1577"},{"name":"directory02","type":"file","ext":"sql","modified":"2013\/04\/11 - 12:10","created":"2013\/04\/11 - 12:10","size":"1577"},{"name":"jquery-mousewheel-master","type":"file","ext":"zip","modified":"2013\/04\/11 - 12:10","created":"2013\/04\/11 - 12:10","size":"5213"}],"foldercontent":[{"name":"folder 2","type":"folder","ext":"sql","modified":"2013\/04\/1

html - How to align a box at middle of page without using margin? -

i trying box @ middle of page without using margin. i tried- .box-middle { vertical-align:middle; height:100px; width:100px; border:1px solid #ddd; } this doesn't work @ all- but things setting margin property works , don't want use margin . because giving margin breaks responsive web design. so have login form , want set @ middle of page. please guide ! here can tricks box- please align me middle use following jquery code : $(window).resize(function(){ $('.classname').css({ position:'absolute', left: ($(window).width() - $('.classname').outerwidth())/2, top: ($(window).height() - $('.classname').outerheight())/2 }); }); // run function: $(window).resize();

java - wired variable are null in zk controller -

i'm developing zk framework in java (with eclipse ) . i'm trying link textbox (view) controller throught wired variable . problem in controller wired variable null when submit event called . index: index.zul login : login.java don't use css selectors in @wire parameter, use zk component id. say, leave off # . also, if java variable name same zk component id (eg "win") can leave off @wire parameter , it'll still work fine. edit: there problem in code. textbox you're importing poi package =x

java - Override onStop everywhere? -

intro: have made fadeout/fadein fades out opacity of views. want animate between switching activities. have add fadein/fadeout every onstop/onresume in every activity. question: possible create custom overridden onstop function , use in every activity? create base activity this public abstract class baseactivity extends activity { .................. .................. @override public void onstop() { super.onstop(); // stuff } .................... ................... } now in every activity extend base actiity public class activity1 extends baseactivity

less - Bootstrap navbar margins -

i'd make left , right margins of navbar conetnt smaller "brand" (left component) appears more on left default , same right component. can point me relevant less variables modify? thanks with basic layout, css selector want is body > .navbar .brand play margin-left , margin-right until result want. depending on how calling css styles, may need add !important well, eg body > .navbar .brand{ margin-left:-20px !important; margin-right:-20px !important; } if don't have success this, try ommitting body > edit if want change width of entire navbar, try .navbar{ margin-left:-20px; margin-right:-20px; } you might need adjust details navbar-inner, eg .navbar-inner{ padding-left:0; padding-right:0; } edit see if helps: http://jsfiddle.net/panchroma/zbezf/ good luck!

c++ - Compile MFC program with VS 2012 running on windows xp -

i have vs 2012 on windows 7. want build mfc program can run on windows xp. received following error while moved exe file windows xp: “it not valid win32 application”. after exploring on internet, discovered should install visual studio 2012 update 1 , change platform toolset “visual studio 2012 (v110)” “visual studio 2012 - windows xp (v110_xp)”. changed target machine “machinex86 (/machine:x86)”. time receive error while run exe file on windows xp: “the procedure entry point initializecriticalsection not located in dynamic library kernel32.dll”. now not know :(. appreciate if can me :). please note tried simple dialog mfc program without adding code it. this bug in visual studio 2012 update 2 . link has workaround update 2 (although community sourced one), , microsoft has say: posted microsoft on 06/05/2013 @ 16:16 yes, fixed in update 3 so best bet roll update 1 or wait update 3. edit visual studio 2012 update 3 release candidate has been release

Determine that the languages accepted by two NFA's are same or not -

i have 2 nfa 's. need determine whether both recognize same language obliged if kind enough explain how this. you can canonical representation of nfa computing equivalent minimal dfa. if 2 nfa's have same canonical representation, accept same language.

WPF Binding to multidimensional array in the xaml -

i have trouble formulate xaml string link specific element in multidimensional array. the datacontext contains following lines: private string[] _onedimension = { "[0]", "[1]" }; private string[][] _jagged = { new string[] { "[0,0]", "[0,1]" }, new string[] { "[1,0]", "[1,1]" } }; private string[,] _twodimension = { { "[0,0]", "[0,1]" }, { "[1,0]", "[1,1]" } }; public string[] onedimension { { return _onedimension; } } public string[][] jagged { { return _jagged; } } public string[,] twodimension { { return _twodimension; } } the xaml contains following lines: <stackpanel> <button content="{binding onedimension[1]}" width="100" height="50" /> <button content="{binding jagged[1][1]}" width="100" height="50" /> <button content="{binding twod

javascript - Handlebars add class -

i have following json: "daysrange": { "status": "unspecified/all/specified", "available": [ { "id": "1", "name": "monday" }, { "id": "2", "name": "tuesday" }, { "id": "3", "name": "wednesday" }, { "id": "4", "name": "thursday" }, { "id": "5", "name": "friday" }, { "id": "6", "name": "saturday" }, { "id": "7", "name": "sunday" } ], "selected": [ { "id": "2", "name": "tuesday" }

android - Adapt chrisbanes ActionBar-PullToRefresh to Fragments(NavigationDrawer) -

okay here problem: i want implement chrisbanes actionbar-pulltorefresh library fragments able use navigationdrawer. https://github.com/chrisbanes/actionbar-pulltorefresh#fragments . chrisbanes says use fragments: one thing note pulltorefreshattacher needs created in oncreate() phase of activity. if plan on using library fragments best practice activity create pulltorefreshattacher, , have fragments retrieve activity. an example provided in fragment & tabs sample. . . ****here comes question: created pulltorefreshattacher in activity how hell pass pulltorefreshattacher fragments :s**** i have read bundles , getarguments() putserializable , parcelable : passing object activity fragment and read article in sth. ((myactivity ) getactivity()).getclassx() ; used. call activity method fragment but nothing understood/worked. :( . . here navigationactivity , 1 example fragment.i have new android/java :) final string[]

django - freeswitch python scripts errno 10 no child processes -

i' ve got issue when running freeswitch python scripts inside dialplan using django.db models. whenever starts causes errors: freeswitch@ubuntu> 2013-08-15 06:56:08.094348 [err] mod_python.c:231 error importing module 2013-08-15 06:56:08.094348 [err] mod_python.c:164 python error calling script "fs_scripts.ringback": <type 'exceptions.ioerror'> message: [errno 10] no child processes exception: none traceback (most recent call last) file: "/home/piotrek/lettel/fs_scripts/ringback.py", line 19, in <module> file: "/home/piotrek/lettel/api/call.py", line 3, in <module> file: "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 11, in <module> file: "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner file: "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup file: "/usr/local/lib/python2.7/dist-pa

pattern matching - In Racket or Scheme, is there any way to convert an ellipsis syntax object to a list of syntax objects? -

for example: (syntax-case #'(a b c d) () ((x ...) (list #'x ...)) in example, (list #'x ...) not work, can output equivalent of (list #'a #'b #'c #'d) ? here's 1 way of doing it: welcome racket v5.90.0.6. -> (syntax-case #'(a b c d) () ((x ...) (syntax->list #'(x ...)))) '(#<syntax:5:16 a> #<syntax:5:18 b> #<syntax:5:20 c> #<syntax:5:22 d>) for more, see syntax object operations section , functions exported syntax/stx .

c++ - Regex: Accepting space anywhere but at the beginning -

i'm working python bindings qt4.8 on os x. i want accept digit , few other chars , white space. string can empty or @ length. what don't want is, string being or end white space. my working example: '[0-9pqw\+\-\*\#\(\)\.][0-9pqw\+\-\*\# \(\)\.]*' however, don't want repeat 2 blocks 1 containing space 1 not. there should better way guess, employing [^ ], how? second question: if want limit strings total length, how it? thank you. you use negative lookarounds @ beginning , end of pattern: ^(?![ ])[0-9pqw+*# ().-]*(?<![ ])$ note brackets not necessary aid readability. neither of escapes (as long put - @ end).

Regex and if in shell script -

my programs starts services , store output in tmp variable , want match variable's content if starts fatal keyword or not? , if contains print port in use using echo command for example if tmp contains fatal: exception in startup, exiting. i can sed : echo $tmp | sed 's/^fatal.*/"port in use"/' but want use builtin if match pattern. how can use shell built in features match regex? posix shell doesn't have regular expression operator unix ere or pcre. have case keyword : case "$tmp" in fatal*) dosomethingdrastic;; *) dosomethingnormal;; esac you didn't tag question bash , if have shell can other kinds of pattern matching or ere: if [[ "$tmp" = fatal* ]]; … fi or if [[ $tmp =~ ^fatal ]]; … fi

MySQL IF... SELECT statement whilst retaining column headers -

fumbling in dark mysql isn't bad. (i coding novice) i have massive database need join database (in arc gis). did code joining database headers (necessary join) surprisingly didn't come standard when generating sub data sets mysql. as still 3 million records need wittle data down. did querying whether contained part of grid square reference (but no titles!). i'm trying see if contains image number (grid_image) whilst retaining column headers. if field contains number select ... outfile. i'm struggling if though, appreciated :). laura code far: where geograph_db.image_numbers.column1 = geograph_db.gridimage_geo.gridimage_id select 'gridimage_id','nateastings','natnorthings', 'view_direction' union select gridimage_geo.gridimage_id, gridimage_geo.nateastings, gridimage_geo.natnorthings, gridimage_geo.view_direction outfile 'geo.csv' fields terminated ',' optionally enclosed '"' geograph_db

How to set a column value based on values in another column in R -

i trying add new column based on values in column. (basically if other column missing or 0, set new value 0 or 1) what's wrong code below? times=nrow(eachfile) for(i in 1:times) {eachfile$salescyclen0[i] <- ifelse(eachfile$r[i]==na | eachfile$r[i]==0,0,1 ) } table(eachfile$salescyclen0) as long have tested column contains 0, 1 , na do: eachfile$salescyclen0 <- 1 eachfile$salescyclen0[is.na(eachfile$r) | eachfile$r==0] <- 0

logging - How to use Gradle Logger? -

import org.gradle.api.logging.logger import org.gradle.api.logging.logging in spock test package com.example.dummies import org.gradle.api.logging.logger import org.gradle.api.logging.logging import spock.lang.specification class dummyclasstest extends specification { file dir = new file("c:/users/results") dummyclass var logger log def setup() { log = logging.getlogger(dummyclasstest.class) var= new dummyclass(dir) } def ' test'() { log.info("--------------------------------------------------->hi") expect: var.gettdir() == dir } } my test passes when write gradle test -i but message not in console output. problem?

Python regex for dollar amounts including commas and decimals -

i'm new python , i'm writing bit of code needs take block of text , remove that's not dollar amount. example, number 2 thousand may represented 2000 2000.00 2,000 , 2k. i'm trying accomplish single regex replacement. right have: f=re.sub([0-9]+?(,[0-9])*?[0-9]+?(.[0-9])*?[ttbbmmkk],"",f) while understand incorrect , not compile, i'm not proficient enough know it. can give me guidance? thanks! give shot: import re blockoftext = 'two thousand may represented 2000 2000.00 2,000 , 2k' ' '.join([ ''.join(x[0]) x in re.findall(r'(\$?\d+([,\.]\d+)?k?)', blockoftext) ]) that gets new text string assign blockoftext if want, removing that's not dollar amount.

wordpress - Close Cookied jQuery UI Dialog With a Link -

i'm having trouble getting dialog respond how want. first script works fine not use cookies prevent dialog showing returning visitors. #closedb anchor says "i'm not interested" , closes dialog. jquery(document).ready(function($) { $("#email").dialog ({ autoopen: true, modal:true, width:400, }); }); jquery(document).ready(function ($) { $("#closedb").click(function () { $("#email").dialog('close'); }); }); this block has cookie check anchor not close dialog in example. jquery(document).ready(function($) { if (document.cookie.indexof('visited=true') == -1) { var fifteendays = 1000*60*60*24*15; var expires = new date((new date()).valueof() + fifteendays); document.cookie = "visited=true;expires=" + expires.toutcstring(); $("#email").dialog ({ autoopen: true, modal:true, width:400, }); } }); jquery(document).ready(function ($) { $

Linux Debian - unmet dependencies -

how can remove unmet dependencies on linux debian? result of apt-get -f install following: reading package lists... done building dependency tree reading state information... done correcting dependencies... failed. the following packages have unmet dependencies: libc-bin: breaks: libc6 (< 2.10) 2.7-18lenny7 installed libc-dev-bin: depends: libc6 (> 2.13) 2.7-18lenny7 installed recommends: manpages-dev not installed libssh2-1: depends: libgcrypt11 (>= 1.4.2) 1.4.1-1 installed libssh2-1-dev: depends: libssh2-1 (= 0.18-1) 1.2.6-1 installed locales: depends: glibc-2.13-1 nscd: depends: libc6 (> 2.13) 2.7-18lenny7 installed e: error, pkgproblemresolver::resolve generated breaks, may caused held packages. e: unable correct dependencies uname -r result: 2.6.18-274.7.1.el5.028stab095.1 i tried apt-get remove libssh2-1 , apt-get remove libc-dev-bin etc. doesn't wor

How to increment an IP address in a loop? [C] -

i know pretty simple of trying increment ip address +1 in loop. example: for(double ip = 1.1.1.1; ip < 1.1.1.5; ip++) { printf("%f", ip); } basically trying increment ip +1 in loop. don't know type of variable store ip in , don't know how increment it. whenever run program error saying number has many decimal points. i've seen on internet have store ip's in character array, cannot increment character array (that know of). variable type should store ip in/how should approach this? thank you. a naive implementation (no inet_pton ) user 4 numbers , print them char array #include <stdio.h> int inc_ip(int * val) { if (*val == 255) { (*val) = 0; return 1; } else { (*val)++; return 0; } } int main() { int ip[4] = {0}; char buf[16] = {0}; while (ip[3] < 255) { int place = 0; while(place < 4 && inc_ip(&ip[place])) { place++;

android - Google In-App Billing V3. Check if user has already purchased the Item -

i've been following tutorial: http://blog.blundell-apps.com/simple-inapp-billing-payment-v3/ i succefully managed integrate in-app billing system app. item add removing ads. therefore, when user first starts app, need check whether has purchased item. how can that?

silverlight - master data services url -

i've included master data services silverlight frontend in sharepoint using iframe. wan't link specific entities , such in frontend. know can link directly entities, , filter on specific parameters using eid , mecd queryparameter i.e.: xxx/explorer/attributesl.aspx?mid=2&amp;vid=2&amp;eid=11&amp;aid=208&amp;mecd=31220&amp;hosted=true#/explorerentity?mid=2&amp;vid=2&amp;eid=11&amp;aid=208&amp;mecd=31220&amp;hosted=true what link hierarchy, , automatically select specific node in hierarchy. possible? the link hierarchy is: xxx/explorer/explorerderivedhierarchy.aspx?htid=1&hid=1&mid=2&vid=2#/explorerderivedhierarchy?htid=1&hid=1&mid=2&vid=2 but selects "root" node automatically. thanks

sql server - SQL query counting based on successive condition -

i have table looks this: +--------+-------+-------+ |testname|testrun|outcome| +--------+-------+-------+ | test1 | 1 | fail | +--------+-------+-------+ | test1 | 2 | fail | +--------+-------+-------+ | test2 | 1 | fail | +--------+-------+-------+ | test2 | 2 | pass | +--------+-------+-------+ | test3 | 1 | pass | +--------+-------+-------+ | test3 | 2 | fail | +--------+-------+-------+ the table used storing brief summary of test results. want write query (using t-sql dialect fine) returns how many build each test has been failing. use example input , should return result set this: +--------+----------+ |testname|regression| +--------+----------+ | test1 | 2 | +--------+----------+ | test2 | 0 | +--------+----------+ | test3 | 1 | +--------+----------+ note query should count current 'fail streak' instead of counting total number of failures. can assume max(testrun) recent run. any ideas? edit:

Django : Read multiple file from html form -

i trying upload multiple files using django. using following code select multiple files in html form. index.html image files:<input type="file" name="image" multiple /><br/> views.py image=request.files.get('image') models.py image=models.imagefield(upload_to=get_upload_pathimage) now last file (if select 3 files 3rd file). how images ? request.files multivaluedict , doing get return last value noted. if want of values should use images = request.files.getlist('image') .

Passing current page url to control with Twig in Symfony -

hi have modal contact form on site available on each page of site. when render contact controller on each page trying use this {% render controller('corporatesitebundle:forms:contactus', { 'contactopen': contactopen defined, route: app.request.requesturi}) %} then on controller page contact form wanted grab 'route' value sending over. used: $request->query->get('route'); but form seems fail when submits. can i'm going wrong? thanks you should try $request->get('contactopen');

php - How to separate two columns with the same name while using JOIN LEFT? -

mysql table looks this: markers id, tid, lat, lng 1 1 42.000 2.500 2 1 41.000 2.400 3 2 40.000 2.300 markers_types id, name, image 1 type1 type1.png 2 type2 type2.png while using codeigniter's active records: function get_coordinates(){ $this->db->select('*'); $this->db->from('markers'); $this->db->join('markers_types', 'markers.tid = markers_types.id'); $this->db->where('state', 1); $query = $this->db->get(); if( $query->result() < 1 ) return false; $results = $query->result(); return $results; } it concatenate (or merge) 2 columns named id one, 2 different tables. how prevent that? , possible prevent merging these columns without renaming them ? just modify $this->db->select('*'); statement list out individual table.field names want capture in response. $this->db-&g

python - Quick way to extract CSS style attributes from html elements -

for machine learning purposes, have html page input, extract style attributes of dom elements. so, here preliminary code: from selenium import webdriver start = time.time() driver = webdriver.phantomjs() driver.get('example page') elements = driver.find_elements(by.xpath, "//*[not(child::*)]") #select leaf nodes l = {} css_properties=("line-height", "text-align","font-size", "font-style") in elements: if i.text: #print time.time() - end_dl if i.text not in l: l[i.text] = {} el in css_properties: l[i.text][el] = str(i.value_of_css_property(el)) l[i.text]["text_length"] = len(i.text) the problem code taking long parse features (~8s). can think in faster way this? are sure it's parsing step that's taking long? if so, here few options... try beautifulsoup4 parsing dom. deploy on cloud server faster hardware. use amazon ec2 or d

java - How to sort descending contents from file and get it only 5 line -

how read file 5 line , line in sort descending. example have file my.log following contents: one 2 3 4 5 6 7 8 9 ten eleven twelve and want result follows: twelve eleven ten 9 8 my code : import android.os.bundle; import android.app.activity; import android.util.log; import java.io.bufferedreader; import java.io.filereader; import java.io.ioexception; public class mainactivity extends activity { long sleeptime = 1000; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); string log = "/sdcard/my.log"; try { tail(log); } catch (ioexception e) { e.printstacktrace(); } } public void tail(string filename) throws ioexception { file checkfile = new file(filename); if (checkfile.exists()) { bufferedreader input = new bufferedreader(new filereader(filename));

actionscript 3 - GetChildByName is not working -

i having problem in getting child starling.current.nativestage - here code var temp:image = starling.current.nativestage.getchildbyname("ball"+turn)as image; trace(temp.name); the code "cannot access property or method of null object reference." making mistake or what? help me please note*i m noob in starling nativestage returns flash stage. these flash.display.displayobjects. cast starling.display.image via as image . return null. so, mean native flash stage, or starling stage - starling.current.stage ? var temp:image = starling.current.stage.getchildbyname("ball"+turn)as image; trace(temp ? temp.name : "temp null");

asp.net mvc - MVC ASPX To Razor - Register webcontrol -

i converted mvc 3 project aspx razor, having problem line: aspx: <%@ register tagprefix="cc1" namespace="webcontrolcaptcha" assembly="webcontrolcaptcha" %> razor: @{ register tagprefix="cc1" namespace="webcontrolcaptcha" assembly="webcontrolcaptcha"; } here error: compiler error message: cs1002: ; expected thanks in advance. you can put, in web.config inside views folder, following key: <configuration> <system.web> <pages> <controls> <add assembly="webcontrolcaptcha" namespace="webcontrolcaptcha" tagprefix="cc1" /> </controls> </pages> </system.web> </configuration>

ios - Objective C - [super dealloc] old? -

this question has answer here: custom dealloc , arc (objective-c) 1 answer i have question objective c. bought book objective c. new in objective c , book include many tutorials memory management. have mac version 10.7.5. in tutorial dealloc, xcode me "arc forbids explicit message send of 'dealloc'". search error in many forums. in these forums many people [super dealloc] inherits nsobject old , newer version of system make memory management automatically. book comes out 2011. i hope understand me. thank in advance. there new(ish) system ios called arc automatically sends release/retain/dealloc etc. messages objects. may read more here . the important thing note when answering question arc optional . may use it, not have to. (when creating new xcode project, either tick "enable automatic reference counting" button, or don

cordova - PhoneGap - Can't download from website -

i trying download version archive none of them seem work. http://phonegap.com/install/ anyone has link can them i didn't have trouble downloading link provided...however, try official apache archive: http://archive.apache.org/dist/cordova/

tomcat7 connection pool error -

when start tomcat7.0_26 on ubuntu 12/jdk7 (running on vm/virtual box), keep getting following error datasourcefactory in catalina.out file in logs directory. ideas how can resolved? have copied relevant server.xml , context.xml portions below well. able connect postgres db supplied username/pwd combination. server.xml : <resource type="javax.sql.datasource" name="jdbc/db" factory="org.apache.tomcat.jdbc.pool.datasourcefactory" driverclassname="org.postgresql.driver" url="jdbc:postgresql://localhost:5432/dbname" username="database-user" password="database-user-pwd" testwhileidle="true" testonborrow="true" testonreturn="false" validationquery="select 1" validationinterval="30000" timebetweenevictionrunsmillis="30000" maxactive="100" minidle="10&quo

iOS RevMob with Admob mediation -

i trying set revmob on admob mediation using customevent. i have setup gadcustomeventbanner custom call in project , being called correctly. but, ad black/blank. way can ad show calling [[revmobads session] showbanner]; does know how display ad view revmob ads using admob mediation? #import "revmobcustomeventbanner.h" @implementation revmobcustomeventbanner // set admob sdk. @synthesize delegate = delegate_; #pragma mark - #pragma mark gadcustomeventbanner - (void)requestbannerad:(gadadsize)adsize parameter:(nsstring *)serverparameter label:(nsstring *)serverlabel request:(gadcustomeventrequest *)customeventrequest { nslog(@"parameter = %@", serverparameter); nslog(@"label = %@", serverlabel); nslog(@"request = %@", customeventrequest); if (!self.revmobbannerview) { [revmobads startsessionwithappid:@"xxxxxx"]; self.revmobbannerview = [[

php - Call to undefined method Template::append_css() -

i trying append_css using code below. on older projects below code work. reference using codeigniter , template sparks public function __construct() { parent::__construct(); $this->load->library('template'); $this->template ->append_css('/public/css/app.css'); } public function index(){ $this->template->build('welcome_message.php'); } } i following error fatal error: call undefined method template::append_css() in /users/afont/quals/codeigniter-test/application/controllers/welcome.php on line 9 first, in autoload.php , may want autoload spark: $autoload['sparks'] = array('template/1.9.0'); second, looking through code, seems there no append_css function. in pyrocms , library appears have function, not spark default.

handlebars.js - restrict character length to display in jquery table with handlebars -

how restrict characters display jqurty table gets populated handlerbars.compile handlebars.compile('<tr><td>{{productdescription}}</td></tr>') i want display first 10 characters , want show ... if user clicks on should invoke jqueryui dialog shows entire product description. use handlebars helpers: handlebars.registerhelper('dotdotdot', function(str) { if (str.length > 10) return str.substring(0,10) + '...'; return str; }); after that, in template write {{dotdotdot productdescription}}

c++ - QT Is a slot launched in a separate thread -

i have done research on topic . thread @ caught interest , wanted summarize understanding , corrected if going wrong on path , wanted know how queuedconnection work. here understanding followed question. signals can connected manually slots through 2 different ways first way using direct connection , second way queued connection. in case of direct connection if slot method attached signal in same thread slot method called sequentially (as if method) incase slot in different thread signal launched queuedconnection launch when finds appropriate. (now in case not sure if launch new thread or how proceed on doing that) slots don't belong particular thread, plain functions. objects do. if connect signal slot queuedconnection , signal emission create event , send event queue of target. qt arrange slot called when internally processing event. as events, processed in thread of object's thread affinity . can change thread calling movetothread on target object.

ruby on rails - On heroku, how to delete files installed by a buildpack that are no longer needed? -

i've started getting slug size errors on deploy: -----> compiled slug size: 350.4mb large (max 300mb). my app far small causing this, verified manually inspecting bundle , assets size. upon investigation in one-off dyno, discovered files installed r buildpack still in vendor/ though stopped using buildpack months ago , unset buildpack_url : ~/vendor $ du -h --max-depth 1 90m ./ruby-2.0.0 28k ./plugins 24k ./heroku 122m ./bundle 113m ./glibc-2.7 16m ./bin 95m ./gcc-4.3 36m ./ruby-1.9.3 104k ./assets 87m ./r 1.2m ./gems 450m ./libexec 108k ./redis-rb 1008m . deleting them in one-off dyno doesn't it; reappear in new one. how can make these directories, r/ , gcc-4.3/ permanently go away? it possible r buildpack placed these files build's cache dir , ruby buildpack still pulling in. unlikely 2 buildpacks conflict way, possible. recommend trying push code brand new app , see if slug size drops. if so, can use third-party/unsupp

.net - Regex - Match Last Occurance -

Image
i have text file full of names, want match them via regex. each name ends following text: fsa fwb fcc, eg: ">dave smith\u0012\/a>\u0012\/div>\u0012div class=\"fsa fwb fcc i want use following expression match names: """>.+?""fsa fwb fcc" aka match text "> fsa fwb fcc , can parse excess matched myself. however "> occurs throughout file, starts matching earlier. have wondered how match last occurance of something, in case, "> , end specified. thanks all, stan. description it looks you're ending string literally fsa fwb fcc , , beginning of substring you're interested in starts directly after last "> before end string. this expression will: find substring between last "> , next fsa fwb fcc ">((?:(?!">).)*)fsa\sfwb\sfcc live demo sample text ">sometext">a dave smith\u0012\/a>\u0012\/div>\u0012div class=\&qu

css selectors - Select last element from already selected elements in pure css -

i want jquery :last selector, in pure css. how can 'z' paragraph, if didn't know index in dom structure! . or how last child of class '.area'? see css3 last element , doesnt work in case, because have childs in parent element. p.area:last-child donesn't work! i found solution, when know how many elements class .area . selector looks this: p.area ~ p.area ~ p.area when didn't know ... think... fun =) <div> <h1>this heading</h1> <p class="">the first paragraph.</p> <p class="area">the x paragraph.</p> <p class="area">the y paragraph.</p> <p class="area">the z paragraph.</p> <p class="">the last paragraph.</p> </div you cant without javascript. here quote the w3c spec : standalone text , other non-element nodes not counted when calculating position of element in list of children of parent. ps

IF statement on MYSQL query - IF all values for a column are the same -

is possible have php if statement saying if values of [column3] same, run code? i have mysqli query returning values if values column 3 same, want run php code. thanks, daniel this query return 1 row 1 column number of different values in column3 : select count(distinct column3) mytable if value 1 , there's 1 value in column.