Posts

Showing posts from July, 2012

c++ - Vector declaration globally and in the main class -

i writing code , in when declare vector globally , gives wrong answer when declare in main function . becomes right . want know difference between 2 declarations this code find min of first enteries, , 2nd min of 2nd enteries , if min >= 2nd min print no . here declared vector in main class when declare ints declared , site on submitting gives me wrong answer. #include<iostream> #include<algorithm> #include<vector> #include<cstdio> using namespace std; #define max 20000; int a,b,c,d,i,z; int main() { scanf("%d %d", &a, &b); while( a!=0 && b!=0) { z = max; for(i=0;i<a;i++) { scanf("%d",&c); if(z>c) { z=c; } } vector<int> v; for(i=0;i<b;i++) { scanf("%d",&d); ...

html - Injecting local files into UIWebView without breaking links -

i working on ios app needs display webpages server inside uiwebview while injecting relevant local png , css files needed in order speed load time. here code using try this: nsdata *myfiledata = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:[nsstring stringwithformat:@"http://www.example.com/index.html"]]]; nsstring* myfilehtml = [[nsstring alloc] initwithdata:myfiledata encoding:nsasciistringencoding]; [mywebview loadhtmlstring:myfilehtml baseurl:[nsurl fileurlwithpath:[[nsbundle mainbundle] bundlepath]]]; my problem of webpages have buttons in them link other webpages on server, , because uiwebview loading string, buttons when tapped don't cause uiwebview load new webpage url if had used loadrequest method. my question how can the uiwebview behave loading request while still injecting local files baseurl? thanks the relative links in button cannot work, because linked pages on remote server , not on device's file system. can use uiw...

puppet - Augeas support on my Vagrant machine? -

i'm trying getting support augeas on vagrant machine. i tried install package these directives: package { "augeas-tools": ensure => installed } package { "libaugeas-dev": ensure => installed } package { "libaugeas-ruby": ensure => installed } when try use augeas on manifests, after vm boot receive error: err: not find suitable provider augeas i'm using precise32 official box vagrant 1.0.3. vagrant 1.0.3 has ruby 1.8.7 , puppet 2.7.14 $ ruby -v $ ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux] $ puppet $ puppet v2.7.14 this little manifest php class, included after apache class, mysql , other classes tested separately. things works correctly excepting augeas command. class php { exec { "apt-update": command => "/usr/bin/apt-get update", refreshonly => true; } package { "augeas-tools": ensure => installed } package { "libaugeas...

c++ - Rectangle Leaves it mark behind while MouseMove -

i trying create rectangle , colour inverse (area outside rectangle) area. gdiplus::region *cropregion = new gdiplus::region(croprectf); gdiplus::rect gdicroprect(0.0f, 0.0f, 1000.0f, 1000.0f); gdiplus::rect imagecontainer(0.0f, 0.0f, 1000.0f, 1000.0f); gdiplus::region *completeregion = new gdiplus::region(imagecontainer); completeregion->intersect(cropregion); gdigraphics.setclip(completeregion, gdiplus::combinemodexor); gdiplus::graphicspath *croprectpath = new gdiplus::graphicspath(); croprectpath->addrectangle(croprectf); gdiplus::pen* mypen = new gdiplus::pen(gdiplus::color::white); mypen->setwidth(1); gdigraphics.drawpath(mypen, croprectpath); gdiplus::solidbrush dimmingbrush(gdiplus::color::makeargb(50, 0, 0, 0)); gdigraphics.fillregion(&dimmingbrush, completeregion); the code till here works fine, however when try move rectangle using mouse movements in mousemove callback, moves leaves white traces behind. i tried call invalidaterect in end recta...

Strange :id in :path with Mongoid-Paperclip — /4f8b/5a82/ef1a/7750/b800/0077/ -

i've upgraded rails 3.1.3 3.2.3 , noticed browser doesn't show images anymore. looked images path , /system/photos/images/4fce/1fb6/3ee5/1d01/a800/0006/original/img_2842new2.jpg?1338908598 example. there no :path declaration in model, should use default :rails_root/public/system/:attachment/:id/:style/:filename . the key thing images aren't shown :id parameter 4fce1fb63ee51d01a8000006 stored in db devided slashes ( / ) 4-symbol groups: 4fce/1fb6/3ee5/1d01/a800/0006 , folder named sould be, 4fce1fb63ee51d01a8000006 . that's pretty strange. i use mongo (1.6.2) mongoid (2.4.10) paperclip (3.0.4) mongoid-paperclip (0.0.7) it mistake, didn't notice when did updates paperclip updated , version 3.0 requires :path , :url options passed explicitly: :path => ":rails_root/public/system/:attachment/:id/:style/:filename", :url => "/system/:attachment/:id/:style/:filename"

selenium - ExpectedConditions for a window not available -

is there api waiting window load before switching or presence of window title in new window? have expectedconditions.frametobeavailableandswitchtoit frame available, however, make life easier if had equivalent 1 window well. response appreciated. thanks. i use approach: /** * wait emergent windows present. */ public final void waitforwindowspresent() { webdriverwait wait = new webdriverwait(getdriverprovider().get(), timeout); wait.until(new predicate<webdriver>() { public boolean apply(final webdriver d) { return getdriverprovider().get().getwindowhandles().size() > 1; } }); } i check if number of windowhandles greater 1, if expecting open more windows save state of windowhandles , compare against that.

ruby on rails - MySQL to MongoDB conversion -

how convert following mongodb query ? sets_progress = photo.select('count(status) count, status, photoset_id') .where('photoset_id in (?)', sets_tracked_array) .group('photoset_id, status') there no 1 1 mapping of sql query nosql implementation. you'll need precalculate data match way want access data. if small enough, query need change map-reduce job. more here: http://www.mongodb.org/display/docs/mapreduce here's decent tutorial takes query group's , converts map-reduce: http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/

javascript - How might I return multiple arrays with equal values from a larger array with mixed values? -

i have array after being sorted appears this: var arr = ["a", "a", "b", "b", "b", "b", "c", "c", "c"]; there 2 "a" strings, 4 "b" strings, , 3 "c" strings. trying return 3 separate arrays, returning them 1 @ time loop, containing only matching values. so, upon first iteration, returned array appear newarr = ["a", "a"] ,  the second newarr = ["b", "b", "b", "b"]   and on third iteration newarr = ["c", "c", "c"] .   however, small array of predefined values, , need algorithm can perform same operation on array of unknown size, unknown elements, , unknown number of elements. (and keep in mind array sorted begin with, in context) here's crazy code displaying unusual, , incorrect, results: var arr = ["a", "a", "b", "b",...

javascript - Backbone.js - Sharing collections across multiple routes -

i'm working on backbone.js application multiple "sections". each "section" may have multiple routes share single collection. here's simple example (with sections "a" , "b"): http://jsfiddle.net/scttnlsn/lw4ny/ in example, collections fetched when router initialized can shared across multiple routes without need re-fetch in every route handler. seems fine @ first wary of continuing way when number of shared collections starts grow. additionally, seems silly fetching collections "sections" may never visited user- rather load data on demand. the obvious alternative fetch data in each route handler instead of when router initialized. mean data needed fetched, however, still ends performing unnecessary fetches when moving between routes in same "section". there no longer "sharing" of collection data. what's way handle situation? feel need implement sort of cache-like structure. there existing...

c# - How can the attributes of outer class can be accesed within the inner class in Composition Classes design? -

i totally unable access outer class attributes inside inner class ... if make object of outer class,, in inner class* which makes no sense in composition design * .. cant access them .. there way can access these outer class attributes ? scenario there sports car constructed if customers want buy exists! .. namespace composition{ public class customcar { #region attributes private string name; private string plateno; private double cost; private carcustomer _customer = new carcustomer(); #endregion #region properties public string name { { return name; } set { name = value; } } public double cost { { return cost; } set { cost = value; } } public string plateno { { return plateno; } set { plateno = value; } } public carcustomer customer { { return _customer; } set { _customer = value; } } #endregion #region methods ...

html - Javascript syntax: Function insideof a For loop -

syntax issue here code works fine. have loop , inline function must run within (aquery callback). (i=1;i <= 5;i++) { twitter[i] = $(this).find('twitter' + i).text(); //$('<div class="twitter[i]"></div>').html(twitter[i]).appendto('#link_'+i); $('.twitter[i]').html(twitter[i]).appendto('#link_'+i); // grab twitter $.getjson('http://api.twitter.com/1/users/show.json?screen_name='+twitter[i]+'&callback=?', function (data) { (j=1;j <= 5; j++) { twit_count[j] = data['followers_count'].tostring(); twit_count[j] = add_commas(twit_count[j]); $('#twitter_count'+j).html(twit_count[j]); } }); } if i=3 want j...

javascript - Preload image doesn't always appear -

i have created simple ajax request: var params = "postdata=" + mydata; if (window.xmlhttprequest) { xmlhttp = new xmlhttprequest(); } else { xmlhttp = new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid("data").innerhtml = xmlhttp.responsetext; } } xmlhttp.open("post", "data.php", true); xmlhttp.setrequestheader("content-type", "application/x-www-form-urlencoded"); xmlhttp.setrequestheader("content-length", params.length); xmlhttp.setrequestheader("connection", "close"); xmlhttp.send(params); and html code: <div id="dat...

c# - Static Repositories - Workaround -

first, background. have taken on large mvc3 project. project pretty ready go live time ago, client decided wanted re-theme whole website , add load more functionality. employed re-theme site, finish off remaining functionality , deploy it. generally built using clear, ordered approach, 1 repository each database table , clear service layer, there oddities making me uncomfortable. main oddity keeps on nagging @ me every single repository , service in application completely, 100% static (yes, including methods write db). of course, doesn't allow unit testing, greater concern potential bottlenecks , threading issues cause when application comes under heavy load. seeing unexplained delays in processing requests on stage server, , trickle of testing traffic. the application huge rebuilding use ioc/instantiated-per-request repositories pretty out of question. what can avoid potential threading issues upon deployment? use connection pool , borrow db connection each time w...

How can I get F# Interactive window to use the same path as the project? -

in project opening file relative path executable. trying test code in f# interractive window, seems run different path. how can change path/ make run same path project? i think __source_directory__ identifier here. you should use compiler directives separate between using f# interactive , compiling f# project. #if interactive let path = __source_directory__ + some_relative_path #else let path = another_relative_path #endif

python - Cron-like scheduler, something between cron and celery -

i'd run periodic tasks on django project, don't want complexity of celery/django-celery (with celerybeat) bundled in project. i'd like, also, store config times , command run within scm. my production machine running ubuntu 10.04. while learn , use cron, feel there should higher level (user friendly) way it. (much ufw iptables). is there such thing? tips/advice? thanks! in personal opinion, learn how use cron. won't take more 5 10 minutes, , it's essential tool when working on linux server. what set cronjob requests 1 page of django instance every minute, , have django script figure out time , needs done, depending on configuration stored in database. approach i've seen in other similar applications.

php - Fedex Web Services: ERROR 9040 - Can't pull up tracking -

i'm having issues attempting pull tracking info using fedex's web services. using valid tracking number , i'm able view details on fedex's site. however, error 9040 "no information following shipments has been received our system yet. please try again or contact customer service @ 1.800.go.fedex(r) 800.463.3339." leaving out? my code: <?php $path_to_wsdl = "url_to_wsdl"; ini_set("soap.wsdl_cache_enabled", "0"); $client = new soapclient($path_to_wsdl, array('trace' => 1)); $request['webauthenticationdetail'] = array( 'usercredential' =>array( 'key' => 'my_key', 'password' => 'my_password' ) ); $request['clientdetail'] = array( 'accountnumber' => 'my_acct', 'meternumber' => 'my_meter' ); $request['transactiondetail'] = array('customertransactionid' => ...

after pressing home button also how to start app from starting activity in android -

hai doing 1 android app.in middle of app user click home button time app closed agian user open same app means time in previous in wich activity press home button page opened.but need in app every time after clicking home button need close app,then user again open app time need open first page every time.i treid using code here home button working button. if 1 having idea suggest me... @override public void onattachedtowindow() { log.i("teste", "onattachedtowindow"); this.getwindow().settype(windowmanager.layoutparams.type_keyguard); super.onattachedtowindow(); } public boolean onkeydown(int keycode, keyevent event) { if (keycode == keyevent.keycode_home) { log.i("teste", "botao home"); finish(); return true; } return super.onkeydown(keycode, event); } whenever press home button activity @ time overwrite onpause method activity , when open app use onre...

c# - Command parameter passing parent reference -

i have wpf treeview , need reference of parent node in child node context. menu command. in below xaml, need pass reference of in member command parameter xaml: <datatemplate x:key="member"> <textblock text="{binding}" tag="{binding datacontext, relativesource={relativesource ancestortype=mylib:extendedtreeview}}"> <textblock.contextmenu> <contextmenu> <menuitem header="delete" command="{binding relativesource={relativesource ancestortype=contextmenu}, path=placementtarget.tag.deletemmebercommand}"> <menuitem.commandparameter> <multibinding converter="{staticresource mutilvalueconverter}"> <binding path=".."/> <binding /> </multibinding> </menuitem.commandparameter> </menuitem> </contextmenu> </textblock.contextmenu> </textblock> </datatemplate> <hierarchi...

java - Spring: how to show image with other content on JSP page -

possible duplicate: when saving image blob how display in jsp text? spring - display image on jsp file i want show image gallery on web page content below it. can't figure out how pass image database page such as: @requestmapping(value = "/", method = requestmethod.get) public string home(model model) { model.addattribute("servertime", /*my image byte[] ?!*/); return "home"; } i have found example tells can't show image , content mapped on same url pattern. if true, please give me example how it?

python - django request with two date field -

i trying attempt request filter on combination of date, , integer represent year, , encounter trouble doing it. here model : class exemple(models.model): date_field = models.datefield() year_field = models.integerfield() here request work : exs = exemple.objects.extra(where=["date(date_field, '+' || year_field|| ' years') < date('now') or date_field null"]) i want exact same request using django orm, tried (which didn't work) from django.db.models import f import datetime exs = exemple.objects.filter(date_field__lt=datetime.timedelta(days=-365*f('year_field'))+datetime.datetime.today().year) i think problem f() isn't yet value @ moment timedelta called thanks advance solution, or idea might help that's problem. can't complex calculations orm. however, might able take advantage of __year lookup simplify math: exemple.objects.filter(date_field__year__lt=f('year_field')) anything...

How to open layout on button click (android) -

how can open layout xml file when click on button in main.xml file? so if have main.xml has button sying click here , click it, opens second.xml file (layout). this tutorial explain need step step. first create 2 layout: main.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" > <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:textcolor="#000000" android:text="this activity 1" /> <button android:text="next" android:id="@+id/button01" android:layout_width="250px" android:textsize="18px" ...

Really strange error on mysql query -

i have query, , think talks itself: mysql> select id,email members email "%abraham.sustaita@gmail.com%"; +--------+----------------------------+ | id | email | +--------+----------------------------+ | 272118 | abraham.sustaita@gmail.com | +--------+----------------------------+ 1 row in set (0.69 sec) mysql> select id,email members email = "abraham.sustaita@gmail.com"; empty set (0.00 sec) mysql> select id,email members id = 272118; empty set (0.00 sec) the data exists, returns empty if use other like... when there such flagrant impossible sequence of queries, it's time think table (or index) corruption , run mysql check command. in case, running repair table members quick did trick.

php - How do you know what parameters/arguments to put in a closure? -

when closures have parameters (or how closures parameters work)? know use() used import variables outside anonymous function, parameter(s) of closure itself? an example of closures parameters currying: function greeter($greeting) { return function($whom) use ($greeting) { // greeting closed on variable return "$greeting $whom"; }; } $hello_greeter = greeter('hello'); echo $hello_greeter('world'); // print 'hello world'; the greeter function return "half-implemented" function start same greeting, followed whatever passed (e.g. person greet).

winforms - c# Check if any picture applied -

i'm trying show image folder user selected.and if slected record not have picture, show image called empty.png here's code wrote. how can change it fit wrote in explaination?(the top of question) string[] fileentries = directory.getfiles(@"c:\projects_2012\project_noam\files\proteinpic"); foreach (string filename in fileentries) { if (filename.contains(combobox1.selecteditem.tostring())) { image image = image.fromfile(filename); // set picturebox image property image. // ... then, adjust height , width properties. picturebox1.image = image; picturebox1.height = image.height; picturebox1.width = image.width; } } i don't think need iterate through every file in directory acheive want image image; string imagepat...

Django - How can I set/change the verbose name of Djangos User-Model attributes? -

i'm building website contains several languages. therefore need set verbose names of attributes in model classes (with internationalizaton-helper). unfortunately don't find way change verbose names of user attributes... and overwriting every single form isn't nice way it, right? thanks help! ron it depends on need for. generally, verbose_name used within context of admin. if that's need worry about, can create proxy model , make user admin use that: from django.contrib.auth.models import user django.utils.translation import ugettext_lazy _ class customuser(user): class meta: proxy = true app_label = 'auth' verbose_name = _('my custom user') then, in admin.py: django.contrib.auth.admin import useradmin django.contrib.auth.models import user .models import customuser admin.site.unregister(user) admin.site.register(customuser, useradmin)

Send text and image to php with java -

this first question on stackoverflow, if have comment on way put/explain it, gladly accept pointers. so here is: i want sent both text , image php script on server. can succesfully sent both apart each other, not together. till use string: string datasend = urlencoder.encode("user","utf-8") +"="+urlencoder.encode(username,"utf-8"); url url = new url(urlcopyimage); urlconnection connection = url.openconnection(); connection.setdooutput(true); outputstreamwriter out = new outputstreamwriter(connection.getoutputstream()); out.write(datasend); out.close(); for image use: url url = new url(urlcopyimage); urlconnection connection = url.openconnection(); connection.setdooutput(true); imageio.write(image,"png", connection.getoutputstream()); can somehow combine these two? in php script merely use $_post receive string , image use: $incomingdata = file_get_contents('php://input'); any ...

sql - What is the TSQL "FOR BROWSE" option used for? -

i working on query, , have found minimal documentation microsoft on tsql "for browse" option on select statement. i have seen browse documented option cursors, haven't been able find examples of using this, or reasons use browse on select statement. what reasons use browse in tsql select statement? i using sql server 2008 , 2012. as far can tell. appears interface implementing optimistic concurrency control within application 1 or more users accessing , updating data same source @ same time. appears work in conjunction compatible front end library ( db-library ). however, appear deprecated mechanism can achieve of above without using " for browse " statement. can further confirmed necessity create 2 dbprocess structures results of db-library (a deprecated c library) call " dbopen ". in addition, browse mode requires 2 dbprocess structures: 1 selecting data , updating based on selected data. src here example of using ...

facebook - Like button will not fire edge.create or edge.remove -

i'm beginner.... i can't edge.create or edge.remove fire when button clicked. see others have posted problem too, going 2011, no solution can see. my code follows.... <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>untitled document</title> </head> <body> <div id="fb-root"></div> <script> (function(d, s, id) { var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) return; js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/all.js#xfbml=1&appid=xxx"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk')); fb.event.subscribe('edge.create', function(response) { alert('you liked url: ' + response); } ); fb.event.subscribe('edge.remove', function(response) { alert('you unliked url: ' + response);...

geometry - Python scikits learn - Separating Hyperplane equation -

a separating hyperplane's equation w.x + b = 0 . for support vector machine in scikit-learn , how separating hyperplane derived? ' a ' , ' w ' signify? in scikit-learn coef_ attribute holds vectors of separating hyperplanes linear models. has shape (n_classes, n_features) if n_classes > 1 (multi-class one-vs-all) , (1, n_features) binary classification. in toy binary classification example, n_features == 2 , hence w = coef_[0] vector orthogonal hyperplane (the hyperplane defined + intercept). to plot hyperplane in 2d case (any hyperplane of 2d plane 1d line), want find f in y = f(x) = a.x + b . in case a slope of line , can computed a = -w[0] / w[1] .

iphone - MPMoviePlayerController existed black background -

make ios app. use mpmovieplayercontroller, shows black background. think problem can solve url, can't understand use way. mpmovieplayercontroller background color won't stick code this. nsstring *path = [[nsbundle mainbundle] pathforresource:@"movie_files" oftype:@"m4v"]; nsurl *videourl = [nsurl fileurlwithpath:path]; movieplayer = [[mpmovieplayercontroller alloc] initwithcontenturl:videourl]; //setting movieplayer.scalingmode =mpmoviescalingmodeaspectfit; movieplayer.controlstyle=mpmoviecontrolstyledefault; movieplayer.shouldautoplay=no; [movieplayer.view setframe:cgrectmake(20, 20, 280, 200)]; //notification [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(movieplaybackdidfinish:) name:mpmovieplayerplaybackdidfinishnotification object:movieplayer]; //clearcolor uiv...

Fortran array of variable size arrays -

a simplified description of problem: there maxsize people shopping in store. each of them has shopping list, containing price of items (as integers). using fortran arrays, how can represent shopping lists. shopping lists may contain any number of items (1, 10, 1000000000). (note: actual problem far more complicated. not shopping.) the lazy approach be: integer :: array(maxsize, a_really_big_number) however, wasteful, want second dimension variable, , allocate each person seperately. the obvious attempt, doomed failure: integer, allocatable :: array(:,:) allocate(array(maxsize, :)) ! compiler error fortran seems require arrays have fixed size in each dimension. this wierd, since languages treat multidimensional array "array of arrays", can set size of each array in "array of arrays" seperately. here does work: type array1d integer, allocatable :: elements(:) ! compiler fine this! endtype array1d type(array1d) :: array2d(10) integer :...

git - What does "commit your changes or stash them" mean? -

i have branch on git repository used commit , push. today saw different programmer committed , pushed branch. when try pull latest branch git completes half way , gives error "either commit changes or stash them". have no idea means , don't want commit before taking latest changes on branch. how solve issue? it means have uncommitted changes, prevents pulling. and solve either committing them or stashing them. error message says. (by way, typically better answers asking precise questions. if want know git stash is, ask that . asking "how solve problem git tells me commit or stash" leads answers "you should commit or stash". git has answered question. if didn't understand that answer, ask part don't understand.

android - ProgressBar Animation -

i want use different animations in 1 progressbar. code init , set animation: progressbar = (progressbar) this.view.findviewbyid(r.id.progressbar); progressbar.setindeterminate(true); progressbar.setindeterminatedrawable(this.getresources().getdrawable(r.anim.progress_small)); when want code, working well, when set new animation `progressbar.setindeterminatedrawable(this.getresources().getdrawable(r.anim.progress_small))` it doesn't work. how use 1 progressbar more animation?` you retrieving animation resources getdrawable() . i may mistaken, don't think there way 'animate' progress changes in progress bar other changing progress in steps desired value. wrote sample code similar question .

struts2 - How can i access a parameter passed by an action in javascript? -

i'm using struts2 , have code triggers after action performed (via ajax): dojo.event.topic.subscribe("cambioproyecto", function() { var hola = json_entregables; alert("hola"); } the *json_entregables* variable parameter given via struts2. can access in jsp, no problem. can't in script. problem? i figured out way gat wanted it's rather unclean. since anonymous function callback function ajax process, captured response defining parameter function. response string actual html of response. now, access parameter, have include value inside jsp hidden element. this: <s:hidden id="hidden_json_entregables" value="%{json_entregables}"/></p> then, got through jquery this: dojo.event.topic.subscribe("cambioproyecto", function(jsp) { var o = $(jsp) var string_entregables = o.find("#hidden_json_entregables").text(); } anyway, don't think ...

how to get profile pic for foursquare user based on the object -

Image
there contradiction in api documentation: on 1 location: https://developer.foursquare.com/docs/responses/user on location, trying out: https://developer.foursquare.com/docs/explore#req=users/self https://irs3.4sqi.net/img/user/hbvx4t2wqogg20fe.png returning internal error. how can profile pic of user? a couple of days ago endpoint returned string profile pic, has changed, can't find documentation on that. edit: also tried adding consumer_key between prefix , suffix like: https://irs3.4sqi.net/img/user/consumer_key/hbvx4t2wqogg20fe.png also gave internal error. this part of change foursquare did api on june 9th. note ak foursquare announced making lot of changes, not documented in coming time, see post here: https://groups.google.com/forum/#!topic/foursquare-api/mpnpdo5zaru to fix, lower 'v' before 20120609, using 20120608 work. returns following url: https://is0.4sqi.net/userpix_thumbs/hbvx4t2wqogg20fe.png user :) another way fix use...

C# extension method for setting to new instance if null -

i have following extension methods me check , instantiate objects if null. top 2 work fine not useful. public static bool isnull<t>(this t t) { return referenceequals(t, null); } public static t newifnull<t>(this t t, func<t> createnew) { if (t.isnull<t>()) { return createnew(); } return t; } public static void ensure<t>(this t t, func<t> createnew) { t = t.newifnull<t>(createnew); } ultimately like ilist<string> foo; ... foo.ensure<ilist<string>>(() => new list<string>()); the ensure method not achieve desired effect, setting foo instance of list<string> if null , set otherwise. if know can tweak ensure method achieve appreciate help. thanks, tom you need distinguish between objects , variables . object can never null - value of variable can be. you're not trying change object (whic...

objective c - Copy image from assets-library to an app folder -

i have uiimagepickercontroller , save selected image app. can easy getting current uiimage , save (by creating file) prefer directly copy file library folder. have url of selected image : uiimagepickercontrollerreferenceurl return specific pattern "assets-library". tried copy image kind of url path without success. is there way success on ? ! you can through 2 ways first way: using imagepickercontroller didfinishpickingmediawithinfo delegate - (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { uiimage *selectedimage = [info valueforkey:uiimagepickercontrolleroriginalimage]; //save selectedimage document directory } second way: using alassetlibrary . for have save alasset url , retrieve image using alassetlibrary , please refer my answer details .just put alasset url instead of asseturl

php - Trying to download a file using curl where file download is blocked by javascript? -

i trying use curl download torrent file url is http://torcache.net/torrent/006ddc8c407accdaf810bcff41e77299a373296a.torrent you notice upon getting page download of file blocked few seconds via javascript, wondering if there anyway bypass while using curl , php? thanks the file not blocked via javascript, that's informal message if request file. redirect done via javascript. you can simulate request own, important part here add http referrer request header. example: $ curl -i -h 'referer: http://torcache.net/torrent/006ddc8c407accdaf810bcff41e77299a373296a.torrent' http://torcache.net/torrent/006ddc8c407accdaf810bcff41e77299a373296a.torrent http/1.1 200 ok server: nginx/1.3.0 date: sun, 10 jun 2012 17:13:59 gmt content-type: application/x-bittorrent content-length: 10767 last-modified: sat, 09 jun 2012 22:17:03 gmt connection: keep-alive content-encoding: gzip accept-ranges: bytes referrer 1 thing check, mind typo in http specs, see wikipedia. ...

ruby on rails - Displaying website when not logged in, and displaying app when logged in -

i have website , rails app. when user goes website, want check if logged in or not. if are, want send them rails application. if not logged in want send them website. pivotaltracker.com has type of behavior. what's best way go this? figure rails app needs log in check seems user should sent there first , redirect website if not logged in? but seems more not result display website, seems adds step, , slows things down majority of users. i'm not sure how else it. any ideas? check app session cookie in web server layer of web site, send them app if have it, continue web site if not. of course, app implement actual check find logged-in users , redirect web site if smells funny. yes, it's more complex. or, stop trying optimise things before measure them. "it seems" implies haven't checked numbers happens more often. (that came off snarkier intended. i'm trying remind "premature optimisation", not trying yell @ it.)

java - Continue maven build although dependency is missing -

is there way tell maven continue build although dependency ist missing? tried <optional>true</optional> doesn't seem in scenario. i have build costum maven plugin package phase , still have package if 1 or multiple dependencies not found. thanks in advance. <optional>true</optional> optional means client using library not need dependency. example spring's orm module, has optional dependencies hibernate, jdo, jpa , mybatis. nobody ever use of these in project, each marked optional. your case different, trying compile something, , can if libraries compile against present. sorry, don't work that.

datetime - Java convert date to EST timezone to respecting DST -

i want current date converted america/montreal timezone. i'm doing this: date date = new date(); timezone timezone = timezone.gettimezone ("america/montreal"); calendar cal = new gregoriancalendar(timezone); cal.settime(date); string whatiwant = "" + cal.get(calendar.hour_of_day) + ':'+ cal.get(calendar.minute)+ ':'+ cal.get(calendar.second); log.info(whatiwant); the conversion fine wondering how robust code is. happen when in no daylight saving? that code fine. java automatically takes winter time or summer time account. you using dateformat object convert date string, setting desired time zone on dateformat object: date date = new date(); dateformat df = new simpledateformat("hh:mm:ss"); // tell dateformat want time in timezone df.settimezone(timezone.gettimezone("america/montreal")); string whatiwant = df.format(date);

How to execute an Ant task only if a file is changed? -

i have been trying use following code task working if file changed doesn't seem work. task called irrespective of whether there change or not. <target name ="widget-change" depends="configuration-for-widgets"> <fileset dir="${src-location}"> <include name="com.myapp.mainclasses.myclassone.java"/> <include name="com.myapp.mainclasses.myclasstwo.java"/> <modified update="true"/> </fileset> <antcall target="gwt-compile"/> </target> are using ant version less 1.8.0? in getting ant selector work properly , asker resolved using depend selector instead of modified. in ant bug 32958 , workaround suggested use nested update param : you may able work around using nested <param name="update" value="false"/> instead of update attribute.

java - Calendar class: set to ten days from now -

i have following 2 methods: private long gettimeinmilliseconds() { calendar c = calendar.getinstance(); if(c.get(calendar.day_of_month) == 21) { c.set(calendar.month, calendar.month + 1 ); c.set(calendar.day_of_month, 1); } else c.set(calendar.day_of_month, calendar.day_of_month + 10); if(c.get(calendar.month) > 11) c.set(calendar.month, 0); return c.gettimeinmillis(); } public static void remainingtime(l2pcinstance player) { long = system.currenttimemillis(); long = player.getexpboosttime(); long time = - now; int hours = (int) (time / 3600000); player.sendmessage(hours+ " hours remaining until exp boost period ends"); } i want gettimeinmillisseconds() return time 10 days later. want remainingtime() show how many days (in hours) remain. with code above, shows 4 days remaining , not 10. can ...

multithreading - Can I check for null on a shared field outside of a synchronized block in java? -

let's have field can accessed 2 separate threads. i'm using object synchronization lock. can check null outside of synchronization block? in other words, thread-safe: private object sharedobject() = new object(); private final object sharedobjectlock() = new object(); private void awesomemethod() { if(sharedobject != null) { synchronized(sharedobjectlock) { //code uses sharedobject } } } no. assignment of variable occur after check before lock. there was, @ 1 time, school of thought synchronized locks expensive, that's not true anymore. grab lock.

Dynamic parsing of xml with xslt -

i parsing dynamic (folder.subfolders) xml xslt, tried few things i'm not there yet. here structure of xml have: <folders> <folder> <folderid>2edfb864-5693-4e7f-8f98-4ef6e032d8a5</folderid> <name>bla</name> <foldersize>33kb</foldersize> <lastmodified>2012-06-07 11:11:02</lastmodified> <subfolders /> <files> <file> <fileid>1825</fileid> <name>img_15052012_142711.png</name> <size>33kb</size> <extension>png</extension> <lastmodified /> </file> </files> </folder> <folder> <folderid>c9c5e2b2-ee93-49a2-b8be-d86e41528071</folderid> <name>testfolder</name> <foldersize>0kb</foldersize> <lastmodified>2012-06-05 00:00:00</lastmodified> <...

transparency - How to create a transparent image with text using GIMP from command line interface -

yes, want use gimp create transparent image text on ubuntu box. please help. you can call gimp command line single "script-fu" expression, using -b switch (for "batch"). creating image text in gimp multi-step process, have to: create image create text layer add text layer image adjust image size layer size save image each of these steps call gimp's pdb api, can browsed going help->procedure browser there "logo" scripts automate steps 1-4, , add (sometimes) nice effects, script-fu-basic1-logo procedure - won't save image file in same step. threfore, have write small scheme - or python - script perform steps want to, , invoke gimp on command line calling script of yours.

c# - Sockets starts to slow down and not respond -

i developing server (with c#) , client (with flash, actionscript 3.0) application. server sends data (datas arround 90 bytes) clients continuously , clients behave according data received (data json formatted) for while, works expected after time passed, clients start receive messages laggy. keep waiting time , behave according last message (some messages lost). after time passed clients starts wait , process messages @ same time. not figured out causing this. network condition stable. here part of c# code, sending message: public void send(byte[] buffer) { if (clientsocket != null && clientsocket.connected) { clientsocket.beginsend(buffer, 0, buffer.length, 0, writecallback, clientsocket); } } private void writecallback(iasyncresult result) { // } and part of client, receiving message (actionscript) socket.addeventlistener(progressevent.socket_data, onresponse); function onresponse(e:progressevent):...

c# - Selecting all check boxes using header check box in grid of asp.net -

it tried many solutions nothing worked. please provide me jquery code select check boxes of current page of gridview checking checkbox in header template. using asp.net 4 using c#. detailed guidance highly appreciated. demo replace div.gridview selector container of of checkboxes in current page. hope helps.

sql - How to search multiple columns with one variable -

i want search 1 table, , multiple columns using 1 variable. code looks this: select lcustomerid, slastname, sfirstname, saddress1, saddress2, scity, sstate, szipcode , @search expr1 customers (slastname = n'includes @search') or (sfirstname = n'includes @search') , (sbarcode = n'includes @search') i want include string not = assuming meant have ors, , "i want include string" means want partial match (e.g. search "john" yields "johnson" , "rojohn"), looking keyword: where slastname n'%' + @search + '%' or sfirstname n'%' + @search + '%' or sbarcode n'%' + @search + '%';

html - Z-index doesn't work. Popup is hidden under a layer -

i helping maintain website http://www.groupme.my/national/ for deals long list of options, when click on "buy now" button, options list popup partially covered deal below. example, click on "buy now" button deal "[55% off] korean style handbag...". please note not every deal comes options. if there no options, clicking on "buyw now" bring shopping cart directly. i have tried put in z-index, doesn't seem anything. please check how can resolve problem. thanks. if understand concern correctly, element fades in has bottom edge behind item beneath, right? if problem z-index isn't going because thing fading in being attached div (and going above it) going behind div sits on page *after 1 fading 1 being attached to, so, fading div going behind next one, no matter what. the easiest way deal draw them in opposite order, divs moving towards ztop go up, or put way, set z-order in reverse order how they're drawn, if have ...

java - Maven Gae Jsf2 ExternalizeJavaScript Warning -

i using maven, google app engine, jsf2 in 1 project. however, there happens exception below: warning: failed jettycontainerservice$apiproxyhandler@dfd2cd: java.lang.nosuchfielderror: externalizejavascript haz 13, 2012 8:32:41 com.google.apphosting.utils.jetty.jettylogger warn warning: error starting handlers java.lang.nosuchfielderror: externalizejavascript @ com.sun.faces.config.processor.lifecycleconfigprocessor.addphaselisteners(lifecycleconfigprocessor.java:132) @ com.sun.faces.config.processor.lifecycleconfigprocessor.process(lifecycleconfigprocessor.java:115) @ com.sun.faces.config.processor.abstractconfigprocessor.invokenext(abstractconfigprocessor.java:108) @ com.sun.faces.config.processor.factoryconfigprocessor.process(factoryconfigprocessor.java:133) @ com.sun.faces.config.configmanager.initialize(configmanager.java:204) @ com.sun.faces.config.configurelistener.contextinitialized(configurelistener.java:200) @ org.mortbay.jetty.handler.context...

.net - Is there a global touch status in WPF? -

as easy listen touch events in wpf, there way tell if user touching screen or not ? you can check areanytouchesover on uielement… including window. window.areanytouchesover tell if user touching window. there not wpf api know if user touching appplication.

css - Specifying different font-sizes for different font-families -

is there way specify different font-size different font-family. font want use(for purposes of product branding) rare font (flashdlig) not supported pc's , browsers. (my 1 windows 7 pc ie 9 not display it...) fallback font use arial, problem arial larger flashdlig, want specify different font-size in same class. possible? i know can use font-size-adjust supported in firefox. any suggestions? javascript magic maybe? thanks have @ following code examples: http://www.lalit.org/lab/javascript-css-font-detect/ and http://remysharp.com/2008/07/08/how-to-detect-if-a-font-is-installed-only-using-javascript/ and adjust stylesheet result of detection. i've used these time ago results. good luck! :)

linux - Errors while installing OpenCV and FFMPEG through Rightscripts -

i writing rightscript install opencv-2.3.1 on linux server. using ffmpeg package: ffmpeg-0.7-rc1 i doing whatever did while installing manually on server, getting errors when try booting box using rightscripts. opencv installs , works fine when built manually through bash. the errors getting are: in file included /opencv-2.3.1/modules/highgui/src/cap_ffmpeg.cpp:45: /opencv-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: in member function 'void cvcapture_ffmpeg::close()': /opencv-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:451: warning: 'void av_close_input_file(avformatcontext*)' deprecated (declared @ /usr/local/include/libavformat/avformat.h:1533) /opencv-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:451: warning: 'void av_close_input_file(avformatcontext*)' deprecated (declared @ /usr/local/include/libavformat/avformat.h:1533) /opencv-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp: in member function 'bool cvcapture_ffmpeg::reopen()': /ope...