Posts

Showing posts from April, 2012

cocoa - Using "Tab" key to move from NSTextField to NSMatrix -

i have cocoa form (xib) contains nstextfield s , nsmatrix of nsbuttoncell s. can use "tab" key tab though nstextfield s, nsmatrix gets skipped over. i want able tab nsmatrix , , tab 1 button next within matrix. i have put in following line of code, having no effect: [mtxmymatrix settabkeytraversescells:yes]; can problem or point me example? have searched hours no success. i had similar problem , solution found fiddling "first responder" setting. specifically, making sure entire form didn't refuse, , each individual field likewise accepted first responder status. again, whole form, , each field well. searched while... :( i'm noob.

How to elegantly implement the pipeline pattern using Scala -

i'm looking build pipeline pattern scala. wish after write pipeline objects, connected this: pipeline1 :: pipeline2 :: pipeline3 ... i have experimented few ideas far. work , don't. none of them seems rid of boilerplate code. following closest i've got. first define pipeline , source abstract class: // input type , o output type of pipeline abstract class pipeline[i, +o](p: pipeline[_, _ <: i]) { val source = p val name: string def produce(): o def stats():string } abstract class source[+t] extends pipeline[anyref, t](null) next, created 2 pipelines , try link them together // creates random integer class randominteger extends source[int] { override val name = "randint" def produce() = { scala.math.round(scala.math.random.asinstanceof[float] * 10) } def stats()="this pipeline stateless" } // multiply ten class timesten(p: pipeline[_, int]) extends pipeline[int, int](p) { private var count = 0 // simple state o

r - roxygen2 + cygwin + default parameter = truncated `\usage` section -

i have package r i've been developing under linux, , horrible time has come i'm testing under windows. the documentation done using roxygen, , using cygwin build package. the thing is, when roxygenise('test-package') , roxygen truncates \usage section of documentation 1 character. not of functions, , can't figure out pattern. this not occur when run same command (i.e. roxygenise('test-package') r prompt) under linux or windows - cygwin under windows (using r devtools + command prompt windows isn't option me - it's part of big project makefiles etc). in cases, using roxygen v2.2.2. update: this appears occur function default parameter. i've boiled down 1 reproducible example, trimmed down as possible isolate problem: from r: # function used trim strings, i've stripped right down # eliminate cause of problem trim <- function(x='asdf') { return( x ) } package.skeleton('test') modify trim.r (i

android - How to get the current latitude and longitude in my mobile -

i have developed application uses google's api level 8, when run app in device supporting android version 2.2 , working properly, can current latitude , longitude.but when run same application on device has android version 2.3.4 works ok except 1 thing not able current latitude , longitude, returns null value. how make app compatible version of android , there way or bug in android api level , have stucked here highy obliged. other option can use phonegap in android application..please follow link phonegap

javascript - What is the purpose of passing-in undefined? -

i have noticed jquery , related keynote plugins jquery.ui pass undefined parameter anonymous functions used in module definitions, so: (function($, undefined) { ... })(jquery); alternatively, have noticed other plugins recommended jquery and/or others not pass undefined in parameter. this silly question, but... shouldn't available anyway? why pass in? there sort of other purpose or trick going on here? there 2 reasons that: 1) if undefined variable in function scope rather global object property, minifiers can reduce single letter achieving better compression rate. 2) before es5*, undefined property of global object without write-protection. overwritten, resulting in strange , unexpected behavior. this: var test = 123; undefined = 123; if (test === undefined){ // true, since undefined equals 123 } by having function argument undefined (the name not matter) don't pass parameter to, make sure have variable undefined can test "undefine

iphone - MapKit : Add custom callout -

i want add custom annotationview callout contains 1. title 2. subtitles 3. button the button can display on right ( rightcalloutaccessoryview ) or left leftcalloutaccessoryview sides of callout. want add button in middle of callout , under title->subtitle. how can do? there no api this. try not using standard callout (canshowcallout = no), catch taps , drags on annotationview manually , show own ui adding custom views based on position of annotationview. seems fragile, though.

Additional sections in ASP.NET web.config file error -

i have legacy asp.net web site, upgraded asp.net 2.0 asp.net 4.0 target framework. it's pity, old web.config file uses many custom sections, positioned on same level appsettings. web site compiles error "unrecognized configuration section mycustomsection" . possible not refactor code , keep custom config sections in web.config file? have added mycustomsection configsections? <configsections> <section name="mycustomsection"... /> </configsections>

WPF form inheritences issue -

i have questions concerning issue of form inheritance in wpf. have read there no visual inheritance in wpf forms. write project base form, other forms inheriting it. some possible solutions use usercontrol , , use inside son form. problem have define again , again in every new form inherits base one. can implement way, without defining in son-form? you can use style handle less markup usercontrol (you have set style="{staticresource mywindowstyle}" in every window element). using style can override template of window, putting whatever chrome around window content. add contentcontrol content="{templatebinding content}" wherever want sepcific window's content appear. unfortunately can't apply windows easily, because setting generic style apply base window control, , each of application's windows of type derives window . edit: if want specify templated controls in window, can following style: <style x:key="mywindowst

CSV to Specific XML with Powershell -

i trying use powershell convert csv xml table. there way can specify xml output. example csv input: time,temp,humid,dewpt "03/07/2012 12:04:59",72.1,73.2,62.5 "03/07/2012 11:34:53",71.9,73.8,62.5 "03/07/2012 11:04:46",71.8,74.6,62.7 "03/07/2012 10:34:39",72.3,72.6,62.4 "03/07/2012 10:04:33",71.9,72.1,61.9 example xml output: <?xml version="1.0" encoding="utf-8" ?> - <chart> - <series> <value xid="0">03/07/2012 00:02:06</value> <value xid="1">03/07/2012 00:32:17</value> <value xid="2">03/07/2012 01:02:26</value> <value xid="3">03/07/2012 01:32:35</value> <value xid="4">03/07/2012 02:02:42</value> </series> - <graphs> - <graph gid="0" color="#32cd32" axis="right" title="temperature"> <value xid="0"

curl - calling controller subclass from a php script -

when call php script php controller page like: curl_setopt($ch, curlopt_url, "http://site.com/admin/importcontroller.php"); importcontoller subclass of pagecontroller : importcontroller extends pagecontroller i'm getting error: fatal error: class 'pagecontroller' not found in /home/public_html/admin/importcontroller.php on line 8 is call possible? how? just add: require_once("pagecontroller.php"); if used other way require_once not included , in case included.

c# - Initialize log4Net as early as possible with NUnit -

i'm wondering best way initialize log4net in nunit project. of course want call init code (ie. xmlconfigurator.configure() ) can many log output can. since project run through nunit, have little control on entry point. according nunit documentation, should call constructors first, method marked [setup] attribute in class marked [testfixturesetup] . so, first, created static helper class can call several times without trouble. public static class loggingfacility { private static bool _loggerisup = false; public static void initlogger() { if (_loggerisup == false) xmlconfigurator.configureandwatch(f); _loggerisup = true; } } then, made [testfixturesetup] inherit single 1 pretty nothing else calling loggingfacility.initlogger() . still leaves constructors run earlier, in order can assume random. , moreover, static initializations before able execute code. in fact, can see in log, first 4 seconds or of execution unrecorded.

query optimization - How to optimize this LINQ expression? -

i have code: var query = deal in db.deals deal.enddate >= datetime.utcnow select deal; var pricelist = filters.price.getpricerangelist(); foreach(var price in pricelist) { var startprice = price.startprice; var endprice = price.endprice; var priceresult = deal in query (deal.discountprice >= startprice && deal.discountprice <= endprice) select deal; if(priceresult.count() != 0) priceresults = (priceresults == null) ? priceresult : priceresult.union(priceresults); } query = priceresults != null ? query.intersect(priceresults) : enumerable.empty<deal>().asqueryable(); my query slow when pricelist has more ten values. i use intersect filters. how optimize these queries? you have few issues. first 1 query executed every iteration in foreach loop. calling tolist or toarray ensure executed once secondly union costly. iterate priceresult every iteration of foreach loop thirdly cou

android - debugging app on xperia over Ubuntu -

i'm trying debug application on xperia cellphone cyanogenmod installed, doesn't seem recognize cell phone. also, adb seems gone, followed http://developer.android.com/guide/developing/device.html official guide, when executing: $./adb devices on plataform-tools/ directory system doesn't recognize device. also tried $sudo ./adb devices any ideas? thanks help.!! solved the problem needed restart adb server did this: $sudo ./adb kill-server $sudo ./adb start-server

email - Python's smtplib sendmail is inserting line feed -

i using smtplib sendmail , \n (line feed) being added there \r (carriage return). this corrupts file use unix tnef utility. how can keep line feed being added? thanks email servers free change line endings iirc. various platforms. if transmitting attachment, use suitable encoding such base64.

hsqldb - Connecting to HSQL via Ruby and shutting server down -

i'm trying write ruby script kill database server on localhost. when run 'ant hsql' starts database (output below) , have keep terminal window open. buildfile: /users/cparaiso/dev/src/testproject-src/build.xml hsql: install-parent-pom: [artifact:install] [info] installing /users/cparaiso/dev/src/testproject-src/pom.xml /users/cparaiso/.m2/repository/org/jasig/portal/uportal-parent/4.0.3/uportal-parent-4.0.3.pom [touch] creating /var/folders/8v/1k2gkj412q1_8084x6lvtbqr0000gn/t/jasig/uportal-parent.pom-110044247-marker [echo] starting hsql on 8887 [echo] using: file:/users/cparaiso/dev/src/testproject-src/data/uportal [java] [server@6f507fb2]: [thread[main,5,main]]: checkrunning(false) entered [java] [server@6f507fb2]: [thread[main,5,main]]: checkrunning(false) exited [java] [server@6f507fb2]: startup sequence initiated main() method [java] [server@6f507fb2]: not load properties file [java] [server@6f507fb2]: using cli/defau

a star - Looking for speedups for A* search -

i've got following working a* code in c#: static bool astar( igraphnode start, func<igraphnode, bool> check, out list<igraphnode> path) { // closed list. hashset because o(1). var closed = new hashset<igraphnode>(); // binary heap accepts multiple equivalent items. var frontier = new multiheap<igraphnode>( (a, b) => { return math.sign(a.totaldistance - b.totaldistance); } ); // way know how many multiple equivalent items there are. var references = new dictionary<igraphnode, int>(); // way know parent graph node has. var parents = new dictionary<igraphnode, igraphnode>(); // 1 new graph node in frontier, frontier.insert(start); // count reference. references[start] = 1; igraphnode current = start; { { frontier.get(out current); // if it's in closed list

android - Fragment not readded on restart -

i have activity manages 4 fragments. activity decides when add/replace/hide/show fragments. when application closed (due low memory) , reopened user, fragments not automatically readded fragment manager. how can save fragments added when application restarted user brought same page on previously? i assume use onsaveinstancestate() i'm not sure save... thanks one thing keeping track of displayed screen integer. activity hold private int current screen value. private int currentscreen = -1; private static final int screen_menu = 0; private static final int screen_profile = 1; private static final int screen_help = 2; private void switchtomenu(){ currentscreen = screen_menu; //load fragment frame. } private void switchtoprofile(){ currentscreen = screen_profile; //load fragment frame. } private void switchtohelp(){ currentscreen = screen_help; //load fragment frame. } @override public void onresume(){ switch(currentscreen){ cas

c++ - Function overloads and inherited types are not calling the correct overload -

given following base class: struct valuetype { string tostring(string const& format) const; }; i want overload called types deriving valuetype : string formatvalue(const valuetype& value, const string& format) { return value.tostring(format); } otherwise, want overload called: template <typename t> string formatvalue(const t& value, const string& format); how can ensure derived types not instead call second overload? the original question located here . i not fond of trying different reasons (including valuetype interface, why not use anytostring always?), @ rate should able solve problem sfinae template <typename t> typename enable_if< !is_base_of<valuetype, t>::value, string>::type formatvalue( t const & value, const string& format ) { ... } what code (once make compile :) inhibiting template function when condition met. when compiler considers template overload try substitute type, , ena

Cakephp Missing Controller -

when tried run website. shown me error. missing controller error: realestatecontroller not found. error: create class realestatecontroller below in file: app\controllers\realestate_controller.php i don't have such controller yet, should ? just create file in controllers folder such: name file realestate_controller.php and in file add <?php class realestatecontroller extends appcontroller{ //if want can add public function index(){ } } ?> thanks,

c# - Silverlight - Dynamic binding by visibility -

if have 2 text boxes, 1 visible , other 1 isn't . both bound same property. is there way bind visible one? way validation causes 1 error in validation summary ? i have form many fiends many different ways people can enter data based on selection. wondering if there way of maybe having method goes on hidden components , disables validation or/and unbinds temporarily . here's nice short example of you're trying accomplish: http://blog.dotnetstep.in/2009/12/silverlight-3-enable-and-disable.html you use visual tree walker in example walk visual tree , remove bindings on framework elements have visibility value of collapsed: http://netpl.blogspot.com/2010/03/silverlight-visual-tree-walker.html

php - How to grab users on the same page in a session and list them? -

on page created chat room works if you're signed forums. grabs session username who's on page , shows name when send chat. messages sent , stored , sent out via .txt file using ajax , processed php. no database (as of yet). i'm wondering how can grab & list current users on page chatting? i'm not php bit complicated me. my guess log username database, , whoever logged displayed... close? try this <?php session_start(); echo "<pre>"; print_r ($_session); echo "</pre>"; //echo single entry echo $_session['username']; ?> foreach loop through ($_session) show session data.. foreach ($_session $key=>$val) echo $key." ".$val;

deployment - how to control ownership of files auto-pushed to a git target repo by commit hooks? -

i created bare repo @ /srv/repos/test i set ownership wwwrun:www suid+guid bits set chown -r wwwrun:www /srv/repos/hub chmod ug+s /srv/repos/hub ls -ald /srv/repos/test drwsrws---+ 10 wwwrun www 4.0k mar 7 21:28 /srv/repos/hub/ i cloned repo webroot, , changed ownership, git clone /srv/repos/hub /srv/www/sitea chown -r wwwrun:www /srv/www/sitea for convenience, define remote cd /srv/www/sitea git remote add hub /srv/repos/hub then create post-commit , post-update hooks keep things in sync, vi /srv/www/sitea/.git/hooks/post-commit #!/bin/sh git push hub vi /srv/repos/hub/hooks/post-update #!/bin/sh cd /srv/www/sitea || exit unset git_dir git pull hub master exec git-update-server-info as normal user, checkout hub whoami locuse cd ~ git clone /srv/repos/hub work ls -ald work drwxr-xr-x 10 locuse users 4.0k mar 7 21:44 work/ make change, commit , push, cd work touch touch_file ls -al touch_file -rw-

asp.net - Folder access issue in window7 with out administrator rights -

i want access folder can read write , delete files in c drive through application , application developed in asp.net using c# window service. found c:\users\default\appdata\roaming or c:\program data folder accessible user , can read write or delete files out admin rights. unfortunately not available in window xp there folder available in xp , win7 user can write/delete/read out administrator rights? you can use temporary folder on c drive: "c:\temp".

javascript - How can i keep the color the same in highcharts -

i using highcharts first time. looks cool , doing want. use piechart , refresh data every second. working color of pieces changing every second. how can keep same color? this code var chart; $(document).ready(function() { chart = new highcharts.chart({ chart: { renderto: 'container', plotbackgroundcolor: null, animation: false, plotborderwidth: null, plotshadow: false, events: { load: function() { // set updating of chart each second var series = this.series[0]; setinterval(function() { $.getjson("opencont.php", function (data) { $.each(data.vragen, function (index, value) { series.addpoint([value.short, value.antwoorden], true, true); }) }) }, 1000); } } }, title: { text: '&#

How can I display a message through multiple sessions? JSF 2.1 & Primefaces 3.1 -

i have application shows data in p:datatable.... table accessible many users. when 1 user modify record in table, (create, edit, delete), action notified @applicationscoped managedbean notify other session (opened other users), items in table changed, must reload database. can see controller notify session items changed, /** * @author simone rondelli */ @managedbean(name="singleton") @applicationscoped public class singletonbean { private int count; private hashmap<class, list<abstractcontroller>> sessions; public singletonbean() { sessions = new hashmap<class, list<abstractcontroller>>(); } public void addsession(abstractcontroller session, class c) { list<abstractcontroller> sessionlist = sessions.get(c); if(sessionlist == null) sessionlist = new arraylist<abstractcontroller>(); sessionlist.add(session); sessions.put(c, sessionlist); } public voi

What does the dot prefix in the cookie domain mean? -

Image
what difference between local.test.com , .local.test.com ? screenshot chrome. local.test.com used domain, while .local.test.com used subdomains too.

iphone - Accept untrusted SSL server certificate with CFStream socket on iOS -

i need open cfstream socket connection server has untrusted ca root. have certificate of server, , can create seccertificateref structure it. problem how set properties of stream. i think should set kcfstreampropertysslsettings property cfdictionary in turn contains kcfstreamsslcertificates key. key should hold "a cfarray of seccertificaterefs except first element in array, secidentityref" according docs. can create seccertificateref server's certificate i'll ship app, how secidentityref ? guess should client identity absolutely don't want client side authentication now. , can't find way how feed cfstream server certificate. note, don't want add untrusted certificate keychain, neither disable kcfstreamsslvalidatescertificatechain in settings. need accept server authentication if based on own server certificate data loaded disk, , on cfstream. i not have direct answer question, perhaps few guidelines: why need use cfstream api , no

asp.net - Javascript not working on google chrome and smartphone browsers -

i working on asp.net/c# web application have check box. , want check box simulate button click when checked/unchecked i used javascript it <input id="filtercheck" runat="server" type="checkbox" value="filter" onclick="document.getelementbyid('button1').click();"/> button1 normal button <asp:linkbutton id="button1" runat="server" onclick="button1_click"/> so when click on checkbox, same if clicked on button1. everything works fine on firefox , internet explorer. not working on google chrome , smartphone browsers how can fix problem? in addition there few other javascript , jquery scripts working on internet explorer , firefox not on google chrome , smartphone browsers. what can make sure website compatible on browsers? thanks lot help edit: yep, first thing. chrome choking on linkbutton , not rendering expected. i going ask. id same html id attribute? ho

jqGrid Sorting Arrows -

Image
for sorting, show 1 arrow aligned column header. noticed viewsortcols allows put arrows horizontally (aligned nicely), wondering if there tricks use single arrow. if sorted 1 way points up, other way points down. i came across this grid doing it...but having little trouble understanding code. not need use custom arrows. the code example reference uses old version of jqgrid (version 3.4.3). can have behavior of sorting. one day misunderstand 1 question , have answered on question. find answer here . uses the demo create results and one more answer interesting you. updated : if want change position of sort icon can adding css follow .ui-jqgrid .ui-jqgrid-labels .s-ico .ui-grid-ico-sort { margin-top: 0px; } it change icon position to and see the modified demo .

javascript - How to get backbone model attributes without .get -

in backbone seems have model attributes via model.get('att_name') i'd prever them way i'd public field within object: model.att_name can think of way around this? eg: in python world override getattr on model this: def getattr(self, att): return self.get(att) oh, , i'm using coffeescript model attributes use get() , set() or defaults get/set stored in instance.attributes attribute. also, these attributes going passed , returned sync() tojson() . when fetch() , save() etc, stored in instance.attributes gets passed along. nothing stop of course having normal attributes instance.foo on objects. if want treat other attributes , pass these along fetch() , save() can providing custom parse() on model default nothing. said, should if deem absolutely necessary, if comply backbone conventions.

Regex and delimiter in javascript -

i not regex, need , stuck... this got: edited: working fine, take at... http://jsfiddle.net/oscarj24/qrphk/1/ this need: // first 4 numbers must 9908 // after 4 first numbers must : delimiter // after delimiter... // - allowed values numbers 0-9 // - min. length 3 // - max. length infinite // result: // - valid: 9908:123 or 9908:123456... // - invalid: 9908:12 or 9908:xyz thanks. var regex = /^9908:\d{3,}$/; will match 9908: followed 3 or more digits.

android - How do I get news feeds? Just like News and Weather app -

i'm trying know how implement news feed retrieval, how on news , weather app: in app (news , weather), have option of writing name, app retrieves news based upon it. (menu -> settings -> news settings -> select news topics) for example, if "android", it'll fetch me news relating "android". is based on rss? how work , how can implement in app? thanks! i saying understand: u want make news search box* : user type word , find latest news written topic: think u have store ur rss feed in db , fire query on db , display news...

php - Ajax Form Submission & Javascript Confirm Error -

i have form submits through ajax, works @ moment. tried add confirm option allow / prevent ajax submission through adding following lines: var answer = confirm('submit now?'); return answer // answer boolean if(answer) { ... } below full function, which, can see, fires on clicking submit button. error occurs when user selects okay in dialog. entire page refreshed , single ajax warnings returned @ top of blank screen. in normal case, without confirm code, error messages appear in div#result tag @ bottom of form. $("#submitbtn").click(function() { var answer = confirm('submit now?'); return answer // answer boolean if(answer) { $('#result').html('<img id="loading" src="images/loading.gif" />').fadein(); var input_data = $('#create_po').serialize(); $.ajax({ type: "post", url: "<

javascript - jQuery fancybox link inside div -

i have div containing information. wraped around div have 'a' tag when user clicks anywhere around div fancy box opens. however inside div andother link when clicked instead of opening fancy box deleted whole div. used return false in click event delete worked. i have had add .live click because newly created elemnet not getting click event. since though when click delete link div delete fancy box opens also. thanks help. $(".listcontent").live('mouseenter', function(){ $(this).fancybox({ 'type':'ajax', }); }); $("div.removecompare").live("click", function() { $(this).parents(".listingcontainer").remove(); return false; }); div <div class="listingcontainer grid_9 alpha omega"> <a class="li

gridview - ViewStub inflate consumes a lot of memory (android) -

i using viewstub in gridview custom adapter programatically sets layout id , calls 'inflate' on viewstub. problem is, have bg service on timer updates values set in 1 of inflated layouts via 'notifydatasetchanged' on adapter. after while, background process crash because it's running out of memory. i've confirmed layout inflater, because if comment out call hits that, backgrhoud service keep on running without crashing. any ideas?

ruby - Rails 3 Routes: How do you show a nested page? -

i show first page lesson when click on show link here have: lesson index: <%= link_to 'show', lesson_page_path(lesson)%><br /> pages controller def show @lesson = lesson.find(params[:id]) @first_page = @lesson.pages.first respond_to |format| format.html # show.html.erb format.json { render json: @page } end end routes resources :lessons resources :pages end i getting error no route matches {:action=>"show", :controller=>"pages", :lesson_id=># lesson id: 1, title: ... how can url when click on show link: /lessons//pages/1 if you're nesting that, need link both page , lesson: lesson_page_path(lesson, page) if want first one, define route: get '/lesson/:lesson_id/page_one', :to => "pages#show"

excel - Powerbuilder Syntax for dw string replacement -

i'm importing csv file problem csv file extracted different program (w/c not control). excel file saved csv when open in text/notepad. shows ex. name;gender;age;address1;address2 sid;m;100;44 lowave st.;pque vill it used semi colon not comma now ask users open in excel , use delimiter options make comma separated know still ask way automate process. now im getting ready request thinking of importing excel file single column datawindow parse each row find ";" , replace() "," in while manner, save csv afterwards. my question have replace char per char using while loop or there better way? thanks lot. filereadex() file string variable, global replace (pfc has 1 if don't already) semicolons tabs, , importstring(). (assumes data has no tabs or semicolons.) or read file, parse , load insertrow() , setitem(). good luck, terry

linux - how to convert the script from using command,read to commmand,cut? -

here test sample: test_catalog,test_title,test_type,test_artist and can use following sript cut off text above comma , set variable respectively: ifs="," read cdcatnum cdtitle cdtype cdac < $temp_file (ps:and $temp_file dir of test sample) and if want replace read command,cut.any idea? there many solutions: line=$(head -1 "$temp_file") echo $line | cut -d, ... or cut -d, ... <<< "$line" or can tell bash copy line array: typeset ifs=, set -a array $(head -1 "$temp_file") # use echo $array[0] # test_catalog echo $array[1] # test_title ... i prefer array solution because gives distinct data type , communicates intent. echo/cut solution slower. [edit] on other hand, read command splits line individual variables gives each value name. more readable: $array[0] or $cdcatnum ? if move columns around, need rearrange arguments read command - if use arrays, have update array indices will wrong. also

indexing - Trouble with a equation in Java -

i'm working on 15 puzzle game android school. sadly i've ran problem. i need rewrite equation row , column instead of index. have @ code , se if guys can me out! this takes row , column , return me corresponding index. int index = 4 * (row - 1) + (column - 1); however, turn index row , column. know how sort of reverse equation return row , column 2 different ints. thank, mikael try this: row = index / 4 + 1; column = (index % 4) + 1; note (and original formula) works if column < 5 (which is, of course, 15 puzzle).

android - How to destory the Admob adView completely and get the memory back? -

my app has activity , service. introduce admob in app. however, found incredibly consuming memory (5mb), , can't memory after destroy it. i use in layout.xml <com.google.ads.adview android:id="@+id/adview" android:layout_width="fill_parent" android:layout_height="wrap_content" ads:adunitid="xxxxxx" ads:adsize="banner"> enable admob in oncreate adview adview = (adview)this.findviewbyid(r.id.adview); adview.loadad(new com.google.ads.adrequest()); destory on onpause or ondestory adview adview = (adview)this.findviewbyid(r.id.adview); adview.destroydrawingcache(); adview.destroy(); after destroy it, still can't 5mb memory back. can pls? p.s. service running on background , see 5mb still there. thanks. just guess maybe try calling stoploading() before calling destroy().

Lock phone using a android application -

possible duplicate: lock android device programatically i trying lock phone using application, i have tried following code, no use,i inserted user permissions too. keyguardmanager manager = (keyguardmanager) getsystemservice(context.keyguard_service); keyguardlock lock = manager.newkeyguardlock("hh"); lock.disablekeyguard(); lock.reenablekeyguard(); please suggest me code lock phone. add permission in androidmanifest.xml file <uses-permission android:name="android.permission.disable_keyguard"/> and keyguardmanager mgr = (keyguardmanager)getsystemservice(activity.keyguard_service); keyguardlock lock = mgr.newkeyguardlock(keyguard_service); lock.reenablekeyguard();

android - my textview are shorten if I don't set an enought large string in my layout :S -

i've strange issue, when try set text on 1 of textview, text appear entirely if i've set in layout bigget text. if text in layout smaller, new string shorten between 2 words fit smaller place. if don't set text in layout, doesn't appear ! have idea have ? (i'm in custom view group involving 3 layout in same activity, without fragments) <?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:gravity="cent

git - Branching: different config files for release/development -

i've inherited project , using git. have number of environments (dev, test, prod). previous team recreated on each instance, using same accounts, passwords, sid, etc. thing changed hostname mappings in /etc/hosts. connect different database server. now, creates problem, because can't, example copy schema developer can run experiment using same database instance main development server. have create new database instance on host, , change /etc/hosts point new server. while working setup, i'm trying find way maintain different config files each instance. ie: different versions of applicationconfig.xml depending on branch. i'm guessing 1 argue keeping database credential in repo not such great idea, lets ignore second. another situation might warrant having different version of file debugging. i'm using javascript logger framework, , add debug code wouldn't want ship production release. don't want have add logger stuff when developing/testing , remove

Jquery: if referer contains 'keyword' then say this -

i want dynamically add div on webpage receives traffic google. lot of traffic comes people searching brands. the idea identify url referer , see if contains of brands , using jquery: if referer contains brand-keyword add div saying: 'brand'? free quotes 'brand' how can that? lets assume keywords brands are: brand1, brand2, brand3, brand4 if want go ahead regardless of @rob w's comment, following: var arr = [ "one", "two", "three", "four", "five" ]; var referrer = "the number three"; $.each(arr, function(){ if (referrer.indexof(this) >= 0){ $('#id_of_your_div').html(this + '? free quotes ' + + '!'); return false; } });​ where arr list of words searching for, , referrer string you're looking in. example: http://jsfiddle.net/ds4r3/1/

documentation - Unable to retrieve docs in a specific folder in google docs using c# -

i'm trying retrieve documents in folder in google docs using below function give in api documentation.. still function returning titles of documents , not of particular folder.. public documentsfeed retrievedocsinfolder(documentsservice service, string folder, string email) { atomcategory foldercategory = new atomcategory(folder, new atomuri("http://schemas.google.com/docs/2007/folders/" + email)); querycategory folderquerycategory = new querycategory(foldercategory); documentslistquery query = new documentslistquery(); query.categories.add(folderquerycategory); query.categoryqueriesasparameter = true; return service.query(query); } try following code: public documentsfeed retrievedocsinfolder(documentsservice service, string folder) { string uri = string.format(documentslistquery.foldersuritemplate, folder); documentslistquery query = new documents

iphone - Which project template should I use for an iOS and Cocoa library? -

Image
i have bunch of code in ios project (named "mylibs") re-use across different apps. drag mylibs project workspace of whatever app i'm creating. don't use unit tests per se, have buttons run through tests in iphone app. i'm learning cocoa , divide library libs can use on both projects. thinking mycommonlibs (or myfoundationlibs), myioslibs , mycocoalibs. however, when creating new project, must choose between ios app or cocoa app. looks though ios framework , library -> cocoa touch static library appropriate because links against foundation framework. on other hand, i'd prefer use application template if there no major drawbacks it. i need able use mycommonlibs in both app types, of them useful both, such nsarray categories, etc. which template should use mycommonlibs , must use library, framework (in mac os templates) or can use normal application template (as i've been doing far)? create ios framework & library project. le

jquery - Javascript Cross browser Issue -

i have programmed simple jquery ticker (using pre-made javascript) display tweets , other things. working fine firefox, chrome, ie9/10 not ie8 , older versions. have no experience javascript can't find why append doesn't work ie8 $(settings.dom.wrapperid) .append('<div style="opacity: 1;" class="tweet_row" id="' + settings.dom.tickerid.replace('#', '') + '"><span><!-- --></span><div id="' + settings.dom.contentid.replace('#', '') + '"></div><div id="' + settings.dom.revealid.replace('#', '') + '"><span><!-- --></span></div></div></div>'); thanks nnnnnn problem solved , <div> , </div> tags unbalanced didn't think may cause problem

Javascript variable in element name -

i have text box, , select box choices same columns in table. want able type in box, select column, press button, , have copy whatever in box, every box in column. having hard time syntax using variable thing prevents working. when put in real values, works fine. function testscript(fill) { choice=document.form1.column.value; alert (fill); alert (choice); for($i=0;$i<fill;$i++){ document.form1.choice[$i].value=document.form1.copy.value; } } fill (tested alert) provides me number of rows in table , works fine. choice select (drop down) box. if type in "document.form1.make[$1].value= fills type in every row of make column. if choose make in select box, choice make indicated test alert. any ideas how use variable correctly in loop? function testscript(fill) { choice=document.form1.column.value+'[]'; for($i=0;$i<fill;$i++){ document.form1.elements[choice][$i].value=document.form1.copy.value; } } updated view

android - How to perform commands after "setContentView" is being called -

i'm using "include" on main layout. each 1 of them relativelayout needs onclick listener attached, , update information related. i've tried by: setcontentview(r.layout.allobjects); objectlisteners objectlisteners = new objectlisteners(objects); for(int i=0;i<1;i++) { relativelayout objectboxrelativelayout = (relativelayout)findviewbyid(r.id.object1 + i); objectboxrelativelayout.setonclicklistener(objectlisteners.getobjectlistener(i)); someobject currentobject = this.objects.get(i); object viewobject = findviewbyid(r.id.object1 + i); this.setobjectview(viewobject, currentobject); } the issue takes long after "setcontentview(r.layout.allobjects);" command, , application shows black screen until finish loading. in addition, use "setcontentview(r.layout.allobjects);" after perform above commands. of these commands have written after "setcontentvie

c# - Linq: Select object based on property -

how 1 select specific object using query-expression style linq? private static observablecollection<branch> _branches = new observablecollection<branch>(); public static observablecollection<branch> branches { { return _branches; } } static void main(string[] args) { _branches.add(new branch(0, "zero")); _branches.add(new branch(1, "one")); _branches.add(new branch(2, "two")); string toselect="one"; branch thebranch = in branches let valuebranchname = i.branchname valuebranchname == toselect select i; console.writeline(thebranch.branchid); console.readline(); } // end main public class branch{ public int branchid; public string branchname; public branch(int branchid, string branchname){ this.branchid=branchid; this.branchname=branchname; } public override string tostring(){

How to retrieve html text from stored procedure in C# -

i have multi line text in html format stored in database this: @"<font size='1'> <p><span ...='25' width='120' src='http://www.mysite.com/images/new-site-logo.jpg'/></span></p> <h2 ...</table></font>" and have stored procedure retrieve database. in c# call stored procedure in myclass.cs this: public string getehtmlcontent(int id) { ... sqlparameter htmlparam = new sqlparameter("@htmlemail",""); htmlparam.direction = parameterdirection.output; cmd.parameters.add(htmlparam); cmd.parameters.add(new sqlparameter("@id", id)); cmd.executenonquery(); htmlcontent = httputility.htmlencode(htmlparam.value); ... } it gets id input parameter , should give html output "@" first character in htmlparam.value . can me how should html context in htmlparam? thanks in advance, mona what parameter list on stored proce

c++ - Difficulty with MPI_Bcast: how to ensure that "correct" root is broadcasting -

i relatively new mpi (with c), , having trouble using mpi_bcast send int processes. in code, decide rank root within loop, different processes responsible different element of loop. then, want bcast result root processes, except non-root processes not know expect bcast from, not receive it. the code block looks this: for (ix=start; ix<end; ix++) //start , end starting row , ending row each processes, defined earlier (int iy=1; iy<nn; iy++) // calculations if (some condition) int bcastroot = rank; // initialized above int x = 111; // initialized above else //do other calculations end end mpi_bcast(&x, 1, mpi_int, bcastroot, comm); // remainder of code , mpi_finalize when execute code, whatever bcastroot default (value non-root processes) competes root, x not broadcast correctly. not know value of x nor can predict root beforehand, cannot define in advance. i have tried initializing bcastroot = -1, setting rank, not wor

css - what could be causing this? -

Image
i have outside div (in blue) , inside div. not sure having effect on adjacent div. ideas? removing content of inside div causes go normal. edit #1 here's new image , css. seems pairings-box causing vertical offset take place. .clearfix:after { clear: both; content: "."; display: block; font-size: 0; height: 0; visibility: hidden; } .wide-box { border: 1px solid blue; margin-top: 10px; min-height: 100px; width: 450px; } .clearfix { display: inline-block; } .pairings-box { border: 1px solid black; float: left; width: 300px; } <div class='wide-box clearfix'></div> <div class='wide-box clearfix'></div> <div class='wide-box clearfix'> <div class='pairings-box'>here text</div> </div> <div class='wide-box clearfix'></div> i don't believe blue <div> s have display: block; suggest. displa

c# - Querying Entity Framework with an object -

i'm trying use entity framework first time, , have come bit unstuck. i have class accountdataaccess: public class accountdataaccess { public ienumerable<account> get(account account) { } } and class, account public class account { string username { get; set; } string password { get; set; } string email { get; set; } session session { get; set; } } when accountdataaccess.get() called, 1 or more of account parameters' fields populated (e.g. username has value). there way in entity framework query database search containing fields contain values? after doing googling, way can see doing like public ienumerable<account> get(account account) { stringbuilder querystringbuilder = new stringbuilder("select value account mydatabase.account account "); if (!string.isnullorwhitespace(account.username)) querystringbuilder.append("username = " + account.username); if (!

Java singleton class vs JSF application scoped managed bean - differences? -

is there difference using singleton class , application scoped managed bean hold application data? i need lookup jndi ressources such remote bean interfaces , therefore wrote myself singleton cache references , allow single references. (servicelocator) i opened website in 2 different browsers , singleton got initialized once. assume application scope? any other benefits of application scope managed bean being able access properties in jsf? singletons not unit testable nor abstractable nor extendable. singletons unnecessarily complex reliably create , maintain if sole purpose have application scoped data (at least, if really want fullworthy singleton for reason -most starters don't understand singleton supposed be). "just create one" application scoped managed bean simpler develop, test , maintain. jsf framework guarantee 1 instance created , reused during web application's lifetime. see also: singleton vs create one how choose right bean sc

ruby on rails - User Messaging with RoR and Mongoid -

i searched web several hours no clear answer. i have rails-app (ruby 1.9.3/rails 3.2.2/mongodb) uses devise user-authorization. now i'd have simple messaging function between users: 1 1 , 1 n. are there gems fulfill need , support mongo or there tutorials or best practices this? maybe relevant too: in next step plan make messages available in ios , android app (both native) too. you need implement it. gem specific , need lot of update generic. i think that. sending message ios , android completly different can't have gem easily. code it.

java - How to create a new HashMap whenever a duplicate key is found? -

i have txt file containing many records, each record has 5 rows , name-value pairs. i have parsed file , put names , values hashmap using scanner detect if file hasnextline. at point because records in same txt file, hashmap contains last record in file. because duplicate keys comes overwrite value key. my question how create new hashmap each record? method have build records: public void recordbuilder() throws filenotfoundexception{ filereader reader = new filereader(afile); scanner outerscan = new scanner(reader); hashmap<string,string> record = new hashmap<string,string>(); while (outerscan.hasnextline()){ scanner innerscan = new scanner(outerscan.nextline()); try{ innerscan.usedelimiter(":"); string name = innerscan.next(); string value = innerscan.next(); string rname = name.trim(); string rvalue = value.replaceall("[^\\w]", "");

android - Retrieving the selected items from a multi-select ListView -

i implementing multi-select listview android app. aim retrieve selected items arrayadapter associated listview when clicking search button. i stumped on how this, have found stuff online such trying set multichoicemodelistener , not seem come option in eclipse . using google api s(level 10), android 2.3.3 equivalent. here code have far: public class findplace extends activity { public findplace() {} @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.list_places); button search = (button) findviewbyid(r.id.search); string[] categories = getresources().getstringarray(r.array.categories); arrayadapter ad = new arrayadapter(this,android.r.layout.simple_list_item_multiple_choice,categories); final listview list=(listview)findviewbyid(r.id.list); list.setadapter(ad); list.setchoicemode(listview.choice_mode_multipl