Posts

Showing posts from March, 2011

How to intercept KeyPressEvent in Java GWT? -

i new java , in our code using gwt. we using keypressevent process key_enter request. seems, each enter request, 2 events fired keypressevent . expect 1 event should fired, since enter 1 time. the following code. please check , let me know, need correct .. void onenter(keypressevent event) { if(event.getnativeevent().getkeycode() == keycodes.key_enter) { //(seems times code called) //domy stuff } } if use event.getcharcode() instead of event.getnativeevent().getkeycode() , returns 0. any idea how fix. thanks, i prefer using keyupevent because user can't distinguish keypressevent here solution: void onkeyup(keyupevent event) { if(event.getnativekeycode() == keycodes.key_enter) { // handle key press } }

Transferring file using sockets from C++ application to Java application -

i'm trying transfer file using sockets c++ application java application. wrote simple code in c++ send file: int main() { int sock; struct sockaddr_in sa; char* memblock; /* create socket on send. */ sock = socket(pf_inet, sock_dgram, ipproto_udp); if (sock < 0) { printf("opening datagram socket"); exit(1); } /* construct name of socket send to. */ sa.sin_family = af_inet; sa.sin_addr.s_addr = htonl(0x7f000001); sa.sin_port = htons(4444); /* send messages. */ file *file; unsigned long filelength = 0; file = fopen(file_path, "rb"); if (!file) { printf("error opening file.\n"); return 1; } // file length. fseek(file, 0, seek_end); filelength = ftell(file); printf("file length is: %d.\n", filelength); fseek(file, 0, seek_set); memblock = (char*)malloc(sizeof(char)*filelength); if (memblock == null) {fputs

java - HttpConnection - javax.microedition, returning -1 for getLength() method -

i trying program simple mobile application (j2me) in java. idea access website via url input , read contents of website buffer. here's problem. works fine url's not others? example below (wikipedia) works fine. take "http://java.com/en/about/" example , "httpconnection hc" returns -1 getlenght() there no content read buffer? here's code: string url = "http://en.wikipedia.org/wiki/rss"; //sets httpconnection , inputstream using url variable httpconnection hc = null; inputstream = null; try { hc = (httpconnection) connector.open(url); = hc.openinputstream(); } catch (ioexception ie) { system.out.println(ie.getmessage()); } //reader object created read input inputstream reader rdr = new inputstreamreader(is); //variable "content" store html code string content = ""; //get lenght of d

ios - How to compare two case insensitive strings? -

i have 2 string objects containing same string case different,now wanna compare them ignoring case sensitivity,how that??here code... #import <foundation/foundation.h> void main() { nsstring *mystring1 = @"mphasis"; nsstring *mystring2 = @"mphasis"; if ([mystring1 caseinsenstivecompare:mystring2]) { nslog (@"its equal"); } else { nslog (@"its not equal"); } } if caseinsensitivecompare: in docs you'll see returns nscomparisonresult rather bool. in docs , you'll see want nsorderedsame. if ([mystring1 caseinsensitivecompare:mystring2] == nsorderedsame) should trick. or compare lowercase strings robert suggested.

How to create a Blackberry notification message that opens the app like twitter does? -

Image
does know actual code create local notification in blackberry app has customized application icon , when user clicks on notification in inbox, goes directly specific page in application? similar how twitter blackberry works, whereby can notified of new tweets via inbox , on clicking on link brings tweets list in twitter app. thanks. what you're looking referred message list integration or message folders. note name "message folder' little misleading. isn't create "folder" user has go (that threw me off first); rather creates message in inbox describe. best user experience you'll want create application notification icon . the package name concern net.rim.blackberry.api.messagelist . need implement applicationmessage you've requested. there example of how in sample source code ships jde, project name "messagelistdemo". jdes dating (at least) os 4.5 have sample app. if want use new notification bar integration os6, make

erlang - Nitrogen - Dynamically creating Events -

i beginner erlang/nitrogen. toying bidding system mnesia db. on index page have following code , various items , properties created dynamically database: %% -*- mode: nitrogen -*- -module (index). -compile(export_all). -include_lib("nitrogen/include/wf.hrl"). main() -> #template { file="./site/templates/bare.html" }. title() -> "meir panim gala dinner silent auction". body() -> header = [#panel{id=header, body=[#h1{text="meir panim gala dinner silent auction"}]}], {atomic, items} = item_database:get_all(), elements = lists:map(fun(x) -> {item, index, title, _, picture, _, _, reserve, currentbid} = x, #panel{id=items, body=[ #span{id=title, text=title}, #image{id=image, image= "images/" ++ picture}, #span{id=currentbid, text="current bid: £" ++ integer_to_list(currentbid)}, #span{id=reserve, text="reser

asp.net mvc - MVC3 - Reading GET Variables Into Controller Action -

i have controller action /responses/insert , want able variables url , save them database. the url this: /responses/insert?pass=blah&msisdn=blah&sender=blah&message=blah&dca=blah&msg_id=blahsource_id=blah here model: public class response { public int responseid { get; set; } public string msisdn { get; set; } public string sender { get; set; } public string message { get; set; } public string dca { get; set; } public string msg_id { get; set; } public string source_id { get; set; } } can offer advice on how code controller action? // // get: /response/insert public actionresult insert() { return view(); } thanks much! paul edit 1 - solved (thanks lukled) public actionresult insert(response response) { if (modelstate.isvalid) { responserepository.insertorupdate(response); responserepository.save(); return redirecttoaction("index");

MySql insert from one table to another where a field not null -

i have table "phonebook" has 1.5m records, of records have "phonenumber" field empty. i want copy records "phonenumber" field not empty table. due seems simple, cant work. here code: insert phonebook2 (company,zip,city,address,tags,phonetype,phonearea,phonenumber) select company,zip,city,address,tags,phonetype,phonearea,phonenumber phonebook phonenumber != null && phonenumber != ""; i dont error, "0 rows affected". in manual search on records, see null values phonenumber. any suggestions ? ** have tried running same query without part , transfer records should. use is not null instead of != null . source: mysql manual

jquery - Radio Button change event not working in chrome or safari -

i've got radio buttons on page , when yes selected, other controls (dropdowns , textboxes) become visible. if no selected, become invisible again. working fine in ff & ie. work when use mouse chrome, when i'm tabbing through page, controls never become visible. it's if change event doesn't trigger because i'm tabbing. ideas of might causing this, or how i'd go fixing it? the show/hide functionality being done jquery. edit: showing code giving problems. $("#rbtncontrolyes").change(function () { $("#othercontrols").show(); }); found answer this. instead of using .change event, switched .click , worked fine. hope helps someone. slap

sdk - Android: Record an audio stream and retrieve the latency information -

i want write simple test program record audio stream input jack (microphone?). i must calculate audio latency information , show it. i must use ndk or sdk? there exist simple source code me? in end, how can start write it? this might start http://developer.android.com/guide/topics/media/index.html for latency problem might meed use ndk - give lower latency anyway last time checked audio not usable in ndk may have changed

Which version of Android supports HTTPS -

i have 1 wcf web service hosted on https. android versions supports https. know android 2.2 supports https. code older version?? all versions of android let make requests https servers.

php - Is it not good to detect devices, operating systems and browsers Versions by User-agents? -

is not detect devices, operating systems , browsers versions user-agents? can create problem in caching if set expire headers , use wordpress w3 total cache plugin detecting browser version, via user agent strings, bad idea. amongst other things, approach fails new versions of opera , chrome in version 10+ because of double digit version number. it's better practice, , more informative, instead use feature detection. often give information you're trying determine. have @ modernizr library paul irish (of jquery , chrome) , others. mix of techniques html5boilerplate suite needs, whilst being cross browser compatible. you can use css3 @media-queries adjusting site mobile or small screen devices.

iphone - NSString is not getting added to NSMutableArray -

-(ibaction)orderbuttonpressed { mystring = staterlabel1.text; [myarray addobject:mystring]; nslog(@"wat in %@",myarray); } -(ibaction)orderbutton2pressed { mystring2 = staterlabel2.text; [myarray addobject:mystring]; nslog(@"wat in %@",myarray); } after clicking button text in mystring should add nsmutablearray object myarray , not happen. doing wrong? you have typo (ibaction)orderbuttonpressed { mystring = staterlabel1.text; [myarray addobject:mystring]; nslog(@"wat in %@",myarray); } -(ibaction)orderbutton2pressed { mystring2 = staterlabel2.text; [myarray addobject:mystring2]; // <-- change here nslog(@"wat in %@",myarray); } in second method need add mystring2 not mystring

list of jars in tomcat+jpa+hibernate -

i use tomcat 7, deployed there web application jpa , hibernate. jars should copied make work? deployment fails on "classnotfoundexception" or "incompatibleclasschangeerror". i've got following jars: antlr-2.7.6.jar commons-collections-3.2.1.jar dom4j-1.6.1.jar hibernate-annotations.jar hibernate-commons-annotations.jar hibernate-entitymanager.jar hibernate-jpa-2.0-api-1.0.0.final.jar javassist-3.4.ga.jar jta-1.1.jar log4j.jar slf4j-api-1.5.2.jar slf4j-log4j12.jar the following files missing: ejb3-persistence-1.0.2.ga.jar hibernate-core-3.3.2.ga.jar xml-apis-1.0.b2.jar

ruby - How can fixtures be replaced with factories using rails3-generators? -

i'm trying replace fixture generation factories using rails3-generators: https://github.com/indirect/rails3-generators#readme the gem included in gemfile , has been installed: # gemfile gem 'rails3-generators', :group => :development i added following application.rb: # application.rb config.generators |g| g.stylesheets false g.fixture_replacement :factory_girl end yet 'rails g model insect' still generating fixtures ('insects.yml'). working others using rails 3.0.4 , rails3-generators 0.17.4? 'rails g' shows new generators available (such authlogic , koala), 'rails g model' still lists fixtures , doesn't refer factories. what else should add work? thanks. edit : ran gem's test suite, includes test this, , passes. no clue why doesn't work app. edit2 : tried again test project , same result: fixtures instead of factories. if confirm whether works them rails 3.0.4 , rails3-generators 0.17.4, helpful bec

c# - Is it best practice for every property on a class to conform to an interface? -

i increasingly seeing examples of style. happens irrespective of whether interface ever needed. in other case, adoption of new interfaces prove helpful. however, cannot predicted whether used or not new interfaces created new properties conform to... best practice or not? as usual, depends. if you're writing public api, approach extremely powerful. example of progistics / connectship api. @ time used it, there single concrete class. rest of public interface interfaces. able rip out entire implementation of product , rewrite it, leaving interfaces untouched. of course, there cost associated this. have put lot of front time , effort making elegant api if you're going want cast in stone (of course, case whether choose use interfaces or not). on other hand, if you're writing data access layer internal business application, might not reap many rewards.

scrollview - Scrollbars in android -

can 1 tell me how can set scroll view both vertical , horizontal scroll ? you can't. scrollview vertical scroll. horizontalscrollview horizontal scroll.

nullpointerexception - Android Application finish prob -

i using custom alert dialog. if user go negative button of code need close app totally. using following code. public class testapp extends tabactivity { private int tabid = 0; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final tabhost tabhost = gettabhost(); // activity tabhost tabhost.tabspec spec; // resusable tabspec each tab intent intent; // reusable intent each tab intent myint = this.getintent(); tabid = myint.getintextra("tab_id", 0); ....................... ......................... ....................... tabhost.setcurrenttab(tabid); showreward(this); } private void showreward(context c) { // todo auto-generated method stub final alertdialog.builder builder; alertdialog alertdialog;

Advantages of Java's enum over the old "Typesafe Enum" pattern? -

in java prior jdk1.5, "typesafe enum" pattern usual way implement type can take finite number of values: public class suit { private final string name; public static final suit clubs =new suit("clubs"); public static final suit diamonds =new suit("diamonds"); public static final suit hearts =new suit("hearts"); public static final suit spades =new suit("spades"); private suit(string name){ this.name =name; } public string tostring(){ return name; } } (see e.g. item 21 bloch's effective java ). now in jdk1.5+, "official" way use enum : public enum suit { clubs("clubs"), diamonds("diamonds"), hearts("hearts"), spades("spades"); private final string name; private suit(string name) { this.name = name; } } obviously, syntax bit nicer , more concise (no need explicitly define fields values, suitable tostr

HTML Table Header widths seem to be sizing according to proportional width? -

ok, please bear me in explaining this. in code below have fake data values. actual width on screen seems change if add couple more characters, rather fixed have stated 150px. need width fixed. there property can set ensure this? <div id='datatable' style='height:300px;overflow:auto;overflow-x:auto;overflow-y:scroll;width:900px;' onmouseup="matchscroll('datatable','headertable', true);" onmousemove="matchscroll('datatable','headertable', false);" > <table border='1' style='width:2850px;'> <tbody id='cleardetails'> <tr id='row0' style='color:black;height:auto;'> <td style='width:150px;'>testtttt</td> <td style='width:150px;'>te</td> <td style='width:150px;'>test</td> <td style='width:150px;'>test</td>

concurrency - Realworld java app using kilim framework -

is there realworld app using kilim message-passing framework? erjang

javascript - One <span> per character in web-based text editor -

i'm developing web-based text editor without contenteditable , textarea or input things. biggest portion of work measure widths of text on left (right) side current caret position , moving caret in text. for example when user presse down key current left-offset of caret must computed , on line below character which's position similar must found. one convenient way use 1 dom element per character - can @ offsetleft property. also, positioning caret easier. actually, easier. however i'm unsure performance implications . have seen technique (or similar) used on web-based javascript "ide"s , works fine there. do have hints, tips? do know other fast way how measure width of text. want avoid putting sections of line dom element , measuring width each time think slower. edit: i'm asking main fact of existence of many dom elements. how measuring different thing. i've seen done (unfortunately can't find link now) using canvas object

php - Redirects with .htaccess stops images from loading -

ok i'm looking redirect following: http://www.example.org/tag/code to following: http://www.example.org/tag.php?tag=code the following regex mix of of answers question solves issue: options +followsymlinks rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.+)/ $1.php [l,nc] rewriterule (.+)/(.+) $1?tag=$2 [l,nc] however now, when try , load image server within directory http://www.example.org/img/imagename.png . gives me 500 internal server error , when checking logs i'm given message: [wed feb 23 12:27:27 2011] [error] [client xx.xx.xx.xx] mod_rewrite: maximum number of internal redirects reached. assuming configuration error. use 'rewriteoptions maxredirects' increase limit if neccessary. does know what's going on there? thanks above rewriterule add these 2 lines: rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d these tell mod_rew

iphone - iOS: After one animation, all other views start animating -

i have peculiar problem. in ios app i've developed, after running animations below find various other elements of ui animate whenever appear. for instance, once these animations below run, every time navigate new tab in app, ui elements animate top left corner of iphone proper positions. have specified no animations these ui elements in other tabs , in fact elements have no access to, activity indicator in iphone status bar, begin animate on own. what going on? why occur after animation below executed? before running animation (with button press) other ui elements in other app tabs not animate @ when appear, expected behaviour. - (ibaction) btnchosenpostcodeclicked:(id)sender { //prep animations startview.alpha = 1.0; postcodeview.alpha = 0.0; [self.view addsubview:postcodeview]; [uiview beginanimations:@"chosenpostcodeanimation01" context:nil]; [uiview setanimationduration:animationspeed]; [uiview setanimationtransition:uiviewanimationtransiti

In Rails, is the RESTful standard that a GET to /users is for index action, and a POST to /users is for create action? -

i looking rails plugin, , seems create user, html form says <form action="/users" method="post"> and if rake routes it says: users /users(.:format) {:controller=>"users", :action=>"index"} post /users(.:format) {:controller=>"users", :action=>"create"} so looks standard /controller_name perform index action, while post perform create action? 100% standard? there exception? ther answer no rails routs flexible can imagine. but . rails loves rest style. can read wiki http://en.wikipedia.org/wiki/representational_state_transfer rest crud: http://en.wikipedia.org/wiki/create,_read,_update_and_delete so. have got convention resources. can: read list of resources: get /resources read resource: get /resources/:id create new resource: post /resources update resource: put /resources/:id delete resource: delete /resources/:id read resource edit

glob - Perl File Globbing Oddities -

i'm writing script loop through range of numbers, build glob pattern, , test if file exists in directory based on glob. the images nascar car number images, , follow the following pattern: 1_earnhardtganassi_256.tga 2_penskeracing_256.tga here snippet of script using: foreach $currcarnum (0..101) { if (glob("//headshot01/cars/${currcarnum}_*_256.tga")) { print("car image $currcarnum exists\n"); } else { print("car image $currcarnum doesn't exist\n"); } } the problem i'm having, images exist in directory, , should match file glob pattern not. for example, file following name returns not existing: 2_penskeracing_256.tga whereas, following returns existing: 1_earnhardtganassi_256.tga if use same file glob pattern in dos or cygwin, both files listed properly. are file glob patterns interpreted differently in perl? there missing? you need have results returned in list format i

javascript - How to check if a user likes my Facebook Page or URL using Facebook's API -

i think i'm going crazy. can't work. want check if user has liked page javascript in iframe app. fb.api({ method: "pages.isfan", page_id: my_page_id, }, function(response) { console.log(response); if(response){ alert('you likey'); } else { alert('you not likey :('); } } ); this returns: false i'm fan of page shouldn't return true?! i tore hair out on 1 too. code works if user has granted extended permission not ideal. here's approach. in nutshell, if turn on oauth 2.0 canvas advanced option, facebook send $_request['signed_request'] along every page requested within tab app. if parse signed_request can info user including if they've liked page or not. function parsepagesignedrequest() { if (isset($_request['signed_request'])) { $encoded_sig = null; $payload = null; list($encoded_sig, $payload)

php - drupal rewrite is not working installed on subdomain -

i have copied drupal main directory anothre directory , created sub domain url rewrite not working. i have checked mod_rewirte enabled , allow override set can not access pages except home page changed $base_url point sub domain , reflected in .htaccess. please advise can here searched on net nothing seems working thanks if cannot log in turn off clean urls , have access database can edit setting in database. in 'variables' table find row 'clean_urls' , delete row. when setting checked uses default off. in experience breaks when move drupal miss .htaccess file. or if moved directory forsome reason has allowoverride turned off in apache settings.

php - MVC style application architecture catering to API -

i'm working on "community" style website, both fun , profit, , while aesthetic element of coming along nicely, haven't yet sunk teeth working out application logic reasons of unsureness in approach. i'm creating php powered mvc style framework can reuse components of, i've noticed many existing mvc frameworks use sort of "convention on configuration" expedite whole process. queries intend run little more complicated select * entity_name . i want design application in layers, api calls can made server. figured instead of doing twice, build site controllers on top of layer, follows standard. allow ajax calls, remote web application calls, etc., follow same route of request normalization , response document web requests. anyways, perhaps of unnecessary detail, can shed light on api layered mvc architectures of nature? since api level (the model layer) data read/written, want incorporate authentication @ level, or abstract higher level , make e

java me - Can you suggest any good books, online tutorials, etc, for developing with Bluetooth in JavaME? -

i have limited experience javame in past. i've worked in basic ui of javame. have not used bluetooth apis before. organization has assigned me team involved in bluetooth application development in javame. some old pdf: http://www.google.com/url?sa=t&source=web&cd=4&ved=0cdeqfjad&url=http%3a%2f%2fwww.ub.uib.no%2felpub%2f2004%2fh%2f413009%2fmasteroppgave.pdf&ei=9j9lteekpmsaostp7pef&usg=afqjcneccur0vkilzjtal-4p1jryr9fgmg&sig2=zyaakntv7b3z1kw65g9q-q some newer article: http://www.codeguru.com/java/article.php/c13147 again old, maybe useful: http://today.java.net/pub/a/today/2004/07/27/bluetooth.html hope helps little.

iphone - IPA file support prerequisites? -

i have in-house iphone app. developed year , half ago. until now, i'd ship users zip-archived app bundle, instructing them unzip, add itunes library , sync. now, there's fancy new ipa file format simplifies process considerably. question - prerequisites support? require specific version of ios or itunes? if yes, version? preempting questions - yes, support over-the-air installation. itunes-based installation has stay sake of remaining ios 3.x users. it shouldn't, as: an ipa file merely zip file different extension itunes has been using ipa files apps since app store first launched

jquery - JscrollPane Div doesn't work when children Div are called -

using jscrollpane on "master" div, , have content in children divs within div. i'm using jquery show/hide load content onclick, child div won't appear. if remove jscrollpane works fine :( html: <h3 onclick="internalnav('testtwo')">click see div two</h3> <div id="content" class="scroll-pane"> <div id="testone"> <h1>title 1</h1> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> </div> <div id="testtwo"> <h1>title 1/h1> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incid

In Rails, if "before_filter :login_required" works, then why will adding "login_required" to an action not work? -

if using before_filter :login_required works, actions of controller, if comment line out, , so: def index login_required [...] end then server complains can render or redirect once per action. thought using before filter same adding method above. please explain. before_filter , around_filter may halt request before controller action run. useful, example, deny access unauthenticated users or redirect http https. call render or redirect. after filters not executed if filter chain halted. this rails api (filter chain halting). so, if in filter, if render or redirect happens, filter chain halts , rest code not executed. so, error not happen in case. when call method directly, code after method call executed , therefore, error 'render or redirect once per action' happens.

c++ - Official Definition of sscanf() Format String? -

i'm implementing own version of sscanf() in different language (not c or c++). i'm finished. i'm trying wrap of finer details of meaning of format string. however, searching web, i'm finding not documentation sscanf() same. for example, %i handle octal , hexadecimal while others don't include format type. , discuss %[ while others not. in addition, details seem omitted. what authoritative documentation of how format string should interpreted? i'm not fanatical complying standard. compatible existing format strings can. edit if interested, i've published c# implementation of sscanf() code online. see iso/iec 9899:1999 7.19.6.2 (fscanf) - last c standard

selenium - Is there an HtmlUnitDriver for .NET? -

i'm using selenium's webdriver run specflow tests asp.net mvc app i'm working on self-education. using firefoxdriver , chromedriver , etc. take long run, it's pretty frustrating use them (in opinion). i have read htmlunitdriver supposedly faster browser-based drivers; can't seem find version in .net client library (only java). there .net version out there? to use htmlunit need use remotewebdriver , pass in desired capabilities it. iwebdriver driver = new remotewebdriver(desiredcapabilities.htmlunit()) and away go. if want firefox implementation run use iwebdriver driver = new remotewebdriver(desiredcapabilities.htmlunitwithjavascript())

xml - The best XMLEditor available -

i using old version of altova's xmlspy , freezes. know alternative xmleditor (free or not, web or windows) use write xml documents based on xsd file? i can recommend oxygen xml editor .

How to creat album using facebook graph api? -

i've generated url https://graph.facebook.com/me/albums?access_token=123005381082600|2.atn22ptkspb6tn_nad7zwa__.3600.1298494800-602414132|4i62wgohikratipytu4jy7__i9a&type=post&name=refacingme is url correct creating album using fb graph api , , expected response request ? this url getting albums belonging you. if want create album fb api, have write code: 1. step: login , token 2. step: create album basically it's pretty simple. please check out @ related docs here , , sample php code here .

javascript - Only show YUI autocomplete footer when there are 5 results -

i autocomplete display footer says displaying top 5 results when there 5 results being displayed. so far, have set won't display if @ first there less 5 results, once 5 results have been loaded footer displays, regardless of how many results being displayed. please excuse silly flip gimmick. oac.formatresult = function(oresultdata, squery, sresultmatch) { var skey = sresultmatch // extract part of match user did not type var skeyremainder = skey.substr(squery.length); oac.setfooter(""); var amarkup = ["<div class='mycustomresult'>", "<span style='font-weight:bold'>", squery, "</span>", skeyremainder, "<br>", "</div>"]; if (oresultdata[2]

What video format will play on all Android devices? -

android can play variety of video formats , need choose 1 format work on devices. do android 2.3 devices support same formats? i.e. if format play in emulator, mean play on hardware? or different devices support different formats depending on decoder chips have? if same best format h.264 @ high bitrate , resolution. if not, best codec/bitrate/resolution play on 90% of devices? google provide way of querying device's video capabilities , choosing appropriate format? the emulator poor test of codecs , isn't functional in few areas. , yes device manufacturers may add additional codecs build of android. may want check out android compatibility , read compatibility definition document more details required manufacturer android market on device. unfortunately quick through doesn't state minimum bitrate depending on how old version of android willing support may have issues there.

validation - How to create immutable objects in C#? -

in question best practices c# pattern validation , highest voted answer says: i tend perform of validation in constructor. must because create immutable objects. how create immutable object in c#? use readonly keyword? how work if want validate in constructor of entity framework generated model class? would below? public partial readonly person { public person() } the interesting question here question comments: what kind of object have not need modify values @ point? i'm guessing not model class, correct? i've had change name of person in database - wouldn't fit idea. well, consider things immutable. numbers immutable. once have number 12, it's 12. can't change it. if have variable contains 12, can change contents of variable 13, changing the variable , not the number 12 . same strings. "abc" "abc", , never changes. if have variable contains "abc", can change "abcd", doesn't chang

android - Can Honeycomb Loaders solve problems with AsyncTask + UI update? -

doing in background , updating ui hard implement correctly in android. it's badly designed. typical example asynctask fetches web , displays result. there 2 problems this: the asynctask has reference activity (because needs update ui). after screen orientation change, activity restarted. asynctask still references old destroyed activity therefore can't update ui of new activity. this can lead outofmemoryexception. imagine have activity lots of bitmaps , start asynctask. press (activity finished) asynctask still running , because references activity, activity bitmaps still in memory. repeat (start activity , back) , have force close sooner or later. this can solved, way complicated. in 1 activity have 3 different asynctasks, each of them can running in several instances simultaneously. implementing correctly frustrating. code becomes hard understand , debug. can honeycomb loaders somehow solve this? , there way use them in pre-honeycomb android versions? y

database - how to use sql along with vb.net -

i doing first time, how use sql via vb.net insert, update , delete data in database. need set before can use sql? if shift executable app different computer need install sql in computer well? there a number of tutorials can started. as running applications on different computer, depends on database located. database , application 2 separate things, latter accessing former. can other target computer access database? database installed on server accessible target machine? long can see database , config file correct, should work fine.

ruby - Carrierwave - Error when processing images -

the problem following error thrown on mongoids save! action. mongoid::errors::validations: validation failed - img failed processed. ~/.rvm/gems/ruby-1.8.7-p249/gems/mongoid-2.0.0.rc.7/lib/mongoid/persistence.rb:234:in `fail_validate!' ~/.rvm/gems/ruby-1.8.7-p249/gems/mongoid-2.0.0.rc.7/lib/mongoid/persistence.rb:75:in `save!' ./app.rb:29:in `post /upload' the setup following: require "sinatra" # 1.1.2 require "mongoid" # 2.0.0.beta.19 require "rmagick" # 2.12.2 require "carrierwave" # 0.5.1 require "carrierwave/orm/mongoid" require 'carrierwave/processing/rmagick' .... mongoid.database = mongo::connection.new('somehost', 1234).db('test') class uploader < carrierwave::uploader::base include carrierwave::rmagick storage :file def store_dir "uploads" end process :resize_to_fit => [80, 80] end class image include mongoid::document mount_uplo

iphone - Weird behavior of hidesBottomBarWhenPushed = YES (moves views when popping back) -

so i've got weird going on here, , can't quite put figure on it. basically, i've got view has 2 subviews: 1 webview, other button controller see here bug: http://screencast.com/t/ztjaup8axgz now when pushviewcontroller controller , pop back, works fine, except when pushviewcontroller view controller (the 1 magnifying glass). when that, see following bugs: the webview gets 20 pixels shorter the button controller gets pushed 7-8 pixels. i've isolated down fact when tab bar hidden (with hidesbottombarwhenpushed = yes), bug no longer seen: http://screencast.com/t/vargpr4u what cause this? bug in hidesbottombarwhenpushed ? if so, how can compensate it? with little bit of debugging, ended finding out subview in question growing 10 px, being shifted -5. i wasn't updating height of view anywhere - coworker suggested turn off autoresizessubviews (which did in nib of parent controller). fixed issue. presumably, parent (containing) contro

android - Emulator Settings Menu doesn't work -

using level 11/3.0 emulator, 'settings' menu doesn't work. click on item eg. 'sound' or 'screen' , nothing happens beyond momentary high-lighting of item. in eclipse, logcat entry appears info/activitymanager(73): starting: intent { act=android.intent.action.main cmp=com.android.settings/.settings (has extras) } pid 375 and nothing else. what's going on here??? want change language settings default chinese! update: i've got screen set normal size(320x480) instead of default(and option) wxga. works fine if use wxga setting - new windows open etc. ver 3.0 tablets? thought system supposed gracefully accommodate different-sized screens. installed because ver 2.3 doesn't javascript bridge or location spoofing. it works me. make sure have "device ram size" setting avd set high. default 256, recommend 1024 (mb) if can spare it. can adjust via sdk , avd manager.

iphone - Object leak using "retain" -

i have property defined retain attribute synthesizing: @property (nonatomic, retain) uiswitch *myswitch; and inside loadview doing this: self.myswitch = [[uiswitch alloc] initwithframe:cgrectmake(0, 0, 40, 20)]; and inside dealloc doing this: self.myswitch = nil; am leaking object (myswitch) have used 1 alloc? should autorelease while assigning frame? please suggest. the line: self.myswitch = [[uiswitch alloc] initwithframe:cgrectmake(0, 0, 40, 20)]; actually calls retain twice - once alloc , again in assignment self.myswitch (which property you've specified should retain values assigned it.) fix have been told best add call autorelease on line, making it: self.myswitch = [[[uiswitch alloc] initwithframe:cgrectmake(0, 0, 40, 20)] autorelease];

expressionengine - Template Groups in Expression Engine -

does know how ee determines path given template group modules. example, have installed module , there template files uses outside of templates directory use. not trying understand how works, how remove reference can move templates own directory. hmm. i'm pretty sure sort of information exist within each module's folder. if you're using ee2.x, folders within /system/expressionengine/third_party/ . if you're using ee1.x, folders within /system/modules/ . don't think i've come across module renders own templates inside of own before. may ask module you're using?

problem with jquery ajax while loading data in django page -

why following jquery code doesn't work when used django while works if loaded static page? there's django's csrf protection involved somewhere, can't find how make work. edited, stripped down code: $(document).ready(function(){ $('.content').load('something.txt'); $.ajax({ method: "get",url: "http://something.com/pm/js/something.txt", success: function(html) { $(".content").html(html); } }); }); the purpose of should be: when django page loads, script should call django view(s) , load data them. (at moment make easier 'something.txt' static file) ...firebug doesn't show abnormal i'm going take wild guess: maybe when load page django don't have static file serving setup properly, jquery never gets loaded, , such none of javascript gets executed. to check , see if jquery getting loaded open firebug on page , see if jquery varia

java - JAXB : XmlElementWrapper nested nodes -

i want generate xml : <mainnode> <node1></node1> <node2></node2> </mainnode> <mainnode2></mainnode2> and how generate mainnode1 , mainnode2 , node1 in code: @xmlelementwrapper(name = "mainnode") @xmlelement(name = "node1") public list<string> getvalue() { return value; } @xmlelement(name = "mainnode2") public string getvalue2() { return value2; } how add node2 mainnode1 ? you don't seem have root element in example. obtain structure want:- @xmlaccessortype(xmlaccesstype.field) @xmlrootelement class node { private mainnode mainnode; private mainnode2 mainnode2; public node() { } public node(mainnode mainnode, mainnode2 mainnode2) { this.mainnode = mainnode; this.mainnode2 = mainnode2; } } @xmlaccessortype(xmlaccesstype.field) @xmlrootelement class

branch - How to partition a git commit in two, based on same parent? -

i'm on branch foo, parent a: ---a---foo i want partition changes foo 2 branches, both based on a. believe can half job this: git checkout -b halffoo git reset head~ # choose half stuff. git add -i git commit that gives me: ---a---foo \ \-halffoo i know how (git checkout -b otherhalffoo; git commit -a): ---a---foo \ \-halffoo \ \-otherhalffoo but i'd this: ---a---foo |\ | \-halffoo \ \-otherhalffoo' how can without having go through 'git add -i' (and selecting negative of chosen halffoo) again? first, rewind previous commit, leaving in changes since. branch off , apply of changes. branch off original branch again, , apply rest of changes. git branch original_tip_with_foo # if want reference foo commit git reset head~ git stash git branch branch_2 # we'll there in moment ... git checkout -b branch_1 git stash pop git add -p # ... add first set of changes, first branch ... git co

plugins - Disable activex alert popup -

Image
this security alert popup getting triggered every time when use activex in our page, preventing displaying in browser. i want disable alert popup. should allow page load without prompt. how can change settings stop alert? tools -> options -> advanced [tab] scroll down security and check allow active content run files n computer. are going in of user's pc? hope intranet application , have control on user's pc. if internet website. forget it! :)

trouble with SWITCH javascript always executing default case -

well have trouble , ive been dealing cant work i have function function getdirections(dir) { var img; switch(dir) { case 0: img+='n.png'; break; case 1: img+='ne.png'; break; case 2: img+='e.png'; break; case 3: img+='se.png'; break; case 4: img+='s.png'; break; case 5: img+='so.png'; break; case 6: img+='o.png'; break; case 7: img+='no.png'; break; default: alert('enetered default direction='+dir); } return img; } quite simple right? have interval set 5000 ms call getdirections(variable), function works first time called after , enter in default clause , alerts 'entered default direction=dirvalue' , mean if dir value between 0-7 enter default: alert value supossed enter 1 of cases. i made same using else if , worked dont know wrong switch if(dir==0){img+='n.png';} else if

compiler construction - Is C open source? -

this stupid question, i've been wondering while. c (or other low-level language, matter) have source, or compiler part "does work", including parsing? if so, couldn't different compilers have different c dialects? stdlib factor this? know how works. the c language not piece of software defined standard , 1 wouldn't it's open-source, rather it's open standard. there gazillion different compilers c however, , many of indeed open-source. notable example gcc's c compiler , under gnu general public license (gpl) , open-source license. there more options. watcom open-source, instance. there no shortage of open-source c compilers, without doubt widespread one, @ least in non-windows world, gcc. for windows, best bet watcom or gcc using cygwin or mingw .

Python's Reduce Function - Written in Scheme -

evening! i need write reduce function in scheme works built-in reduce function in python. it's easy write reduce function in scheme: (define (reduce fn lis identity) (if (null? lis) identity (fn (car lis) (reduce fn (cdr lis) identity)))) however, code isn't identical python reduce , takes 2 arguments (the function , list of items reduce). can help me write scheme function works way? (>(reduce * '(2 4 5 5)) => 200, our professor's example.) thanks much, guys , gals. helpful <3 eta: mr. levien , mr. jester-young, thank much. provided perfect amount of information me figure problem out on own. *hug that easy. accumulator initialized first element of list: (define (py-reduce f ls) (fold f (car ls) (cdr ls))) (py-reduce * '(2 4 5 5)) => 200 feel free use reduce function fold srfi-1 (like reduce, fold-right ...) or use own. list needs 1 element @ least.

database - Is Redis right for storing and retrieving messages against user a la twitter? -

i'm building web app - in php - need pull down messages twitter , various other services (email, sms). i'm writing small service in node.js handle twitter connection etc. trying work out best content pulled down. right i'm leaning towards combination of mysql our standard info main php app , redis node.js service store each message against key username , sort of unique identifier. i've used redis before data needs persist rather being can expire sessions. redis' in memory nature makes me bit nervous as, on time, being our main message store dataset become unruly in ram, not? this blog post gives , concise overview nosql-type databases. perhaps can find confirmation or alternative redis there. since have not given numbers on how many , how need pull data sources, it's hard answer side. and, redis supports 2 methods of persistence: timed snapshots , append-only journal files changes db written to. second 1 safer alternative.

How website can track users even after clearing browser cookies -

i banned forum asking first question, indeed stupid one. later created new logins, cleared browser history, changed ip address, still forum catches me , gives warning "you're banned". how able track me? seems eying me cam. it ip address, surprised if rely on track given user, given many users' ip address change 1 day next, because of block ip address allocation. a few other possibilities: lso (a.k.a., 'flash cookie') not stored in browser-specific directory. local storage , stored in localstorage directory 1 level below directory each browse, , have extension localstorage (on mac, anyway). both of these have stored in different directory default browser cookies , both have far higher storage capacity cookies way. there's nothing inherently 'stickier' either of these versus cookies, other fact not stored in same directory cookies , major version of major browsers include simple user-preference settings remove cookies--i

PHP Caching Question -

i worked on project on .net , part of code involved reading header , footer pre-defined format consistency across various websites shared same client. i faced similar problem in php. contents of header/footer links using: <?php $contents = file_get_contents('http://www.mysite.com/common/footer.asp'); echo $contents; ?> is there way can load cache avoid repeated calls http://www.mysite.com/common/footer.asp cheers if looking cache across many page loads, use session. session_start(); $_session['somekey'] = value; or persistent storage flat file , database or memcache .

c# - Send Information from my computer to my phone -

if wanted able sync computer phone. send messages computer phone (texts messages , custom phone application) parameters need connect 2. , find information on how might this? it seems me use of word "sync" in context going confuse people. i think (if understand correctly) want have custom phone app, can "talk" custom app on computer or server. correct? if so, in concept you'll need do. build custom phone app can talk "tcp/ip" (either known protocol such http or custom tcp/ip protocol design, if you're not done tcp/ip before complex). build custom application runs on desktop. if you're decided use http, app asp.net application or wcf application (self hosted or iis hosted) in scenario, phone app 1 can initiate communication because tcp/ip client (it doesn't have it'll simpler build initially). desktop application have running prior phone app attempting "connect". since tcp/ip server application. the phone

sql server - To Get Trigger script source from VB6? -

i want trigger script source vb6. database using sql server2000. have trigger in table. want trigger script @ run time vb6. possible? if yes please can me. advance in thanks you can triggers on table (or view) this select name sysobjects parent_obj = object_id('mytablename') , xtype = 'tr' than can source t-sql of trigger (or stored procedure) using this exec sp_helptext 'mytriggername'

opengl - Changing color using a shader -

i writing deferred shader , 1 of first steps, familiar glsl , using shaders , framebuffer trying change color of mesh through shader. have linked 1 of buffers calling gldrawbuffers array holds attachement , binding texture framebuffer: glreadbuffer(gl_none); glint color_loc = glgetfragdatalocation(pass_prog,"out_color"); glenum draws [1]; draws[color_loc] = gl_color_attachment0; gldrawbuffers(1, draws); glbindtexture(gl_texture_2d, diffusetexture); glframebuffertexture(gl_framebuffer, draws[color_loc], diffusetexture, 0); i have out_color variable in fragment shader (otherwise wouldn't compile), can't manage change color of mesh setting through variable inside shader. has idea why , explain me? thanks edit: shaders: vertex shader #version 330 uniform mat4x4 u_model; uniform mat4x4 u_view; uniform mat4x4 u_persp; uniform mat4x4 u_invtrans; in vec3 position; in vec3 normal; out vec3 fs_normal; out vec4 fs_positi

facebook iframe compatibility jquery plugin list -

anyone can share expiriance jquery plugins , facebook iframe developing? please write here plugin names worked list of good-known plugins , save time... you can use jquery iframe, there lots of choices, fancybox has iframe, simplebox, or html work.

javascript - How to get an IFrame src attribute value from ASP.Net code behind? -

on asp.net code behind page have generated source , want value of src attribute of iframe on html page? on page: <iframe runat="server" src="test" id="myframe"></iframe> on code behind: string source = myframe.attributes["src"];

caching - Django: Cached items not accessible between processes? -

i have problems using django cache. looks cached items not readable between processes. design? haven't found information on it. testing on production server using 2 ssh sessions in parallel, , setting cache in 1 , reading in other using memcache backend (also tested file based backend), , result: (session 1): >>> django.core.cache import cache >>> cache.set('foo','bar') >>> cache.get('foo') 'bar' (session 2): >>> django.core.cache import cache >>> cache.get('foo', 0) #cache has not been set yet... 0 >>> cache.get('foo', 0) #cache has been set in other session, expect 'bar' here 0 i use low level cache api cache processed results of uploaded file. user complete more steps describe uploaded data @ point it's entered in db. done asynchronously using apache2 1 thread per process, mod_wsgi , python 2.5. problem ran in "cache.get('<filekey>'

objective c - iPhone SDK : How to remove the horizontal markers from Core-Plot? -

Image
i have implemented core-plot in iphone app. using gradient scatter plot shown below: how remove horizontal markers appear on y axis of graph in above core plot? set majorticklinestyle , minorticklinestyle properties nil .

java - how install maven on eclipse -

i want install maven plug in on eclipse. when add maven site in install software section, , beginning download , install it, error occurred dependency. how can fix it? want complete installation guide... first dependencies missing? maven plugin eclipse eclipse maven sonatype, m2eclipse .

java - Implementation of BlockingQueue: What are the differences between SynchronousQueue and LinkedBlockingQueue -

Image
i see these implementation of blockingqueue , can't understand differences between them. conclusion far: i won't ever need synchronousqueue linkedblockingqueue ensures fifo, blockingqueue must created parameter true make fifo synchronousqueue breaks collections method (contains, size, etc) so when ever need synchronousqueue ? performance of implementation better linkedblockingqueue ? to make more complicated... why executors.newcachedthreadpool use synchronousqueue when others ( executors.newsinglethreadexecutor , executors.newfixedthreadpool ) use linkedblockingqueue? edit the first question solved. still don't understand why executors.newcachedthreadpool use synchronousqueue when others ( executors.newsinglethreadexecutor , executors.newfixedthreadpool ) use linkedblockingqueue? what is, synchronousqueue, producer blocked if there no free thread. since number of threads practically unlimited (new threads created if needed), never happen. why sh