Posts

Showing posts from August, 2012

ruby - Rails Concatenated Query Result "where" -

i have concatenated 2 query results , limit results based on particular criteria. def all_notifications return (user_project_notifications+followed_comments).sort_by(&:created_at).reverse end i'd limit all_notifications come after time, like: def new_notifications(notifications_last_viewed) return all_notifications.where('created_at >?, notifications_last_viewed) end however, i'm getting error undefined method `where' array:... how can perform "where" query on concatenated result? you can't directly, because after apply 1 of typical array (or enumerable ) methods (for example "+") on activerecord::relation , returns array instance, doesn't have activerecord methods. i think should fetch user_project_notifications , followed_comments in 1 query "or" - have activerecord::relation instance, on can call scope methods, order or where .

c# - Entity Framework / Linq - Get distinct values of dynamically specified property -

i have requirement list of distinct values specific properties of collection of entities. so, let's table has fields x, y, z, 1, 2, 3 x pk(thus off table). i need unique values y, z, 1, 2, or 3, without knowing in method field i'm getting. pattern method be: public list<objectname> getuniquefieldvalues(string fieldname) the "objectname" object object 2 properties, method above fill @ least 1 property per result. someone in question had similar answer using parameterexpression , expression classes didn't provide enough information me specific task. i tried reflection of course linq not within select expression. i use if , call there ton of fields/properties in actual table/object it's impractical. save me little refactoring if base table ever changes. sql version of i'm trying do: select distinct [usersuppliedfieldname] tablename [someotherconditionsexist] pseudocode of have: public list<returnobject> getuniquefieldva...

Ruby on Rails: Access values from form in controller -

how values in form input fields below iterating through ans[n] n = 1...3 in controller? <input type="text name="ans[1]" value="test 1"> <input type="text name="ans[2]" value="test 2"> <input type="text name="ans[3]" value="test 3"> you can loop on params doing in controller: #controller params[:ans].each |value| puts value # should print values each input end if params[:ans] array of hashes, can access attributes this: params[:ans].each |answer_attributes| puts answer_attributes['1'] end

php - jQuery plugin not loading in WordPress -

i've linked jquery wordpress within functions.php . however, appears center.js not loading. this, because console giving me error: uncaught typeerror: object [object object] has no method 'center' i calling scripts <?php wp_head(); ?> within header.php . here functions.php : <?php function add_google_jquery() { if ( !is_admin() ) { wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"), false); wp_enqueue_script('jquery'); } } add_action('wp_print_scripts ', 'add_google_jquery'); // added jquery function add_google_center() { if ( !is_admin() ) { wp_register_script('center', ("http://jquerydevbrazil.googlecode.com/svn/trunk/jquery.center.js"), false); wp_enqueue_script('center'); } } add_action('wp_print_scripts_center ', 'add_google_center'); se...

android - Listview Text Font -

i can't seem find looking for. i know how change textview fonts in listviews. have text font when try apply code works 1 textview1 etc. i have been reading need custom adapter change listview styles don't know start new android , coding. guess looking site me started if can help. custom style listview dummies lets ;) there tons of information , tutorials on creating custom listviews . i'll link tutorials here have found needed doing little bit more searching. creating custom adapter , listview 1 creating custom adapter , listview 2 if have questions or run trouble these willing help.

java - Why does my sprite flash in LibGDX? -

i'm trying create main menu using sprite. however, when gets rendered , everything, sprite flashes quickly. why doing this? @override public void show() { batch = new spritebatch(); texture = new texture("ui/mainmenu.png"); mainmenu = new sprite(texture); mainmenu.setsize(gdx.graphics.getwidth(), gdx.graphics.getheight()); batch.begin(); mainmenu.draw(batch); batch.end(); } @override public void render(float delta) { gdx.gl.glclearcolor(0, 0, 0, 1); gdx.gl.glclear(gl20.gl_color_buffer_bit); } this goes in render method: batch.begin(); mainmenu.draw(batch); batch.end(); render method called, show called once when screen shown.

wordpress - Sanatize title in url php -

i'm trying search based on title. like this: $alfred = get_the_title(); $link11 = "http://example.com/?s=$alfred"; the problem is: when title is account manager (m/w) software- / it-lösungen (non microsoft) it makes url: jobsde.de/?s=accountmanager%28m/w%29software-/it-l%c3%b6sungen%28nonmicrosoft%29 or when title recruiting consultant (m/w) it becomes jobsde.de/?s=recruitingconsultant%28m/w%29 the wordpress search not give me results want. think there must way handle properly, don't know how. thoughts? i found this i have: $title = get_the_title(); sanitize_title_for_query( $title ); $link5 = "http://jobsde.de/?s=$title"; that doesnt work. url still looks like: jobsde.de/?s=handelsvertreterphotovoltaiksolarw%c3%a4rmepumpephotovoltaikberatersolarberater what code should use? have @ urldecode this return encoded characters defaults

nsuserdefaults - iOS Saving User Configuration -

i working ios app require user configure part of app , configuration must saved in event user turns on/off part of app. once app backgrounded, users-configuration must removed security purposes. my question best way save strings , nsintegers temporarily , removing them when time comes. nsuserdefaults nscache i have looked both , unable come solid conclusions. there way missing might better? thanks! -brian if want settings available while app in foreground, don't store them in nsuserdefaults . nsuserdefaults persist between app launches , removed when user deletes app. for temporary storage, consider storing key/value pairs in simple nsmutabledictionary . clear dictionary in application delegate's applicationwillresignactive method ensure values cleared when app moved background. while nscache key/value store similar dictionary, app clear nscache if receives low memory warnings. store non-critical (re-creatable) data in nscache .

problems with http file upload to wcf-rest service -

i upload file using form this: <form action="http://127.0.0.1:8090/myservice/" method="post" enctype="multipart/form-data"> <p>select file<br> <input name="datei" type="file" size="50"> <input type="submit" value="submit"> </p> </form> and have wcf service this: [servicecontract] public interface idocumentconverter { [operationcontract, webinvoke(uritemplate = "/", method = "post")] void uploadfile(stream filecontents); } i have 2 problems this. when write stream file not contain file data http stuff. seems odd. there nice way raw file data?: -----------------------------67832811011758 content-disposition: form-data; name="datei"; filename="haha.jpg" content-type: image/jpeg ÿØÿà... the original file looks this: ÿØÿà... secondly have filename in wcf. ideally this: [s...

Mix of query and form params in REST service? -

we have rest api which, operations, provide option of asynchronous requests. async requests, service return token can used query completion, while synchronous requests, response not returned until operation completes. the current design looks this: url: put /api/orders/1234?async=true request body: customername=my company&city=dallas intuitively, seems wrong mix query , form params this, query param (async) providing options service call , not attribute of resource. primary reason did not include in request body. does approach seem design, or there better more "rest-y" way accomplish same? the prefer header designed trying do. see spec .

Click on any one of "1 2 3 4 5 ..." on a page by using Selenium in Python (e.g., Splinter): -

i have html looks 3 following sample statements: <a href="javascript:__dopostback('ctl00$formcontent$gvresults','page$10')">...</a> <a href="javascript:__dopostback('ctl00$formcontent$gvresults','page$12')">12</a> <a href="javascript:__dopostback('ctl00$formcontent$gvresults','page$13')">13</a> (i'd presently on pg. 11.) i don't know py/selenium/splinter syntax selecting 1 of page numbers in list , clicking on go page. (also, need able identify element in argument as, example, 'page$10' or 'page$12', seen in __dopostback notation. maybe 'next page', in many words, fine, don't know how that.) thank help. update ii: here's code have work from: import time import win32ui import win32api import win32con selenium import webdriver selenium.webdriver.common.keys import keys ctypes import * selenium.webdriver.common.by i...

linux - How can I see the list of available merge tools for git on the command line? -

i using git on virtual machine ubuntu server running command-line , don't know vim (and frankly don't want learn right now) don't want use vimdiff. how can list of available merge tools git? bonus points list of merge tools usable command line don't have of steep learning curve! just run without tool value: $ git mergetool --tool= merge tool candidates: meld opendiff kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse ecmerge p4merge araxis bc3 vimdiff emerge i'll leave bonus points documentation :/

sockets - Efficiently retrieve IP address and status code -

just practical question. need retrieve http status code of site ip address. given fact need parse between 10k , 150k domains, wondering efficient method. i've seen using urllib2.urlopen(site) attempts download entire file stream connected file. @ same time urllibs2 doesn't offer method convert hostname ip. given i'm interested in head bit collect information http status code , ip address of specific server, best way operate? should try use socket? thanks i think there no 1 particular magic tool retrieve http status code of site , ip address. for getting http status code should make head request using urllib2 or httplib or requests . here's example, taken how send head http request in python 2? : >>> import urllib2 >>> class headrequest(urllib2.request): ... def get_method(self): ... return "head" ... >>> response = urllib2.urlopen(headrequest("http://google.com/index.html")) an exa...

php - facebook login using oauth -

<?php require "facebook.php"; $facebook = new facebook(array( 'appid' => '3288@@@@@@@@@@', 'secret' => 'ca2@@@@@@@@@@@@@@@@@@', )); $user = $facebook->getuser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (facebookapiexception $e) { $user = null; } } ?> <?php if ($user): ?> <form action="#" method="get"> name: <input type="text" name="name" value="<?php echo $user_profile['name'] ?>"><br> kid's name <input type="text" name="kid"><br> dob <input type="text" name="kid" value="<?php echo $user_profile['birthday'] ?>"><br> address <input type="text" name="kid" value="<?php echo $user_profile['email'] ?>...

Automatically create the schema in PostgreSQL with Fluent NHibernate -

how create database schema automatically in fluent nhibernate? configuration is: public static isessionfactory createdatabase() { switch (4) { case 4: // postgress _sessionfactory = fluently.configure() .database(postgresqlconfiguration.postgresql82.connectionstring(connectionstring)) .exposeconfiguration(c => { c.setproperty("cache.use_second_level_cache", "false"); c.setproperty("cache.use_query_cache", "false"); }) .exposeconfiguration(schemametadataupdater.quotetableandcolumns) .exposeconfiguration(x => new schemaupdate(x).execute(false, true)) .mappings(m => m.fluentmappings.addfromassemblyof<pessoa>()) .currentsessioncontext<websessioncontext>() .buildconfiguration() .buildsessionfactory(); break; } _sessionfactory.dispose(); return _sessionfactory; } currently have method creates using npgsqlcommand. to create s...

java - Scene2d suitable for non-UI display? -

i'm using libgdx (and subsequently scene2d) develop sidescroller game. know there's lot of user interface things built (buttons, text fields, labels, tables, etc.), wondering, suitable render actual 2-dimensional game in scene2d? i way handles groups , actors, wasn't sure if built-in collision detection interfere box2d physics simulation. i wouldn't use actors represent sprites, rather sprite class, actor class more receiving input , animating, , background static in sidescroller. collision detection outside box2d simulation should unnecessary think. physics engine there simulate collision detection , response you.

php - Break query data into several files -

i want table database , break output data files (50 entries in each file): list01.txt, list02.txt... somehow got stacked @ question how break data more effectively. if ( $result = $mysqli->query($query) ) { icount = 0; while ( $row = mysqli_fetch_array($result) ) { if ( icount % 50 == 0 ) { $snum = int( icount / 50 ); $filename = 'scripts/spisok'.$snum.'.txt'; $handle = fopen( $filename, 'w' ); } fwrite( $filename, $row['uname'].';'.$row['email'].'<br />' ); icount++; } echo 'ok'; $result->free(); } can break $result 50-entry arrays first , write them all? sorry, im novice php you can use array_chunk <?php if ( $result = $mysqli->query( $query ) ) { $data = array(); while( $row = mysqli_fetch_array( $result ) ) { $data[] = $row['uname'].';'.$row['email'];...

hash in url to deep linking with ajax -

i've code load content in div #target animation. works fine don't know how implement code change link , url #hash! how can this? the code: $(document).ready(function(){ $("#target").addclass('hide'); $('.ajaxtrigger').click(function() { var pagina = $(this).attr('href'); if ($('#target').is(':visible')) { } $("#target").removeclass('animated show page fadeinrightbig').load(pagina, function() { $("#target").delay(10).transition({ opacity: 1 }) .addclass('animated show page fadeinrightbig'); } ); return false; }); }); try use javascript router. example, router.js . modify code this(i didn't check if code work, think idea should clear): $(document).ready(function(){ var router = new router(); //define route link router.route('/loadpath/:href', function(href) { ...

javascript - Three.js Particle System different texture for each particle -

in three.js have 1000 particles , 2 different textures loaded in. var particlecount = 1000; var texture1 = three.imageutils.loadtexture( 'texture1.png' ); var texture2 = three.imageutils.loadtexture( 'texture2.png' ); var customuniforms = { texture: {type: "t", value: texture1} // how set value per particle? }; var customattributes = { customcolor: {type: "c", value: []}, customsize: {type: "f", value: []} }; for(var p = 0; p < particlecount; p++ ) { customattributes.customcolor.value[p] = new three.color(0xffffff * math.random()); customattributes.customsize.value[p] = size; // .. place particle , push particles code } var shadermaterial = new three.shadermaterial({ uniforms: customuniforms, attributes: customattributes, vertexshader: document.getelementbyid( 'vertexshader' ).textcontent, fragmentshader: document.getelementbyid( 'fragmentshad...

HTML and CSS- Vertical scroll bar not shrinking/resizing in window of fixed height/width containing content -

so trying make website , have popup window/box appears after clicking something. popup window contains text/content, let's name "locations," per website's design. locations popup box has fixed height , width, , consequently, there vertical scroll bar i've created scroll down , read text. add more content popup unfortunately, text being cutoff, , scroll not continue scrolling down. more specific, how can add in or change such vertical scroll re-size/shrink accommodate text adding? currently, text cutoff in window, , cannot scroll down read it. in correct applications of vertical scroll bar integration, understanding, scroll bar should re-size text until end can scrolled , read. please let me know if other code snippets necessary this. below css it: /* pop */ #popupabout, #popuplocations, #popupcontact, #popupblog { height: 600px; width: 900px; overflow: scroll; background-color: rgba(0, 0, 0, 0.75); border: 2px solid #cecece; z-index: ...

meteor - Exception from setTimeout callback: { stack: [Getter] } and Mongo error -

i'm getting following exception thrown: => meteor server restarted i20130820-00:17:58.852(3)? exception settimeout callback: { stack: [getter] } mongoerror: $or requires nonempty array i20130820-00:17:58.852(3)? @ object.future.wait (/home/alexei/.meteor/tools/4010e5731d/lib/node_modules/fibers/future.js:326:15) i20130820-00:17:58.853(3)? @ _.extend._nextobject (packages/mongo-livedata/mongo_driver.js:540) i20130820-00:17:58.853(3)? @ _.extend.foreach (packages/mongo-livedata/mongo_driver.js:570) i20130820-00:17:58.853(3)? @ _.extend.map (packages/mongo-livedata/mongo_driver.js:582) i20130820-00:17:58.853(3)? @ _.extend.fetch (packages/mongo-livedata/mongo_driver.js:606) i20130820-00:17:58.853(3)? @ _.each.cursor.(anonymous function) [as fetch] (packages/mongo-livedata/mongo_driver.js:444) i20130820-00:17:58.854(3)? @ mongoconnection.findone (packages/mongo-livedata/mongo_driver.js:362) i20130820-00:17:58.854(3)? @ _.extend.findone (packages...

actionscript 3 - TypeError: Error #2007: Parameter hitTestObject must be non-null. Why -

so im trying make bullet-ship hittestobject ,but don`t know why variable representing bullets.length doest change. so error comes function function doships() { trace("bcount :" + bcount) trace("_bulletsarray length:" + _bulletsarray.length) (var i:int = shiparray.length - 1; >= 0; i--) { shiparray[i].movedown() //what code in ship , ship2 class -> only: this.y += 3 (var bcount= _bulletsarray.length-1; bcount >= 0; bcount--) { //if bullet touching ship while (shiparray[i].hittestobject(_bulletsarray[bcount])) { //if here means there`s collision removechild(_bulletsarray[bcount]); _bulletsarray.splice(bcount,1); removechild(shiparray[i]); shiparray.splice(i,1); ...

indexing - R return the index of the minimum column for each row -

i have data.frame contains 4 columns (given below). want find index of minimum column (not value) each row. idea hiw achieve that? > d v1 v2 v3 v4 1 0.388116155 0.98999967 0.41548536 0.76093748 2 0.495971331 0.47173142 0.51582728 0.06789924 3 0.436495321 0.48699268 0.21187838 0.54139290 4 0.313514389 0.50265539 0.08054103 0.46019601 5 0.277275961 0.39055360 0.29594162 0.70622532 6 0.264804739 0.86996266 0.85708635 0.61136741 7 0.627344463 0.54277873 0.96769568 0.80399490 8 0.814420492 0.35362949 0.39023446 0.39246250 9 0.517459983 0.65895805 0.93662382 0.06762166 10 0.498319937 0.67081260 0.43225997 0.42139151 11 0.046862110 0.97304915 0.06542971 0.09779383 12 0.619009734 0.82363618 0.14514799 0.52858058 13 0.007262782 0.82203403 0.08573499 0.61094206 14 0.001602586 0.33241230 0.57762669 0.45285004 15 0.698388370 0.83541257 0.21051568 0.84431347 16 0.296088411 0.34363164 0.02179999 0.70551493 17 0.897869571 0.50625928 0.92861583 0.6...

permissions - linux how to allow user to read/write/delete files created from root in a specific folder -

i use automysqlbackup backup mysql database. the problem can run program using sudo automysqlbackup . program dumps backup folder /home/user/backup theses files owned root , when connect via ftp folder cannot delete or read them. is possible files created root in folder /home/user/backup can read/write/deleted user "user" ? or there way can run automysqlbackup user "user" ? couldn't write bash script, calls backup , changes permissions chmod ?

WCF & Basic Authentication -

i want configure basic authentication on iis7 hosting several wcf/asmx services, want clients store user name , passwords inside web.config file without modify client code, possible? you can configure iis7 basic authentication, authenticate against local users , groups rather web.config configuration file. i not recommend putting them in configuration file have go effort of encrypting passwords , have modify code use custom authentication method.

jquery - AJAX form submit Codeigniter -

i'm trying submit form using ajax / jquery view code igniter model. if post value has been passed model returns true. my view showing success message regardless. please point out i'm going wrong? here function controller: function bookings(){ $this->load->helper('url'); if($_post): echo $_post["name"]; // database stuff here save comment. // return false if db failed // else return true; endif; } here relevant javascript & form view: <div id="booking-form-container" class="fb-dialogue"> <div id="info">entery details below make group booking:</div> <!-- hold response / error message server --> <div id="response"></div> <form id="bookingsform" method="post" action="eventguide/bookings...

javascript - Angular JS: Why is my click event firing twice? -

i have following code. loops on json produce nested ul list. have click event executes function togglenav() bound anchor tag. don't know why click event bound twice element. new angular, there document explains concept out there? thanks! define([ '/assets/angularapp/appdirectives.js', 'highstock' ], function (directives) { directives.directive('collection', function () { return { restrict: "e", //declare element replace: true, scope: { collection: '=' }, template: "<ul class=\"nav nav-list tree\"><member ng-repeat=\"member in collection\" member=\"member\"></member></ul>" } }) directives.directive('member', function ($compile) { return { restrict: "e", replace: true, scope: { member: '=' }, template: "<li ng-show=\...

windows phone 7 - ListPicker within LongListSelector not retaining value after scrolling -

i developing wp7 app contains longlistselector. within itemtemplate there listpicker. select value listpicker first item in longlistselector, select value listpicker 2nd item. if scroll down page , top again, value selected in listpicker 1st item reset (selectedindex=0). i have put code in link , unlink events of longlistselector write output window , have found when 1st item unlinks (due scrolling down page), listpicker value selected link event fires (due scrolling page) 1st item value reset. im using obserablecollection , implement inpc interface objects , viewmodel updates when listpicker selection changed. how can ensure value in listpickers retaining during scrolling of longlistselector? mainpage.xaml <phone:phoneapplicationpage x:class="longlistselector.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:microsoft.phone.c...

Entity name conflicts in Visual Studio -

i'm new entity framework. i've created model-first schema in visual studio 2012 ef5, i'm having trouble getting generated code build. 1 of entities ("test") has same name model ( edmx ) , project ( csproj ) files, conflicts namespace (test namespace used type ). decided change namespace setting "custom tool namespace" .tt files. worked, found "test" entity's generated .cs file entirely empty (other entities generating properly), had build errors other entities reference "test". renaming entity results in generated class, , therefore building project, want use original name. i end scratching project , starting over, ensuring choose unique names project, model, , entity. i'd rather know how fix if possible in case run similar when project further along , it's not easy start over. you can use use alias on using directive, e.g. using project = pc.mycompany.project; differentiate between namespaces. see ...

c - Using printf without having to escape double quotes? -

in c not possible use ' printf of string. however, have text full of double quote " , , need escape of them as printf("this \"test\" \"text\""); is possible printf in way without escaping " . mean using character wrapping string. not recommended, can use macro: #include <stdio.h> #define s(x) #x int main() { printf(s(this "is" string (with nesting)!\n)); } this prints this "is" string (with nesting)! now delimiters balanced () characters. however, escape single ) , " , or ' characters, have write s(right paren: ) ")" s(!\n) , quite ugly. technique not recommended writing maintainable code.

c++ - Boost librairies not found but compilation is ok -

i trying use filesystem boost in c++ it seems compilation ok when using "c++ -c analyse.c -o analyse.o -g -w -wall -l/usr/local/lib -lboost_filesystem -lboost_system" however have following error when trying execute code : "error while loading shared libraries: libboost_filesystem.so.1.54.0: cannot open shared object file: no such file or directory", find / -iname "libboost_system.so.1.54.0 i had issues install boost (i first installed 1.49 , after 1.54) wondering if there conflict between 2 version ? p.s : btw "find / -iname "libboost_system.so.1.54.0" gave me following /usr/include/boost/boost_1_54_0/bin.v2/libs/system/build/gcc-4.7/release/threading-multi/libboost_system.so.1.54.0 /usr/local/lib/libboost_system.so.1.54.0 try add directory before execution. example: ld_library_path="/usr/local/lib/" ./analyse.o

jquery - cannot call javascript function inside click handler -

i have div loaded via ajax: <div id="container"> <a href="#" class="easyui-linkbutton submit_data">click here submit</a> </div> in same file in have div, have script this: <script> $(function(){ $('#container').on('click', 'a.submit_data', function(e){ e.preventdefault(); alert(test()); }); function test() { return 'this test'; } }); </script> the problem have when call function test() in callback of click event did above, error uncaught typeerror: undefined not function when click on button (so don't alert). if call test() function outside of click handler, works expected. dpes know why happening please? thank you does help? i'm not sure you're looking for. cleaned script , click event. codepen sketch jquery $('.submit-data').on('click', fu...

java - what is a good way to stop a thread in android -

i trying passthrough input obtained microphone speaker (the goal able perform audio processing in real time in future). code: public class mainactivity extends activity { audiomanager = null; audiorecord record =null; audiotrack track =null; final int sample_frequency = 44100; final int size_of_record_array = 1024; // 1024 original final int wav_sample_multiplication_factor = 1; int i= 0; boolean isplaying = true; class mythread extends thread{ @override public void run(){ recordandplay(); } } mythread newthread; private void init() { int min = audiorecord.getminbuffersize(sample_frequency, audioformat.channel_in_mono, audioformat.encoding_pcm_16bit); record = new audiorecord(mediarecorder.audiosource.voice_communication, sample_frequency, audioformat.channel_in_mono, audioformat.encoding_pcm_16bit, min); int maxjitter = audiotrack.getm...

objective c - UITableViewController with UISearchDisplayController not reloading data -

i have viewcontroller class appropriate .xib file. here viewcontroller code: viewcontroller.h: #import <uikit/uikit.h> #import <foundation/foundation.h> @interface viewcontroller : uiviewcontroller { nsarray *news; nsmutabledata *data; } @property (strong, nonatomic) iboutlet uitableview *maintableview; @property (strong, nonatomic) iboutlet uisearchbar *searchbar; @property (strong, nonatomic) results *result; @end viewcontroller.m: #import "viewcontroller.h" #import "results.h" @interface viewcontroller () @end @implementation viewcontroller @synthesize result, maintableview, searchbar; -(id) init { self = [super initwithnibname:@"viewcontroller_iphone" bundle:nil]; if (self) { result = [[results alloc] init]; maintableview = [[uitableview alloc] init]; [self.maintableview setdelegate:self]; } return self; } - (void)viewdidload { self.title = @"search...

javascript - facebook style menu implementation -

i trying put responsive site works on desktop/ipad/iphone/android tablet etc. i trying add in facebook style left hand menu - 1 has 3 lines when click menu slides in , , content moved over the problem having have set <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> so when slide in content extends viewport if set container have overflow hidden. know slide menu in on content not client wants i doing slide in of menu using css transitions , seems smooth rather jquery. has had similar problem / can suggest way round doing this? cheers dan so far have found this http://tech.xtremelabs.com/html5-facebook-style-sliding-menu-using-twitter-bootstrap-collapse/ this has working jsfiddle example

c# - How can you disable a.NET ImageButton control on the client side when the ImageButton has an onClick event handler? -

the purpose here prevent users clicking button multiple times during submit/click. i've tried different solutions button control not apply imagebutton. try following code: imgbutton.onclientclick = "this.disabled = true;"; this disable button @ client side pressed. (the syntax may off - can't test code right now.)

C99999 format in java to be used in sql -

i have number format "c99999" i need import sql i try this while (rs.next()){ int s=rs.getint("number"); s++; string n = string.format("%05d",s); view.txtcustomernumber.settext(n); how add "c" format , data type in mysql int just use "c%05d" format string.

php Object of class Closure could not be converted to string -

i'm creating search-function php-based file manager. i'm getting error: 'catchable fatal error: object of class closure not converted string' on following line: if ($data->input_ext) { $data_ext = ($begun ? ($data->input_logic ? ' or ' : ' , ') : function () { $begun = true; return ""; }) . 'ext = "' . $data->input_ext . '"'; $data_string.= $data_ext; } that's part of builds sql query. $begun_files determines whether or not put 'or' or 'and' @ beginning based on whether or not user input name or comes before match. have feeling i'm not allowed include anonymous functions in ternary expressions should instead? thanks! you can't use anonymous functions inline flow control; use regular if statement , don't shun writing things on multiple lines: if ($data->input_size) { if ($begun_files) { $str .= $data->inp...

ruby on rails - Writing Testcase in Rspec for Update method -

i writing rspec update method of controller updates record in table t given id id . here in spec want add case checks whether record id exists in table t , , if not exist, should give error following being new rspec not complete it. "should give error when record given id not exist" pending "case yet handled" end so if helps me in writing spec. you should pass parameter id , use correct http verb send request update action. i.e it "should give error when record given id not exist" put :update, id: <invalid_id> # expectations here end how learned test rails applications, part 4: controller spe has example , more explanation on controller tests.

sqlfire - Why won't this statement work? SQL -

Image
i using sqlfire. doing assignment , when beginning assignment came across couldn't return particular value. see sql fiddle, contains exact data in table using in assignment , contains sql statement have tried. fiddle: http://sqlfiddle.com/#!2/e761ac/1 what want outputted is: rate | rentalcode ----------------- 350 | wl i getting error when type code sql fire. i have been told not use order clause , have not learnt 'limit' thank you you need have group by clause since have non-aggregated column in select clause select min(rate), rentalcode rentalrates group rentalcode update since want lowest rate, think better way using order - limit since supports multiple records having lowest rate. select * rentalrates rate = (select min(rate) rentalrates)

iphone - Saving buffer data of AVPlayer -

i playing audio server using avplayer in application. want when buffer audio can save data in application play later. guide or how can access buffer data , save later use i think issue similar downloading audio or music files server , playing them in app. anyways if want save audio in app , wouldn't better download , play ? anyways please check these links how download audio files server iphone application? download music file server , save in app hope help.

popup - Opening a javascript window same as facebook window functionality -

Image
i trying implement inviting friends facebook, gmail functionlaity. below html code generates links , opens pop window htmlcode.html <div class="socialapis"> <span>invite friends <a href="http:/" onclick="facebookinvitefriends();">facebook ?</a></span>&nbsp; <span> <a onclick="window.open('{% url 'social:gmail_contacts' %}','targetwindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=500')"> gmail ? </a> </span> </div> so when clicked on facebook link below popup window opening facebook login screen fitting window size when clicked on gmail link thee below pop window opening by way using twitter bootstrap ui part. can observe above image, gmail login screen not fit window, instead have scrolling bar. also after logged in gmail, getting next...

java - Socket programming is not working -

i using socket programming in java. working in computer. when run server in computer , run client in computer not working. when run server in computer , run client in computer working. in case stack trace , code snippet can hepful. can assume following reasons: firewall routing to check routing try ping server client. if ping works have firewall problem. if both computers in same network check personal firewall configuration. server computer not allow "strangers" connect port have chosen. i try stop filrewalls on both machines first. if helps start them again , learn how create firewall rule allows application work.

javascript - How to access an object literal property from another property? -

this incredibly simple , google-fu not strong enough. apologies if duplicate. consider following object literal: var config = { url: 'http://google.com', message: 'you must go <a href="' + url + '">google</a> search!' }; i error saying url not defined . how access url element message element? i think can wrap config object, e.g. var config = (function() { var _url = 'http://google.com'; return { url : _url, message : 'you must go <a href="' + _url + '">google</a> search!' } })();

Android: displaying icons on device's desktop -

i know how facebook messenger work. mean, guess there service running in background, broadcast receiver. baffles me when receive message, circle person's profile picture pops on home screen. https://encrypted-tbn1.gstatic.com/images?q=tbn:and9gcq7ik8vphoc1ork3vf-ltozptsptdtgzzgecofsk49hxyikdmv4 how can achieve that? displaying icons desktop. (no, not want set shortcuts). i have not used facebook app, might misunderstand want do, might achieavable widget? if want more 'dynamic' experience, without needing user place widget, can use intent or broadcast launch transparent activity ( here question on transparent activties). activity can display views want show on top on whatever user viewing (such home screen).

ios - sorting NSArray of NSDictionaries in which are array of dictionaries -

i need sorting array "date" key of items dictionary.and in end need array structure mdata array sorting date. mdata---------->( { items = ( { accuracy = 5; address = "australia, sydney cbd, bridge street"; course = "0.00"; date = "2013-08-20 06:50:28 +0000"; speed = 3; alt = 0; lat = "-33.8634"; lon = "151.211"; }, { accuracy = 65; address = "armenia, yerevan, \u053f\u0561\u056c\u0565\u0576\u0581\u056b \u0583\u0578\u0572\u0578\u0581"; course = "0.00"; date = "2013-08-20 06:41:02 +0000"; speed = 3; alt = 1116; lat = "40.20016076"; lon = "44....

css - Why does my image overlap with my words? -

Image
why images overlapping words? below css of 5 different images , 1 table. #memberreporthistoryimage1 { position:absolute; left:20%; } #memberreporthistoryimage2 { position:absolute; left:40%; } #memberreporthistoryimage3 { position:absolute; left:60%; } #memberreporthistoryimage4 { position:absolute; left:30%; margin-top:20%; } #memberreporthistoryimage5 { position:absolute; left:50%; margin-top:20%; } #memberreporthistorytable2 { position:absolute; width:100%; } as can see used position absolute. therefore if have not mistaken, position of second table should going according image width , height since memberreporthistorytable2 below images. unfortunately, doesn't. can see image below, overlaps click data. this layout when no data being clicked here image overlap. i tried adding margin-top ...

ios - NSUserDefaults not being saved in simulator ,even though I use synchronize -

i add dictionary nsuserdefaults , call 'synchronize' method,but when close app , reopen values saved in nsuserdefault nil. #define kstarttime @"starttime" #define kendtime @"endtime" nsuserdefaults *defaults=[nsuserdefaults standarduserdefaults]; nsstring *starttime=@"08:00"; nsstring *endtime=@"18:00"; nsdictionary *dict=[[nsdictionary alloc] initwithobjectsandkeys:starttime,kstarttime, endtime,kendtime, nil]; [defaults registerdefaults:dict]; [defaults synchronize]; and in viewdidload method call this: nsstring *starttimevalue=[defaults stringforkey:kstarttime]; the starttimevalue still nil when reopen app in simulator.is userdefaults can't save in simulator??? my point when close app , reopen in simulator values gone. after searched apple document ,i got this. registerdefaults: . as said in apple document :adds contents of specified dictionary registration...

ruby - How to merge multiple hashes? -

right now, i'm merging 2 hashes this: department_hash = self.parse_department html super_saver_hash = self.parse_super_saver html final_hash = department_hash.merge(super_saver_hash) output: {:department=>{"pet supplies"=>{"birds"=>16281, "cats"=>245512, "dogs"=>513926, "fish & aquatic pets"=>46811, "horses"=>14805, "insects"=>364, "reptiles & amphibians"=>5816, "small animals"=>19769}}, :super_saver=>{"free super saver shipping"=>126649}} but want merge more in future. example: department_hash = self.parse_department html super_saver_hash = self.parse_super_saver html categories_hash = self.parse_categories html how merge multiple hashes? you can below way using enumerable#inject : h = {} arr = [{:a=>"b"},{"c" => 2},{:a=>4,"c"=>"hi"}] arr.inject(...

How to load a new page with AngularJS when a user start typing in an input box -

my route /search shows template , related controller showing list of entries database (properly binding data using controller template using $scope variable). if go /search works , shows data. now have added search box @ top of page. when user starts typing, wherever on website, show results instantly (showing template results). what angular way that? here how did it: my route: app.config(['$routeprovider', function($routeprovider) { $routeprovider.when('/', { templateurl: '<%= asset_path "welcome/index.html" %>' }); $routeprovider.when('/search', { templateurl: '<%= asset_path "search/index.html" %>', controller: 'searchcontroller' }); $routeprovider.otherwise({ redirectto: '/' }); }]); the global layout: <form class="navbar-form navbar-left" role="search" data-ng-controller="searchcontroller"> <div class="form-group"> ...

.net - ASP.NET injects session state into the URL despite the "UseCookies" setting -

in asp.net mvc3 application have following route definitions: routes.maproute( "sso", "mycontroller/sso", new { controller = "mycontroller", action="sso" } ); routes.maproute( "settings", "mycontroller/settings/{objectid}", new { controller = "mycontroller", action="settings", objectid = @"" } ); and inside mycontroller have this: [my] public actionresult sso( list of parameters ) { //blah - nothing yield redirect, formsauthentication.setauthcookie("magicsso." + someguid, false); return redirecttoaction("settings", new { objectid = someguid } ); } and myattribute class inherits system.web.mvc.actionfilterattribute , overrides onresultexecuted() , latter logs value of resultexecutedcontext.httpcontext.response.redirectlocation . in test works fine , when onresultexecuted() runs logs /myaccount/settings/some-guid-as-expected-here redirectio...