Posts

Showing posts from June, 2010

How to deploy a rails app with no domain name. (trying to create a test server) -

ok i'm trying deploy first rails project. i've asked this question , think figured out can't configure apache work using ip , have have domain name. the reason can't use domain name yet because i'm recreating site , don't want down in between switching domain current site new rails site. i'd rails app running on server can test out , once it's ready, switch domain name. how can setup server run rails project without using domain name? if want run rails project locally in development mode, run command rails s root of project. it possible deploy 2 apps same server, or 2 versions of same app, typically use sub-domains this, website.com , testing.website.com. you need have seperate databases , seperate virtualhost files. you try access apache machine it's ip address if on local network.

java - Issue reading a file path from a Properties file -

i'm working on swing app allow users view sets of (mostly locally-stored) files. i'm able store lists of files (among other preferences) text in properties files when try pull file values out, using myproperties.getproperty("file") it discards some of '\'s in text. confirmed writing properties files this: myprintwriter.println("file = " + myfile.tostring().replaceall("\\\\", "/")) or this: myprintwriter.println("file = " + myfile.tostring().replaceall("\\\\", "\\\\\\\\")) would allow getproperty() work more expected didn't having convert data java-specific format without explanation in api decided write on stack overflow. but when got point in post started feeling embarrassed; post on stack overflow without consulting java source code java.util.properties (distributed jdk). found javadoc comments properties.load() indicate design decision which, example, allows properties v...

ant - "'hibernate.dialect' must be set when no Connection available " error despite having set the dialect -

i have tried run hibernatetool ant task i've been unsuccesfull.help. jars eclipse(3.7.2) hibernate tools plugin(3.4). org.hibernate.hibernateexception: 'hibernate.dialect' must set when no connection available despite having set dialect here build.xml: <project> <target name="genero"> <path id="toolslib"> <path location="mylibs/hibernate-tools.jar" /> <path location="mylibs/hibernate3.jar" /> <path location="mylibs/freemarker.jar" /> <path location="mylibs/postgresql-9.0-802.jdbc4.jar" /> <path location="mylibs/dom4j-1.6.1.jar" /> <path location="mylibs/commons-logging-1.0.4.jar" /> <path location="mylibs/slf4j-api-1.5.8.jar" /> <path location="mylibs/slf4j-log4j12-1.5.8.jar" /> <path location="mylibs/log4j-1.2.15.jar...

javascript - Titanium createHttpClient runs after other vars declarations -

i have code in titanium, calls php file on server print name of user match id: var mystring; var request = titanium.network.createhttpclient(); var url = "http://localhost/myphp.php?id=1"; request.open("get", url, false); request.onload = function(){ var newstring = this.responsetext; ti.api.info(newstring); mystring = newstring; } request.send(); ti.api.info("result " + mystring); titanium console prints me this: result undefined nameofuser titanium seems call first code after request , request. can't change value of var responsetext. how can it? , why happens? sorry if posted here before, not think in keywords search here in stackoverflow thanks in advance =) the request asynchronous, when call request.send() not block execution. when request completes, onload event handler invoked.

Regex for java.util.Scanner for csv files? -

i want read csv file using java.util.scanner . first attempt looked promising: scanner scanner = new scanner(cfile); while (scanner.hasnextline()) { string curline = scanner.nextline().trim(); this.processrow(curline); } private void processrow(string workstring) { scanner linescanner = new scanner(workstring); linescanner.usedelimiter(","); // .next goes through elements linescanner.next(); } the challenge i'm facing line linescanner.usedelimiter(","); . csv has commas inside text , escaped double quotes: year,value,customer,nickname,rank 2012,45.56,t3456c,"mike, \"the gangster\"",1 2012,1237.35,"a453f", joe armagendon,2 2012,,x344,"frank weasel",3 is there regex filters separators? as mentioned nhahtdh, should use parser, way csv works bit more complicated example. there many libraries out there. 1 i've used , forked csvfile . it's pretty easy use , jo...

backbone-relational id references with backbone.marionette -

i use backbone-relational's includeinjson: 'id' include related model ids avoid spamming server-side whole object tree. unfortunately, backbone.marionette.view default exposes attributes of view mode returned tojson, means related models no longer accessible in view templates. i realize need custom marionette.view serializedata. needed models, i'm hoping solve generically; i.e. override serializedata views such right thing backbone-relational id references. any chance someone's done this? i'm not hopeful of that, figure there others use this, if nothing else serve place dump solution once i've coded it. :) any solution require 1 of these options: define 2 versions of tojson models, 1 uses includeinjson , other treats true. some way punch hole through marionette's restriction on view templates using model attributes , attribute-based helpers. i've got functional solution using option #1, it's such hack can't bear post p...

semantic web - Graph Database: TinkerPop/Blueprints vs W3C Linked data -

looking infrastructure network analysis heterogeneous (multiple node types (multi-mode), multiple edge type (multi-relation) , multiple descriptive features (multi-featured)) networks, i've noticed there 2 standard stacks in graph database world: on 1 hand have thinkpop/blueprint property graph model . supported neo4j , orientdb graphdb , dex , titan , infinitegraph , etc. the tinkerpop stack includes blueprint property graph model interface, gremlin graph traversal language, , furnace graph algorithms package. on other hand have w3c's linked data technology stack , supported allegrograph , 4store , oracle database semantic technologies , owlim , systap bigdata , etc. semantic data represented using rdf / rdfs / owl , , can queried using sparql on top offers rules , reasoning capabilities. now, suppose want represent heterogeneous data in graph database, , analyse such data (statistics, relations discovery, structure, evolution, etc.) (i know these terms ...

hidden - Is this possible to create a partition which be accessible but invisible by TrueCrypt and C#? -

i have folder in cd/dvd , want make contents invisible, accessible , encrypted. decide use truecrypt making folder encrypted hidden volume.but method , user can see new volume contents after mounted. want know possible make mounted volume accessible invisible? , there other solution programming in c#? yes can. need write few of code produce registry file hide truecrypt drive. example make hide truecrypt drive known z: . first, open notepad , enter code. windows registry editor version 5.00 [hkey_current_user\software\microsoft\windows\currentversion\policies\explorer] "nodrives"=hex:00,00,00,02 then save file name hidez.reg . double click file , restart pc. after finished restart, drive z: (truecrypt drive invisible form computer). important truecrypt drive letter z: .

java - How to round DateTime of Joda library to the nearest X minutes? -

how round datetime of joda library nearest x minutes ? example: x = 10 minutes jun 27, 11:32 -> jun 27, 11:30 jun 27, 11:33 -> jun 27, 11:30 jun 27, 11:34 -> jun 27, 11:30 jun 27, 11:35 -> jun 27, 11:40 jun 27, 11:36 -> jun 27, 11:40 jun 27, 11:37 -> jun 27, 11:40 the accepted answer doesn't correctly handle datetimes have seconds or milliseconds set. completeness, here's version handle correctly: private datetime rounddate(final datetime datetime, final int minutes) { if (minutes < 1 || 60 % minutes != 0) { throw new illegalargumentexception("minutes must factor of 60"); } final datetime hour = datetime.hourofday().roundfloorcopy(); final long millissincehour = new duration(hour, datetime).getmillis(); final int roundedminutes = ((int)math.round( millissincehour / 60000.0 / minutes)) * minutes; return hour.plusminutes(roundedminutes); }

Facebook oauth display=wap for old cellphones -

facebook roadmap states on july 1st 2012 "the wap dialog display mode removed.". have taken @ dialogs overview , available display methods page, popup, iframe, or touch. none of them wap usage older cellphones (no touch support). the question how make wap visitors see wap version of auth dialog on facebook?

android - index out of bound exception in arraylist -

i developing application in have parsed json of public facebook profile. got string of imageurl , saved them arraylist , implemented in listview. going fine application crashing giving error "array index out of bound" or "memory space exception". unable resolve problem. me out. in advance. i attaching code also. @override public view getview(int position, view convertview, viewgroup parent) { view row = view.inflate(socialactivity.this, r.layout.facebook_row, null); imageview iv_user = (imageview)row.findviewbyid(r.id.iv_user_pic); textview tv_title, tv_description, tv_time; tv_title = (textview)row.findviewbyid(r.id.tv_title); tv_description = (textview)row.findviewbyid(r.id.tv_discription); tv_time = (textview)row.findviewbyid(r.id.tv_time); button btn_count = (button)row.findviewbyid(r.id.btn_arrow); //bitmap = downloadimage(aljson.get(position).strpicurl); tv_title.settext(aljson.get(position).strname); tv_descript...

lm - In R linear model, get p-values for only the interaction coefficients -

if have summary table linear model in r, how can p-values associated interaction estimates, or group intercepts, etc., without having count row numbers? for example, model such lm(y ~ x + group) x continuous , group categorical, summary table lm object has estimates for: an intercept x, slope across groups 5 within group differences overall intercept 5 within group differences overall slope. i figure out way each of these group of p-values, if number of groups or model formula change. maybe there information summary table somehow uses group rows? following example data set 2 different models. first model has 4 different sets of p-values might want separately, while second model has 2 sets of p-values. x <- 1:100 groupa <- .5*x + 10 + rnorm(length(x), 0, 1) groupb <- .5*x + 20 + rnorm(length(x), 0, 1) groupc <- .5*x + 30 + rnorm(length(x), 0, 1) groupd <- .5*x + 40 + rnorm(length(x), 0, 1) groupe <- .5*x + 50 + rnorm(length(x), 0, 1) groupf <-...

html - Avoid CSS expressions -

i understand css expression is, yslow reporting page using one: grade b on avoid css expressions there total of 1 expression inline <style> tag #3 (1 expression) however, cannot find coming from? tried searching files word "expression" (trying find expression() function) , coming blank. there else yslow considering css expression missing? yslow claims have inline style, @ least not css file. if can't find <style> in own html, else adding code. this maybe external javascript, or maybe comes browser extension added, e.g developer tool. in browser debug console type document.getelementsbytagname("style") list <style> in generated document

How can I check if filename contains a portion of a string in vb.net -

i have userform in 2008 vb express edition. part number created user input via concat string. want check if portion of part number exists in existing file names in directory. below more detailed explanation. this code creating part number user input on form. l_partno.text = string.concat(cb_type.text, cb_face.text, "(", t_width.text, "x", t_height.text, ")", mount, t_qty.text, weep, serv) i have following code tell user if configuration (part no) created exists l_found.visible = true if file.exists("z:\cut sheets\tcs products\blank out sign\" & (l_partno.text) & ".pdf") l_found.text = "this configuration exists" else l_found.text = "this configuration not exist" end if this need help. part no bx002(30x30)a1ss want compare 002(30x30) (just part of file name) files in 1 directory. want yes or no answer existance , not list of matching files. code below i've tried, n...

log probability plot in R? -

Image
does know how create log probability plot 1 in r x-axis probability , y-axis in log-scale. read , downloaded package her.misc package don't know how use it. ! #create log probablity plot #mpm 131201 #make dummy data set.seed(21) dt<-as.data.frame(rlnorm(625, log(10), log(2.5))) names(dt)<-"au_ppm" #create probablity scale lines , associated labels - prbgrd <- qnorm(c(0.001,0.01, 0.05, 0.10,0.20,0.30,0.40, 0.50, 0.60, 0.70,0.80,0.90,0.95,0.99,0.999)) prbgrdl<-c("0.1","1","5","10","20","30","40","50","60","70","80","90","95","99","99.9") #create value grid lines convert logs valgrd<-c(seq(0.001,0.01,0.001),seq(0.01,0.1,0.01),seq(0.1,1,0.1),seq(1,10,1),seq(10,100,10)) valgrd<-log10(valgrd) #load lattice packages - latticeextra nice log scale require(lattice) require(latticeextra) #use qqmath...

python - How to parse Apple's IAP receipt mal-formatted JSON? -

i got json from apple this { "original-purchase-date-pst" = "2012-06-28 02:46:02 america/los_angeles"; "original-transaction-id" = "1000000051960431"; "bvrs" = "1.0"; "transaction-id" = "1000000051960431"; "quantity" = "1"; "original-purchase-date-ms" = "1340876762450"; "product-id" = "com.x"; "item-id" = "523404215"; "bid" = "com.x"; "purchase-date-ms" = "1340876762450"; "purchase-date" = "2012-06-28 09:46:02 etc/gmt"; "purchase-date-pst" = "2012-06-28 02:46:02 america/los_angeles"; "original-purchase-date" = "2012-06-28 09:46:02 etc/gmt"; } this not json know. in json it's defined that each name followed : (colon) , name/value pairs separated , (comma). ho...

objective c - Synthesized NSNumber "out of scope" -

i'm doing ios app crawl youtube subscription's videos. have problem when want navigate see next videos @ third time. for these, need collect start-index (nsnumber *youtubestart) add number of videos displayed (int const maxvideos). for that, have in videosviewcontroller.h @interface videosviewcontroller : uiviewcontroller { nsnumber *youtubestart; } @property (nonatomic, retain) nsnumber *youtubestart; then in videosviewcontroller.m @synthesize youtubestart; static int const maxvideos = 6; and method do - (void) navigatevideos:(id)sender { int navigate = 0; int start = [youtubestart intvalue]; if(sender == bt_prev) { if(start >= maxvideos) { start -= maxvideos; navigate = 1; } } if(sender == bt_next) { start += maxvideos; navigate = 1; } if (navigate > 0) { youtubestart = [nsnumber numberwithint:start]; nsstring *url = [nsstr...

Objective-C set accessor -

when declare property in objective-c, add synthesize clause accessors @interface storemanager () @property (nonatomic, copy) nsstring *writestorestimer; @implementation storemanager @synthesize writestorestimer i use following syntax set value property [self setwritestoresmanager:@"data"]; is above statement same self.writestorestimer = @"data" ? call set-accessor yes self. , set uses accessors time dont when within same class , use pointers name

apache - Install passenger in CentOS with RVM and latest Ruby cause this error -

i'm trying install passenger-install-apache2-module error: [root@devserver redmine]# passenger-install-apache2-module /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>': seems ruby installation missing psych (for yaml output). eliminate warning, please install libyaml , reinstall ruby. /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/resolver.rb:287:in `resolve': not find gem 'rails (= 3.2.6) ruby' in gems available on machine. (bundler::gemnotfound) /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/resolver.rb:161:in `start' /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/resolver.rb:128:in `block in resolve' /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/resolver.rb:127:in `catch' /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.4/lib/bundler/resolver.rb:127:in `resolve' /usr/local/rvm/gems/...

PHP 5.3 lambda anonymous function not working -

i can't figure out what's wrong here. here's test.php file: <?php error_reporting(e_all); echo phpversion(); $arr = array (); $attrs = array_filter((array)$arr, function($v) { return ($v || $v === 0 || $v === '0'); }); the output of script is: 5.3.3 warning: array_filter() expects parameter 2 valid callback, no array or string given in /path/test.php on line 8 how can be? thought php 5.3 supported lambdas. this related bug in eaccelerator, had problem caching opcode used lambdas. updated latest version of eaccelerator , fixed.

javascript - Proper deleting HTML DOM nodes -

i'm trying create star shining animation. function showstars() { //if ($('img.star').length > 5) // return; var x = math.floor(math.random() * gameareawidth) - 70; var y = math.floor(math.random() * gameareaheight); var star = document.createelement("img"); star.setattribute("class", "star"); star.setattribute("src", imagespath + "star" + getrandom(1, 3) + ".png"); star.style.left = x + "px"; star.style.top = y + "px"; gamearea.appendchild(star); // light. settimeout(function () { star.setattribute("class", "star shown"); }, 0); // put out. settimeout(function () { star.setattribute("class", "star"); }, 2000); // delete. settimeout(function () { gamearea.removechild(star); }, 4000); settimeout(function () { showstars(); }, 500); } it works fine until uncomment following code...

c# - The type initializer for 'Emgu.CV.CvInvoke' threw an exception -

i use code in project. haar = new haarcascade("face_detect.xml"); when program run, gives exception "'emgu.cv.cvinvoke' threw exception". can give me suggestion why is? edit: search this. says copy dlls emgucv. don't know where need copy dlls. add emgu.cv , emgu.gpu , emgu.ml , emgu.cv.ui , emgu.cv "references" in "solution explorer window" add opencv_core290.dll , opencv_gpuimgproc290.dll project in "solution explorer window". right click project / add / add existing item / goto emgucv folder / goto bin / *86 / opencv_core290.dll (if running 2.9 version of emgu cv ) check . can check youtube link https://www.youtube.com/watch?v=gaafi1kjagm

ruby - sass not recognised using Windows command shell -

i've installed ruby , sass gem on win 7 enterprise box. i've had issues throughout process, , had download gems , install them local avoid other issues. gem install --local sass-3.1.19.gem i'm trying sass --watch styles.sass:styles.css standard sass isn't recognised error command line. i'm new ruby have missed step. thanks in advance in order run commands without specifying full path, need have path program in path variable. so if program located in c:\programs\rubygems\gem\sass you'll need add c:\programs\rubygems\gem\ path . the process of adding folder path windows command line prompt described here . for windows powershell, please check setting windows powershell path variable here on so.

how to restore a trashed document in lotus domino in java -

i want restore trashed document in lotus domino. on basis can know parent view of trashed document? , how can items of document back? unfortunately, lotus notes doesn't offer way via there api. soft deletes in lotus notes explained here: http://www-01.ibm.com/support/docview.wss?uid=swg21091152 also see instructions on how create view displays soft deleted documents

java - While migrating from tomcat5.5 to tomcat7 the following jsp error is occurring -

this question has answer here: tomcat 8 enable debug logging list unneeded jars 3 answers i trying migrate application use tomcat7 instead of tomcat5.5 getting below error. using tomcat-7.0.27 window 32 bit machine: jun 29, 2012 3:01:05 pm org.apache.jasper.compiler.tldlocationscache tldscanjar info: @ least 1 jar scanned tlds yet contained no tlds. enable debug logging logger complete list of jars scanned no tlds found in them. skipping unneeded jars during scanning can improve startup time , jsp compilation time. you can define jar files skip when scanning tlds. done in conf/catalina.properties make error (which info message) disapear , speedup startupd/compile process of application.

mongodb - How to set a 2D index in Play Morphia? -

how set 2d index in play morphia? example: db.places.ensureindex( { loc : "2d" } ) http://www.mongodb.org/display/docs/geospatial+indexing i assume mean play 1.2.x. you can't @indexed annotation yet, seems: http://code.google.com/p/morphia/issues/detail?id=290 you can hacky [untested] code: morphiaplugin.ds() .getmongo() .getdb('dbname') .getcollection('places') .ensureindex(basicdbobject(loc, "2d")); but might want shell, show. it's 1 time thing.

wcf - I have a contract class with a proerty that is changed -

i have follwing class in common library: [datacontract] public class wcffilestream { private string _name; [datamember] public string name { { return _namee; } set { _name = value; } } private system.io.stream _file; //[messagebodymember] [datamember] public system.io.stream file { { return _file; } set { _file = value; } } i have property name, system.io.stream, when create new wcffilestream in client send service, type system.io.memorystream. why? this throw exception, system.servicemodel.communicationexception, because expected stream, not memorystream. why if property stream, when create object memorystream? thanks.

c# - Cursors stays where I click in VS text editor -

Image
sorry question can't find answer anywhere on internet. couldn't find answer myself either. here question: previously when clicked anywhere in vs text editor cursor moved end of statement, after ";". stays click on screen , annoying. how can address issue. in advance. this called virtual space , can changed in visual studio's options dialog. as per msdn article: to position comments beside code in options dialog box, expand text editor, , click general node development language. under settings, select enable virtual space. when option selected , word wrap cleared, can click anywhere beyond end of line in code editor , type. to revert behaviour you're after, need uncheck enable virtual space either @ language level or languages: also more here .

java - Search Method for an EmployeeStore. Using HashMap -

i making application store employee details such name, id , email address. doing using hashmap. having difficulty searchbyname,id , email address methods. how go writing 1 ? here code: //imports. import java.util.scanner; //******************************************************************** public class mainapp { private static scanner keyboard = new scanner(system.in); public static void main(string[] args) { new mainapp().start(); } public void start() { employeestore store = new employeestore(); store.add(new employee ("james o' carroll", 18,"hotmail.com")); store.add(new employee ("andy carroll", 1171,"yahoo.com")); store.add(new employee ("luis suarez", 7,"gmail.com")); store.print(); } } //imports. import java.util.hashmap; //******************************************************************** public class employeestore { ...

command line - Bash write to file without echo? -

as exercise, method exist redirect string file without echo? using echo "hello world" > test.txt i know cat , printf . thinking like > test.txt <<<"hello world" of course doesnt work, maybe similar command? you can "cat" , here-document. cat <<eof > test.txt text eof one reason doing avoid possibility of password being visible in output of ps. however, in bash , modern shells, "echo" built-in command , won't show in ps output, using safe (ignoring issues storing passwords in files, of course): echo "$password" > test.txt

php - SELECT * FROM table WHERE row IN ('list') -

i'm having trouble code below, it's giving me syntax error , can't find in manual or online it. thoughts on how run? 1st attempt: <?php require("../dbpass.php"); $types = array('buyer','seller','buyer / seller','investor'); $typeslist = implode ("','", $types); $sql = "select * contacts contacttype in ('$typeslist') , status = 'new' order date desc"; $result = mysqli_query($mysqli,$sql) or die ("error: ".mysqli_error($mysqli)); while ($row = mysqli_fetch_array($result)) { 2nd attempt (put "=" after "in"): <?php require("../dbpass.php"); $types = array('buyer','seller','buyer / seller','investor'); $typeslist = implode ("','", $types); $sql = "select * contacts contacttype = in ('$typeslist') , status = 'new' order date desc"; $result = mysqli_query($mys...

Writing messages of different types through sockets in C -

i want send message binder class via tcp socket connection in c. have pass in request type (char*), ip address (int), argtypes(int array) etc. through connection using write() method. what's best method send of information in 1 single message? there's no guarantee can send/receive data in single read/write operation; many factors may influence quality/packet-size/connection-stability/etc. question/answer explains it . some c-examples here . explanation of socket programming in c . quick overview of tcp/ip . about sending different types of messages: data send server-app received client-app can interpret data way likes.

Ado.net entity framework installation on Visual Studio 2008 -

i have visual studio 2008 professional edition not have template ado.net entity data model. i have tried downloading separate file ado.net entity framework 3.5 failed complete installation because beta version. could please advise on how find/install missing templates? visual studio sp1 should have template installed. have installed sp1 ? also make sure project targeting .net 3.5

c# - Can I write an excel add-in using Xcode? -

i've written several helpful excel add-ins using vba. i'm using excel mac 2011 version 14.2.2 (120421). i'd sell add-ins via web site. can write add-ins in xcode or have use c#? from microsoft support : in office 2011 mac, there no concept of add-ins. using excel add-in not possible... you'll need use vba or applescript emulate same behavior.

c# - LLBLGen Template Binding test for date type -

in llblgen template bindings viewer, want check if field date type, , if so, action i have similar, checks string type: <[foreach entityfield]> <[if isstringfield]><[entityfieldname]> = ""; <[endif]> <[nextforeach]> i'd able similar date types, like: <[foreach entityfield]> <[if isdatefield]><[entityfieldname]> = datetime.today; <[endif]> <[nextforeach]> however, isdatefield not available command. thanks in advance.

objective c - How to catch all iOS Push Notifications with different user actions including tap on app icon -

as per apple guide: "as result of presented notification, user taps action button of alert or taps (or clicks) application icon. if action button tapped (on device running ios), system launches application , application calls delegate’s application:didfinishlaunchingwithoptions: method (if implemented); passes in notification payload (for remote notifications) or local-notification object (for local notifications). if application icon tapped on device running ios, application calls same method, furnishes no information notification . if application icon clicked on computer running mac os x, application calls delegate’s applicationdidfinishlaunching: method in delegate can obtain remote-notification payload." my question suppose user got 3-4 push notifications provider , stored in apple's notification center. if user tapped on notification alert, he/she can notification data in app. if user tapped app icon on iphone, how data related of previous notifications. ...

java - How to upload a file using httppost FileEntity working with PHP server -

my java code on client is: fileentity entity = new fileentity(zipfile, contenttype); post.addheader(entity.getcontenttype()); post.setentity(entity); httpresponse response = httpclient.execute(post); i want receive using php on apache server. have no idea how set first value in $_files[" "]["tmp_name"] in php function move_uploaded_file($_files[" "]["tmp_name"],$upload_file) . have seen others asked same question.but answer not enough. waiting answer,thanks lot! i'm ready own test , it's been done on android downloading apache httpclient, should'nt problem case. i included httpclient.jar , httpmime.jar in 'libs'-folder. the important thing set part-name on mime-part of multipart-message. first part of assoc. php array. httpclient httpclient = new defaulthttpclient(); httpclient.getparams().setparameter( coreprotocolpnames.protocol_version, httpversion.http_1_1); ...

slf4j without toString() -

when log.debug("exported {}.", product) in slf4j call tostring() on arguments, e.g. product . for reasons, can't override tostring() on classes want use arguments. classes come third party jars, others have tostring() called in other contexts, too, information want print in log statement isn't available. however, have class debugging purposes has method debugformatter.format(object) has long cascade of instanceofs selects routine find useful debugging information object. my question is: possible configure slf4j calls such static method instead of tostring()? of course, call format method on object before passing parameter logger.debug() executed when respective logger not enabled. had surround if (log.isdebugenabled()) means whole point of having arguments in debug() missed. you create shim, taking object , calling debugformatter.format() tostring() function. this: class debugformatobject { private final object o; public static debug...

tags - Wordpress <!..more..> -

can <!..more..> tag me used make start , end point, below <h2>post details</h2> <!--more text in here appear on home page nothing else above or below. more!--> all want small text appear on home page, using tag in traditional way, seen below means header 'post details' appears on home page well <div class="page-header"> <h2>details</h2> </div> small text should appear on home page without showing header <!..more--> any great thanks found solution. use the_excerpt(); ignores text such headers

matlab - Can linprog give an integer value of x's? -

i have linprog code has x1,x2,x3 , x4 in objective function. the results give me values in form: x = 6.6667 0.0420 0 0 which in case trying model doesn't make physical sense because x's represent number of units of specific technology, , therefore example 0.0420 doesn't in fact exist. there anyway "force" linprog find optimum integer value of x? thank you that's called integer programming , in general np-hard. it's not covered linprog it's different , harder problem. here's related question (but not duplicate) stack overflow integer programming .

iphone - resizing text in UITextView -

how resize text in uitextview doesn't cut off text? have uitextview set @ specific height , want text in uitextview fit in height. in uitextfield have adjustsizetowidth, not in uitextview cgrect frame = textview.frame; frame.size.height = textview.contentsize.height; textview.frame = frame; source: https://stackoverflow.com/a/2487402/253008 edit: you can use -(cgsize)sizewithfont:(uifont *)font constrainedtosize:(cgsize)size to check width of text in uitextview , when reaches set width can start lowering font size

ruby - Can't get pjax to work on Rails -

i'm trying pjax work on rails app none of links being annotated pjax. think pjax isn't being loaded. i'm using pjax_rails , following railscast instructions using //= require jquery.pjax instead of pjax . i'm using bootstrap may cause issue i'm not sure. other thought is pjax javascript isn't being loaded , need run $('a').pjax('[data-pjax-container]') to clear main problem pjax isn't being loaded client side , when make requests x-pjax header not being set. finally got working. first problem unbeknownst me assests pipeline turned off pjax javascript file wasn't being included. instead went pjax rack gem , dumped public directory. created new javascript file $('a').pjax('[data-pjax-container]') , works! although i'm not sure why need manually call javascript when documentation seems point fact should there.

java - Transition to a black screen -

i believe have code set correctly when try debug it, after transitions splash screen goes right black screen. know imported layout correctly still goes black. this code splash screen package com.example.equate.jones; import android.os.bundle; import android.app.activity; import android.content.intent; import android.view.menu; import android.view.menuitem; import android.support.v4.app.navutils; public class ej_splash extends activity { protected boolean _active = true; protected int _splashtime = 3000; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_ej__splash); // thread displaying splashscreen thread splashtread = new thread() { @override public void run() { try { synchronized(this){ wait(4000); } } ...

python - read somewhat structured text file into array in C++ -

i reproduce following python code in c++, have run trouble. function read_file reads text file, tests first word in each line see if integer. if first word integer (4 or more digits) of words on line added list, z, floats. in other case line added string list. list of lists (z) converted 2d numpy array , returned rest. def read_file(f): srchp = re.compile(r'^\d{4,}\s') # beg. of line, digit min 4, white space f = open(f) rest = [] z = [x.strip() x in f.readlines()] # read file, strip whitespace @ beg./end of line, #store in z list of strings. each line @ own offset in range(len(z)-1,-1,-1): if not srchp.search(z[i]): #if regex not match rest.append(z.pop(i)) #append list rest else: z[i] = map(float,z[i].split()) f.close() return numpy.array(z),rest what data types should use containers in c++ (vector of vectors? arrays?)? @ end of day want use array statistical analysis. i'd grateful in convert...

django-ratings proving frustrating; need insight -

i've been trying 2 weeks implement highly regarded django-ratings 0 success. i've followed directions, not detailed, , cannot figure out how present means user submit rating template. there no directions on how load template tags associated it, resulted in errors. after looking through code, appears "ratings" proper way load tags within template, employed that. i added 'djangoratings' settings.py. the following model: rating = ratingfield(range=5) i did following urls.py: from djangoratings.views import addratingfrommodel url(r'rate-my-post/(?p<object_id>\d*)/(?p<score>\d*)/', addratingfrommodel(), { 'app_label': 'report', 'model': 'story', 'field_name': 'rating', }), added template: {% rating_by_user user on story.rating vote %} and nothing appears. no means user vote. nothing. i cannot figure out may wrong here , after 2 weeks of tweaking , trying d...

java - How to remove HttpServletRequest parameters (in JSP)? -

how can httpservletrequest parameter (especially in jsp) unset or removed (like in php using unset($_post['index']) function)? have tried following. map requestmap=request.getparametermap(); requestmap.remove("index"); but says no modifications allowed locked parametermap is there way unset request parameters? is there way unset request parameters? afaik, not within jsp (or servlet matter). but write filter wrapped current request in way replaces parameter map.

c - Why shared library path is hardcoded in execuatble? -

recently got test binary. when checked using objdump, observed includes hard coded library path. why needed to hardcode path that? shouldn't path taken shell environment variables or -l parameter instead ? objdump -p testprog the output includes hardcoded path shared libraries: .... needed /home/test/lib/liba.so needed /home/test/lib/libb.so needed /home/test/lib/libc.so .... this because 3 .so files had no soname on host test program built. tell person built rebuild liba.so -wl,soname,liba.so , similar other two, relink main program.

Handling dynamic subdomains in Google App Engine (Java) -

say have www.foo.com domain setup load app on foo.appspot.com how set things site can accessed sub-domain (such user.foo.com )? , how understand in app request has sub-domain value of user ? i'm not sure modifications need make in dns, , modifications need make in code read subdomain. maybe there's easier way, user.foo.com requests load (not redirect) foo.appspot.com/user , in case straightforward handle in code. i'm not sure how make these modifications - i'm trying achieve each of users gets own subdomain. you need wildcard cname, there info in app engine docs , if recall correctly not dns providers support that. also can't (without redirect) map {user}.domain.com www.domain.com/{user}.

html - Custom Pinterest button for custom URL (Text-Link, Image, or Both) -

i tried find solution can't. need custom image pinterest (pin it) button , pin custom image url not current page. i created custom link: <a href="http://pinterest.com/pin/create/button/?url=http://inspired-ui.com&media={imageurl}&description=descriptiontext" class="pinitbutton">pin it</a> in style set background image see default pin button , not custom button there solutions can set custom button image pin button can't change media={imageurl} in solutions. the popular solution is <a href='javascript:void((function()%7bvar%20e=document.createelement(&apos;script&apos;);e.setattribute(&apos;type&apos;,&apos;text/javascript&apos;);e.setattribute(&apos;charset&apos;,&apos;utf-8&apos;);e.setattribute(&apos;src&apos;,&apos;http://assets.pinterest.com/js/pinmarklet.js?r=&apos;+math.random()*99999999);document.body.appendchild(e)%7d)());'><img src='http:...

selenium - Counting inner text letters of HTML element -

is there way count letters of inner text of html element, without counting letters of inner element's texts? i tried out ".gettext()" method of "webelements" using selenium library, counts inner texts of inner web elements in (e.g. "<body><div>test</div></body>" results in 4 letters "div" and "body" element, instead of 0 "body" element) do have use additional html parsing library, , when yes 1 recommend? i'm using java 7... based on this answer similar question , cooked solution: the piece of javascript takes element, iterates on child nodes , if they're text nodes, reads them , returns them concatenated: var element = arguments[0]; var text = ''; (var = 0; < element.childnodes.length; i++) if (element.childnodes[i].nodetype === node.text_node) { text += element.childnodes[i].textcontent; } return text; i saved script script.js file , lo...

xml - Ruby - Finding Elements with REXML -

i have xml file holds information retail stores in particular city , locations i'm having trouble retrieving data it. problem can find stores names looping through name elements don't know how corresponding addresses once find stores i'm looking for. know how this? i'm using rexml main xml module. here's xml file , code like xml: <stores> <store> <name>supermarket</name> <address>2136 56th avenue</address> </store> <store> <name>convenience store</name> <address>503 east avenue</address> </store> <store> <name>pharmacy</name> <address>212 main street</address> </store> </stores> ruby: xml_file.elements.each('stores/store/name') |name| if input == name print name + "\n" #code retrieve address print address + "\n\n" end end xml_file = document.new fil...

Using navigation properties in entity framework code first -

context: code first, entity framework 4.3.1; user ---- topic, 1 many relation; user public virtual icollection<topic> createdtopics navigation property(lazy loading); topic public virtual user creator navigation property; dataservicecontroller : dbdatacontroller<defaultdbcontext> , web api beta, asp.net mvc 4 beta , single page application; system.json json serialization; web api action: public iqueryable<topic> gettopics() { // return dbcontext.topics; // ok return dbcontext.topics.include("creator"); //with exception } result: "an unhandled microsoft .net framework exception occurred in w3wp.exe" the problem here seems be: should not add navigation property in both entities (cause circular reference?), , if delete createdtopics navigation property in user class, ok again. so, in similar context listed above , here questions: how deal navigation properties in situation of 1 many relation;...

modify the name of the :id to :another_id in rails 3 -

well googled question couldn't find or it's not correct question.. the issue need modify primary_key name of database :id :another_id, in project need use pgrouting , contains several plsql functions , these functions uses primary-key name gid , instead of modify plsql functions better change id name, , thinking migration becouse thought it's rails way. is possible, , how can ?? thanks in advance , sorry english. edit create_table :pruebas, primary_key: :gid |t| t.string :name t.timestamps end this trick, , active record generate , uses pk gid. sorry if question not clear.. gracias por las respuestas. to set primary key yourself, when create table, do: create_table(:table_name, primary_key: 'gid') |t| ... end and need define primary key name in model: self.primary_key = 'gid'

Using an Arduino as a regular AVR -

i'm planning project using atmega (i can't use arduino directly because of university's restrictions). want use arduino's ide, serial monitor, plotting graphs using processing debugging purposes. can dump regular atmega code arduino , use serial monitor debugging purposes? can use arduino uno board other normal avr development board can best of both worlds. googled it, didn't answer need. if mean using arduino's avr microcontroller without arduino libraries: that's possible. you're going have mess lower-level stuff, though. can inspiration have done far libavrutil .

When using Toad to create a view in Oracle, how can I store the formatted script also? -

this question may toad specific. have no idea how oracle stores views, i'll explain happens when use toad. if answer oracle specific, better. i have created rather complex view. make clearer, have formatted code nicely, , entered comments needed. when need make changes view, use toad's "describe objects" window, can find script recreate view. problem formatting gone. comments before select keyword (but after "create view xxx as") disappear. if enter script create view: create or replace view testviewformatting -- here have long comment explaining role of -- view , things aware of if changing it. -- unfortunately comment disappear... select name, --this comment kept accountnumber --this debtable name 's%'; toad display when describe later: drop view xxx.testviewformatting; /* formatted on 04.07.2012 09:35:45 (qp5 v5.185.11230.41888) */ create or replace force view xxx.testviewformatting ( name, accountnumber )...

validation - How to validate uniqueness of nested models in the scope of their parent model in Rails 3.2? -

here example of problem. i have 'room' model: class room < activerecord::base has_many :items, :inverse_of => :room accepts_nested_attributes_for :items end and have 'item' model: class item < activerecord::base belongs_to :room, :inverse_of => :items validates :some_attr, :uniqueness => { :scope => :room} end i want validate uniqueness of :some_attr attribute of items belongs room. when try validate items, error: typeerror (cannot visit room) i cannot set scope of validation :room_id since items not saved yet id nil. want prevent using custom validators in 'room' model. is there clean way in rails? wonder if set :inverse_of option correctly... i don't see wrong how you're using inverse_of . as problem, in similar situation ended forcing uniqueness constraint in migration, so add_index :items, [ :room_id, :some_attr ], :unique => true this in addition ar-level validation validates_un...