Posts

Showing posts from April, 2010

android - How to identify type of SIM? -

i developing application need check type sim based on need perform calls . able network type not able type of sim using. determine type of sim card sim / uim / usim: / / simtype    string simtype = "unknown"; / / system, obtain sim data    telephonymanager tm = (telephonymanager) context.getsystemservice (context.telephony_service); / / cell phone simtype    int type = tm.getnetworktype ();    / / determine type of value, , named   if (type == telephonymanager.network_type_umts) {    simtype = "usim"; / / type defined umts usim card wcdma    } else if (type == telephonymanager.network_type_gprs) {    simtype = "sim"; / / type defined gprs gprs sim card    } else if ( type == telephonymanager.network_type_edge) {    simtype = "sim"; / / type defined edge-edge sim card    } else {    simtype = "uim"; / / type unknown definition of uim card cdma    }

pg: 172-175 Multiple Interfaces, Stroustrup, C++ Programming Language, 3E -

i having difficulty making sense of this! trying in this? page 172-173, create single namespace 2 interfaces (parser, parser-prime). stick each interface in different header file (parser-implementer.h , parser-user.h). parser-user.h has smaller namespace definition , parser-implementer.h has larger (implementer) namespace definitions. why that: "compiler doesn't have sufficient information check consistency of 2 definitions of namespace."?? if actual implementation in: parser-crud.c, should: #include <parser-implementer> way compiler guarantee c-definitions matched declarations in header.. of course parser-user.h not checked.. he's saying?? then on pg:174(lower half), how parser_interface dependent on parser::expr?? doing here???? doing: #include <parser-implementer.h> // gets namespace parser scope namespace parser_interface { using parser::expr; } pg 175 (top line) how driver "vulnerable" change in parser_interface interf

php - Codeigniter Trim Image -

i using upload class codeigniter comes with: $config['upload_path'] = getcwd() . '/public/images'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $config['encrypt_name'] = true; $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { echo $error = array('error' => $this->upload->display_errors()); } else { echo $data = array('upload_data' => $this->upload->data()); } it works fine uploading file trim white space image. looked @ image manipulation class not seem it. looked around , found crop whitespace image in php . unsure though how put 2 together. ideas? you're right, image manipulation class doesn't support doing that. you can, however, extend library (bottom of http://codeigniter.com/user_guide/g

jarsigner - C/C++ code or Bash script to sign jar files -

is there c/c++ code or bash script can sign java .jar files without using jvm? such code might useful embedded applications serve jar file small http server, or other situations jar file might need edited , re-signed programmatically there insufficient storage space jvm. does need type of javaless jarsigner?

android - How to Pass object from sub activity to main activity? -

from activitya i'm starting activityb. in activityb i'm creating new serializable object. after object has been created want close activityb , pass new object activitya. how can it? start activity b startactivityforresult() . in activity b, when object created create intent pack object in: intent result = new intent(); result.putextra("result", object); setresult(result_ok, result); then receive intent in onactivityresult() method of activity a, can extract so: data.getserializableextra("result");

localization - Umbraco 5 Localize text in Surface Controller -

i've created newsletter subscription form in umbraco 5 using surface controller. controller renders form input fields user. when translate text in view works fine. can use: umbraco.getdictionaryitem("newslettertitle") or @("newslettertitle".localize()) when handle form submit need send localized email. localizing text doesn't work: example: var mail = new mailmessage(); mail.from = new mailaddress(settings.smtp.from); mail.to.add(asubscriber.email); mail.subject = "newslettersucces".localize(); the subject of mail = (umbraco.cms.web.newslettersucces). no localization. same happens when use getdictionaryitem("newslettersuccess"). advice appreciated. you can push umbraco helper in view need umbraco.getdictionaryitem. created basesurfacecontroller like: public class basesurfacecontroller : surfacecontroller { public umbracohelper umbraco{ { irendermodelf

c++ - Automatically extend file size when seeking / writing to a location on a read/write fstream -

i'm working on legacy code uses win32 writefile() write random location in binary file. offset of write can past end of file in case writefile() seems automatically extend file size offset , write data file. i'd use std::fstream same, when try seekp() appropriate location, past end of file, seekp() fails , subsequent write() fails well. so seems me have 'manually' fill in space between current eof , location want write to. the code looks this: void save(size_t offset, const element& element) { m_file.seekp(offset, std::ios_base::beg); m_file.write(reinterpret_cast<const char*>(&element), sizeof(element)); if (m_file.fail()) { // ... error handling } } so option 'manually' write 0 s current eof offset ? here example picked verbatim msdn : // basic_ostream_seekp.cpp // compile with: /ehsc #include <fstream> #include <iostream> int main() { using namespace std; ofstream x(&qu

Export to Excel using SAS -

suppose have 2 sas dataset: test1.sas & test2.sas. want export these 2 dataset excel, in excel file sheet1 have test1.sas data & in sheet2 have test2.sas data. how it? start this paper . this , this references. using ods, can output data using reporting procs (ex. proc print , report) xml. not can create multisheet output, can format dates, set autofilters , place headers.

Javascript : Coding standards, Pascal Casing or Camel Casing? -

i creating calling function , passing in array of objects unsure if use camingcasing or pascalcasing. here method util.load({ defaulttext:'empty', items:[ { id:0, title:'press' } ] }); if notice passing in defaultext, should defaulttext? , items, should items? , within items , passing in id , title. can confirm correct way of doing this? i know methods camelcasing passing in objects above? thanks in advance the popular javascript convention use pascalcasing call constructors (classes), example string, number, date , camel casing variable names , object keys. code convention used built-in javascript functionality in modern browsers, thats why recommend use own code too.

apache - Mod Rewriting - really stuck -

the site i'm talking subdirectory of main site. site/index redirects index.php . site/gallery redirects gallery.php . now, i'd site/gallery/question/answer link site/gallery.php?question=answer . question can have 2 possible values, answer can have several hundred. because it's site/gallery (without end slash), site/gallery/question/answer doesn't load properly. , when rewrite work (with end slash), have re-do of images , links in html , css parts work that, because else it'd redirect main site (because of additional slash). there solution? how about: rewriteengine on rewritecond %{request_filename} !-s rewritecond %{request_filename} !-l rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^gallery/(q1|q2)/([-a-za-z0-9=_]+)$ index.php?$1=$2 [l,nc,ne,qsa] rewriterule ^gallery$ gallery.php [l,nc,ne,qsa] attached index.php <?php print_r($_get); die();

data binding - When is DataBind called automatically on an ASP.NET page? -

i have gridview on page search button. gridview not visible start user must click search before results retrieved. datasourceid set id of objectdatasource. when click called, following method called click handler: private void populategrid() { gv.visible = true; gv.databind(); } a problem occurs when same method called page_load handler. store user's search terms in session , retrieve them first time page accessed, this: if(!postback && session["search"] != null) { setsearchfromsession(); populategrid(); } the problem in case objectdatasource's selecting event fired twice. once when gridview made visible, , again when databind() called. fixed substituting gv.visible = true ; populategrid(); in page_load. but i'd understand going on. why setting gridview visible page load result in databinding when call in button click event doesn't? if declaratively set datasourceid going called after prerender , if call databind c

removing a git submodule -

i want remove git submodule. found question answers how had questions process. in knowledge, removing reference .gitmodules should remove .git/config see .git/config (in the top level) gets updated on running "git submodule init". so, why can't remove .gitmodules , git rm --cached ? another question when did that(just remove .gitmodules), on running git submodules init, see failure git tries initialize submodule want remove. i understand process , how if can give more info. on it, great. have googled on , seen similar questions on stackoverflow. i think way is, not answers marking right 1 close it.

javascript - jQuery animate - get future position of element -

i'm having trouble getting position of element because animation long , $(this).position().top calculated early. how can future position value of element before animates position? that's not want. want position of element after animation has completed. need add callback function animation, , call position inside callback function. here go -> $("whatever").animate({ //do stuff animation }, 'delay', function(){ //our animation has completed, our callback function. //we can our position. $(this).position().top }); hope helps! also please consider improving accept rating, 20% either means questions poorly formatted, or aren't following community guidelines. please read faq understand interacting stackoverflow.com https://stackoverflow.com/faq side note: you badge 'analytical' reading entire faq. highly suggest it.

facebook - This API call requires a valid app_id -

i got wierd going on. have 2 facebook api calls (using facebook php-sdk) next each other. first call goes fine, second throws exception: "this api call requires valid app_id" previous api call requested access token offline_access , publish_stream. token valid because api calls next "problem call" fine. make things clear, small snippet of code: // call goes fine! $user_info = $this->facebook->api('/'.$user_id ); // create wallpost facebook $wallpost = array( 'message' => 'some message', 'name' => 'shoppe', 'caption' => "ik heb een product toegevoegd", 'link' => site_url(), 'description' => $description, 'picture' => site_url("assets/img/logo.png") ); // throws exception

http live streaming - what profile / resolution should the video be in? so that Android's Emulator 3.0 can play HLS streams -

i have android 3.0 version installed on eclipse ide, on when test apple's sample hls link: "http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8" runs successfully. i have created 1 custom file "maqm.m3u8" reading apple's specification hls ref: (https://developer.apple.com/library/ios/#documentation/networkinginternet/conceptual/streamingmediaguide/introduction/introduction.html) but used free encoding (using ffmpegx) , segmenting (open source segmenter) methods create custom .m3u8 file. when test .m3u8 file uploading on server (www.simsanraj.comlu.com/maqm.m3u8) played on safari 5.0.3 , on ipad2. however, same stream when test on android emulator (using same code played bipbop sample file successfully), emulator crashes. following logs generated: i/stagefrightplayer( 33): setdatasource('httplive://www.simsanraj.comlu.com/maqm.m3u8') i/livesession( 33): onconnect 'http://www.simsanraj.comlu.com/maqm.m3u8'

python - Good Django apps source code to read -

i created first django app. felt of code not designed/organized. wondering django apps guys recommend read/study see how apps should created (i'm pretty new django though, understanding huge apps might little hard me). thanks i have found django example tutorials useful work through when starting out django. there range of different applications work through.

c# - What is behind a silent failure to load resource on x64 bit machine with .NET 4.0? -

a user of program has reported inability startup application. not yet done troubleshooting, i'm baffled. logging still works, used logging statements , able narrow down crash single line in user control's initializecomponent: this.horizontalbox.image = ((system.drawing.image)(resources.getobject("horizontalbox.image"))); here relevant clues end: 64 bit windows 7 correct .net framework (4.0 client profile) no visual elements ever show, , no error dialogs. silent shutdown when starting. logging works, there no logged errors. he has uninstalled , reinstalled .net 4.0 client profile framework. he doesn't have visual studio or other development tools mucking stuff. i have spent week or eliminating theories , i'm becoming confused , desperate. here relevant details , things have found: i targeting x86 explicitly. the logging failed log exception set catch , log unhandled exceptions , thread abort exceptions. whatever killing applicati

visual studio 2010 - The type or namespace name UpdatePanel does not exist in the namespace System.Web.UI -

i'm working on website built developer targets asp.net 3.5. i'm trying add update panel around bit of code, whenever attempt error posted in title. i've tried including ajaxcontroltoolkit dll no luck. the following referrences web config file: <compilation debug="true"> <assemblies> <add assembly="system.design, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a"/> <add assembly="system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add assembly="system.web.abstractions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> <add assembly="system.core, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/> <add assembly="system.data.linq, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/> <add assembly="sys

Google Maps V3 Geolocation Rails 3 gem 'geocoder' addresses not correct -

i'm using google maps v3 , it's not having trouble getting exact geolocations, it's not finding correct city (even missing more 50 miles in cases). the way i'm using google maps in rails 3 app gem 'geocoder'. feel pretty sure it's not geocoder gem that's causing google maps off, think i've had problem in google maps v3 before. my question: there better experience determining user's location? should use browser's built in geolocation features? or should using combination of google maps geolocation , browser's geolocation functions? i imagined scenario ask user if town correct, , if not enter town, store town in database, seems poor user experience. hope make app on mobile devices in future, wouldn't of problem, it's web app. anybody else have system dealing apps rely on user's location? thanks! i ran same problem geocoder. me appeared not interpret address correctly in cases. if sent '250w 450n' str

java - Primefaces: adding growl into my view -

i'm implementing web app using primefaces components in view part. problem comes when want use < p:growl > anywhere, have error when page loaded. firebug says: "widget_j_idt25_headlogin_messages not defined". looks when primefaces generated, javascript trying use component, finds it's not defined. however, when remove tag works , jsf error messages displayed. i'm using primefaces 3.1.1 library, ideas how solve issue? here you've code: <?xml version='1.0' encoding='iso-8859-15' ?> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:form id="download_manager_form"> <p:growl id="messages" /> <p:ajax event="click" update="messages"/> <p:

canvas - How to set focus on a Vbox's specific child in flex 4 -

i have vbox contains several grids children. have scroll see grids. there buttons in grids. if press of button, shows children grid's removing grids vbox , fill children of grid's. there button remove children , fill vbox previous grids. when press button want come specific grid clicked see it's child. if @ bottom of scroll when see grid instead of top grid.but shows me top grid. tried setfocus method. not work. i have canvas root parent , 1 vbox child. , vbox contains grids. , if press button of grid vbox have grid's children explained above. children of grid grids. please this. pretty stuck in here. in advance :) setfocus() method activates component , not scroll viewport. can use var spdelta:point = datagroup.layout.getscrollpositiondeltatoelement(index); if (spdelta) { datagroup.horizontalscrollposition += spdelta.x; datagroup.verticalscrollposition += spdelta.y; } where datagroup can vgroup . if doesn't work or not want, can tr

How can I change the git message of my 1 push in github? -

my environment: i working team on github private repository. we have master branch. reproduce problem: i made change (i talking single , not muilticase) , add+commit+push github private repository. i saw message in github after push - , have mistake want change. how can change message of push? edit: important me no history left of mistaken message. edit2: files pushed in github repository , not in local repository tl;dr git commit -v --amend git push -f this allow edit last commit message, , replace commit on remote edits. however you better off pushing correction. the way change existing commit is: git add changed # example, add changed commit git commit -v --amend # launch editor, edit commit message that allow edit last commit (either contents, or commit message) you'll find can't push remote, when try it'll rejected warning this: ! [rejected] master -> master (non-fast-forward) error: failed push refs 'g

security - .swf vulnerabilities in magento -

security scan (by godday) reported following files vulnerable. /skin/adminhtml/default/default/media/uploader.swf as solutions, has suggested recompile .swf using latest flash. since compiled magento , don't have .fla. how fix issue? any suggestion? found solutions here, have apply patch .swf file. patch provided adobe http://kb2.adobe.com/cps/915/cpsid_91544.html

c# - Model validation based on the DataType -

i have project, classic 3 tier structure: datastore, businesslogic, web-frontend in datastore have model (simplified) e.g. configmodel.cs: public class configmodel { [datatype(datatype.emailaddress)] public string defaultsenderemail { get; set; } public ipaddress fallbackdns { get; set; } } here comes question: what's elegant way programmatically add validators according either actual datatype, or datatype attribute? a few answers have considered myself far, did not find them satisfactory: add [emailaddress] validation attribute parameter: don't want duplication , don't want reference mvc specific code in datastore layer. make separate viewmodels , use automapper: since of models lot more complex that, i'd hate make specific viewmodels. thanks! i consider using automapper, not answer solution. maybe can consider this: http://weblogs.asp.net/srkirkland/archive/2011/02/15/adding-client-validation-to-dataannotations-datatype-a

c# - I am merging two Word documents with OpenXML SDK but get a corrupt document when copying an image into a header -

i have code works in sorts of different situations, including when copying images body of document. the code works when copying (adding) headers , footers 1 document other, long headers/footers being copied not contain images. when copy header has image in it, resulting file corrupt, , when try open openxml sdk throws exception saying "compressed part has inconsistent data length". know image has created in headerpart (as against maindocumentpart when copying body). the code merging of image looks like: private void addsourceimagestodestination(xelement sourcexml, openxmlpart sourcepart, openxmlpart destpart) { foreach(xelement drawingelement in sourcexml.descendants(_mswdrawingelementname)) { xattribute ablipembedattribute = drawingelement.descendants(_ablipelementname).first().attribute(_embedattributename); string relationshipid = ablipembedattribute.value; imagepart sourceimagepart = (imagepart)sourcepart.getpartbyid(relation

Gearman jobs are passed to more than one worker (PHP) -

i have problem in php application gearman jobs passed more 1 worker. reduce code reproduce 1 file. not sure if bug in gearman or bug in pecl library or maybe in code. here code reproduce error: #!/usr/bin/php <?php // try 'standard', 'exception' or 'exception-sleep'. $sworker = 'exception'; // detect run mode "client" or "worker". if (!isset($argv[1])) $smode = 'client'; else $smode = 'worker-' . $sworker; $slogfilepath = __dir__ . '/log.txt'; switch ($smode) { case 'client': // remove queued test jobs , quit if there test workers running. prepare(); // init greaman client. $client= new gearmanclient; $client->addserver(); // empty log file. file_put_contents($slogfilepath, ''); // start worker processes. $apids = array(); ($i = 0; $i < 100; $i++) $apids[] =

php - append two methods in flickr -

i have use 2 methods flickr achieve desired result; "the photos.search method" returns photo id while "geo.getlocation method" returns long , lat value of each photo id. able iterate search each photo id within search area. question how iterate each photo id in "geo.getlocation method" latitude , longitude values. find below php code returns each photo id: <?php $url = ("http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=ff8c4c178209865b1ac5ee3f2d492de0&lat=51.5424&lon=-0.1734&radius=2&page=1&text=flats"); $xml = simplexml_load_file($url); foreach ($xml->photos->photo $entry) { echo $entry->attributes()->id; echo $entry->attributes()->owner; echo $entry->attributes()->title; } ?> the rest request format geo.getlocation method is: http://api.flickr.com/services/rest/?method=flickr.photos.geo.getlocation&api_key=xxxx&photo_id=[value] yemi

android - Very sloe FPS on IceCream Sandiwch but Perfect on previous version -

i using andengine 1 , developed app running on 55+fps when ran on icecreamsandwich becomes slow fps <5. can 1 me possible solution? try using ddms profile application , see calls taking time in each frame. way you'll able tell actual problem instead of guessing @ it.

c# - Selenium Webdriver wait on element click? -

i have been searching solution this, no avail. have button i'm clicking, taking long while return data, , driver timing out , killing app guess. i trying use webdriverwait class accomplish this, click() method not available in way i'm using it. webdriverwait wait = new webdriverwait(browser, new timespan(0, 5, 0)); bool clicked = wait.until<bool>((elem) => { elem.click(); //doesn't work return true; }); the implicitlywait() method waiting elements load, times out on click(), can't element. the setscripttimeout() method works executing javascript, i'm not doing. does know of way this? try : webdriverwait wait = new webdriverwait(driver , 1000) ; wait.until(excepctedconditions.elementtobeclickable(byid("element")); element can id of element present on next page redirected . once page loads start executing code .

Adding Alt + Space shortcut in Eclipse -

i using win7 , eclipse aptana plugin trying examples on ruby. can't figure out how add alt + space shortcut in eclipse (i want add complete defined variables). issue when try add combination (eclipse reads keys clicked) , menu window appears in top left -> shown when hit alt key. does has hint how add shortcut? i found similar post, don't know how , add code there. autohotkey, remap left alt + space control + escape in eclipse, code-completion shortcut ctrl+space (it's called content assist in eclipse lingo). you're looking for? i'm pretty sure can mapped different keyboard combination. open preferences , navigate general > keys , search content assist command re-map.

xamarin.ios - Swipe Gesture with Two Fingers -

i added swipegesture view on page. if make left swipe view switches subview. same if right swipe. the problem is, on 1 of pages uislider , if change value of this, swipe gesture triggers , navigates subview. is possible make swipe gesture triggers if swipe 2 fingers? yes, can use swipe gesture 2 fingers using numberoftouchesrequired property. agree @jonathan.peppers though if have conflicting gesture patterns it's bad ux practice differentiate them incrementing touch points. i recommend using abstraction using gestures , modify using sort of type check swipe: https://gist.github.com/1453770 if(typeof(t) == typeof(uiswipegesturerecognizer)) { ((uiswipegesturerecognizer)frecognizer).numberoftouchesrequired = 2; }

xml - What does node()|@* mean XSLT? -

i have seen being used in contect: <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> can explain "node()|@*" means? this called identity transform . node()|@* matching child nodes ( node() text,element,processing instructions,comments) , attributes ( @* ) of current context.

c++ - How can I be sure a routine is taking advantage of (N)RVO? -

i'd make sure routines leveraging (n)rvo whenever possible. other parsing through resulting disassembly, there can or check see if routine being compiled (n)rvo? @ point i'm interested in msvc , gcc. no, not really. however can follow guidelines when writing code. unnamed return value optimization this pretty triggered every time return temporary, in debug mode. return myobject(....); named return value optimization this pretty triggered every time function return same temporary object: myobject func() { myobject result; if (...) { return result; } result.push(0); return result; } you can mix those, becomes nigh impossible compiler apply rvo in case: myobject func() { myobject result; if (...) { return myobject(...); } return result; } here, 1 return benefit rvo , other not. , bet on first being optimized because you'd stuck if speculatively create result in return slot , need take if branch. note reordering statements

linux - issue with fork() from a firebreath npapi plugin -

i trying fork() new process can call separate console application. the fork happen fine , new process id process in sleeping state , not active @ if browser exits. i took sample plugin project , modified echo method fork. a regular console application works fine fork code. is there different has taken account firebreath plugin app? can suggest might issue? the platform archlinux 64 bit. fb::variant plugintestvzapi::echo(const fb::variant& msg) { static int n(0); fire_echo("so far, clicked many times: ", n++); // fork pid_t pid = fork(); if(pid == 0) // child { m_host->htmllog("child process"); } else if (pid < 0) // failed fork { m_host->htmllog("failed fork"); m_host->htmllog(boost::lexical_cast<std::string>(pid)); } else // parent { m_host->htmllog("parent process"); } m_host->htmllog("child process pid = &

how to read image file and store in memory as base64 string in c++? -

i've read few articles on stackoverflow , on internet have not find suitable answer me. so here's newbie question. have image files sitting on local disk such *.jpg, *.png, , *.gif. want read these files base64 encoded string. how can in c++? i've tried open file binary , store in std:string. didn't work due 0 byte in data. can suggest solution? thanks in advance.

javascript - Remove item in array without deleting the object it points to -

i have this var myarray = []; myarray.push(someobject); but if delete or splice array entry pushed deletes someobject(someobject passed reference pushing, not clone , cannot have clone). there way can: just remove pointer someobject myarray without deleting someobject have delete actual key object in array, not shift other keys in array? someobject not deleted long other variable or object in javascript has reference someobject. if nobody else has reference it, garbage collected (cleaned javascript interpreter) because when nobody has reference it, cannot used code anyway. here relevant example: var x = {}; x.foo = 3; var y = []; y.push(x); y.length = 0; // removes items y console.log(x); // x still exists because there's reference in x variable x = 0; // replace 1 reference x // former object x deleted because // nobody has reference more or done different way: var x = {}; x.foo = 3; var y = []; y.push(

iphone - MPMoviePlayerViewController not playing in Landscape orientation under 5.1 -

has changed in 5.1 affect how mpmovieplayerviewcontroller works regarding device orientation? i started getting reports users today videos playing in portrait mode. figured out using 5.1 , upgraded device recreate situation. code has not changed , works in 4.x, 5.0, , 5.01. all views in app display in portrait mode except when user clicks on video, movie player suppose take on whole screen , launch landscape more. app using 5.0 sdk targeting 4.0. here code using display video: videoplayer *vp = [[videoplayer alloc] initwithcontenturl:movieurl]; vp.movieplayer.moviesourcetype = src; vp.movieplayer.controlstyle = mpmoviecontrolstylefullscreen; vp.movieplayer.shouldautoplay = true; [self presentmovieplayerviewcontrolleranimated:vp]; videoplayer subclass of mpmovieplayerviewcontroller shouldautorotatetointerfaceorientation overridden so: - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { return (interfaceorientation == uideviceor

javascript - Fancybox only firing on first gallery -

i using foreach loop inside of wordpress give each image's < rel > tag value of $post_id . creating data variable called 'gallery' value of $post_id . using fancybox call upon data variable , fire fancybox. this works perfect first image gallery, when go next 1 doesn't fire fancybox though data value , rel tag values match on next galleries. my jquery: var galleryvalue = $('.portfolio-gallery').data('gallery'); $("a[rel=" + galleryvalue + "]").fancybox({ 'transitionin' : 'elastic', 'transitionout' : 'elastic', 'cyclic' : true, 'autoscale' : true, 'shownavarrows' : true, 'overlaycolor' : '#666' }); my html: <?php $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_pare

php - Mysql Index to Ignore Spaces and Capitalization? -

i have unique index on text field , wondering if there anyway can tell ignore case , spaces. preprocessing normalize data before inserting still count these two "this title of data" "this title of data" as same , allow 1 of them. if there way @ index level great if not guess can try make preprocessing more strict normalize incoming data. have bunch of old data have passed through whatever normalization again or else continue duplicate entries prefer way fix @ mysql index level. suggest? character case has become complex many languages. if need preserve typed make 2 columns typed text , normalized text... in trimmed, lcase, etc. search on normalized column, display user's column

iphone - Why don't my TabBar buttons autoresize on the iPad? -

Image
i'm building universal ios app , ipad version uses splitviewcontroller. in popover view, have uitabbarcontroller 2 buttons. when runs on iphone, tabbar buttons correctly stretch fill entire width of view... ...but on ipad, in popover view, buttons don't stretch fill entire width... i'm creating uitabbarcontroller programmatically... inspectiontabbarviewcontroller *inspectiontabbarvc; inspectionlistviewcontroller *inspectionlistvc; self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone) { inspectionlistvc = [[inspectionlistviewcontroller alloc] initwithsunday:no]; inspectionlistvc.managedobjectcontext = self.managedobjectcontext; uinavigationcontroller *calendarnavvc = [[uinavigationcontroller alloc] initwithrootviewcontroller:inspectionlistvc]; calendarnavvc.title = @"calendar"; inspectionmapview

java - Find array elements equal to a given sum -

suppose array is: [1, 2, 5, 7, 10, 13, 17, 21] , have find 5 numbers sum equal 31. algorithm? for small array such have, efficiency doesn't mean much. trick make fast. work (written in matlab, translate language easily): array=[1, 2, 5, 7, 10, 13, 17, 21]; sum_val=31; a=1:(length(array)-4] b=(a+1):(length(array)-3) c=(b+1):(length(array)-2) d=(c+1):(length(array)-1) e=(d+1):(length(array)-0) if array(a)+array(b)+array(c)+array(d)+array(e)=sum_val fprintf("%i+%i+%i+%i+%i=%i",array(a),array(b),array(c),array(d),array(e),sum_val); end end end end end

ios - Quartz 2D Opaque Data Types -

quartz 2d opaque data types the quartz 2d api defines variety of opaque data types in addition graphics contexts. because api part of core graphics framework, data types , routines operate on them use cg prefix. quartz 2d creates objects opaque data types application operates on achieve particular drawing output. figure 1-3 shows sorts of results can achieve when apply drawing operations 3 of objects provided quartz 2d. example: you can rotate , display pdf page creating pdf page object, applying rotation operation graphics context, , asking quartz 2d draw page graphics context. you can draw pattern creating pattern object, defining shape makes pattern, , setting quartz 2d use pattern paint when draws graphics context. you can fill area axial or radial shading creating shading object, providing function determines color @ each point in shading, , asking quartz 2d use shading fill color. i having trouble understanding

java - How to compare two spinner values to display toast & change one spinner value -

i want display toast when 2 spinner values same, , revert spinner1 value default value being same spinner two here java code package com.test16.sp2; import android.app.activity; import android.os.bundle; import android.view.*; import android.widget.*; import android.widget.adapterview.onitemselectedlistener; public class test16sp2activity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); spinner spin1=(spinner)findviewbyid(r.id.spinner1); spinner spin2=(spinner)findviewbyid(r.id.spinner2); arrayadapter<charsequence> adapter1= arrayadapter.createfromresource(this, r.array.planet_array1, android.r.layout.simple_spinner_item); arrayadapter<charsequence> adapter2= arrayadapter.createfromresource(this, r.array

events - How do I emit to an eventListener from inside a nested function in Node.js (javascript scoping issue) -

i writing code below parses sites api 1 @ time, tells event queue ready next object parse. having issues since still new javascript scoping, , emit siteparser or call emitfornext function. cannot seem bring emitfornext scope in error callback. function siteparser(){ this.emitfornext = function (message) { this.emit("next", message); }; this.pulljson = function (path, processjson) { //processjson callback function var options = { host: 'www.site.com', port: 80, path: path } //console.log("... processing "+path); //pulls entire json request via chunks http.get(options, function (res) { var resjson = ''; //stores comment json stream given in res res.on('data', function (chunk) { resjson+=chunk; });

android - Cannot draw on surfaceview onDraw -

hi using surfaceview draw on canvas.when using this canvas.drawcircle(100, 100, 5, paint); //it drawing fine while using : canvas.drawcircle(x, y, 5, paint); //it's not drawing.x,y being points on screen , floats. any help check if x , y coordinate positive , inside bounds of view: x >= 0 && x < canvas.getwidth() && y >= 0 && y < canvas.getheight()

javascript - Is there any way to detect that window is currently active in IE8? -

is there way detect window active (is being shown on active tab/window) in ie8? i know there events onfocusin / onfocus - not perfect solution, since window must receive focus event fired - not work when user switches tabs without touching window itself. i believe there has simple, elegant solution such ordinary use-case. i’ve written jquery plugin this: http://mths.be/visibility gives simple api allows execute callbacks when page’s visibility state changes. it using the page visibility api it’s supported, , falling old focus , blur in older browsers. demo: http://mathiasbynens.be/demo/jquery-visibility this plugin provides 2 custom events use: show , hide . when page visibility state changes, appropriate event triggered. you can use them separately: $(document).on('show', function() { // page gained visibility }); …and… $(document).on('hide', function() { // page hidden }); since of time you’ll need both events, best option u

android - How to disable the installation of device administrator application? -

we can create device administrator application supposedly have escalated privileges enforce policies password quality, device encryption etc. see: http://developer.android.com/guide/topics/admin/device-admin.html but example device provisioned first time administrator (administrator install app user) , device passed user, can disabled (under settings -> security -> device administrator) or uninstalled. is there way can prevented? password required disable device administrator? can done? there other way? thanks in advance, perumal no cannot that. device administrator have voluntarily installed user. user decides if wants enable device administrator. if device not having proper device admin installed , enabled, being "punished" access refusal e.g. corporate network.

Java SimpleDateFormat with pattern "MM/DD/yyyy" produces unexpected date value -

i trying create date object input string. code snippet have written : inputs : effdate = "03/09/2012" , expirydate = "08/31/2012" system.out.println("eff date: " + effdate); simpledateformat formatter = new simpledateformat("mm/dd/yyyy"); date date = formatter.parse(effdate); system.out.println("effective date = " + formatter.format(date)); the output : eff date: 03/09/2012 effective date = 01/09/2012 the same happens other input well. exp date: 08/31/2012 expiry date = 01/31/2012 does know reason why changing month value anything(03/08) 01 ?? info: using jdk1.6 eclipse. , running sample program through junit 4. new simpledateformat("mm/dd/yyyy"); should new simpledateformat("mm/dd/yyyy"); ( dd instead of dd ) dd = day in year dd = day in month

node.js - Mongo DB - sub-collections? -

i'm new mongodb , using nodejs , native node mongodb driver. having doubts implementation. hope can me: have "schema", db.pages holds config each section of website: db.pages = [ {name: 'contacts', settings:{...}}, {name: 'blog', settings:{...}, posts: "blogposts"}, {name: 'media', settings: {...}, posts: "mediaposts"} ] db.blogposts = [ {title: 'post1', date: '2011-10-22', author:'me', content: '...'}, {title: 'post2', date: '2011-11-22', author:'me', content: '...'}, {...............................................................} ]; what i'm doing here is, in each page, define if have posts collection and, in node, when load page, check if page.posts defined and, if so, load appropriate collection. maybe i'm wrong, looking relational thing so, idea, put content of blogposts directly value prop posts of pages collection, so:

delphi - Geting an instance of Windows Control (dialog window) by its handle -

i called dialog window in delphi. i'm trying refference it, bu encountering problem. controls not vcl can't use findwindow(handle): twincontrol is there method returns proper window control? is there chace able gather dialog window info like: *number of controls on dialog window *names, text, classnames of controls on dialog window if there isn't vcl control representing dialog box, cannot manufacture 1 out of nothing. vcl controls create , assume responsibility corresponding windows controls, if windows controls exist, there no way "wrap" them new vcl objects. you'll have operate on window handles directly instead. can use them gather whatever information want.

c# - What could cause EventWaitHandle.Set() to block the current thread? -

i invoking set method on instance of manualresetevent, , deadlocking. can't find in documentation indicate blocking method. cause mre.set block? stack trace: [managed native transition] mscorlib.dll!system.threading.eventwaithandle.set() + 0xe bytes mycode.stopall(bool force) line 179 + 0xd bytes mycode.calccheckthread() line 250 + 0xb bytes mscorlib.dll!system.threading.threadhelper.threadstart_context(object state) + 0x66 bytes mscorlib.dll!system.threading.executioncontext.run(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state) + 0x6f bytes mscorlib.dll!system.threading.threadhelper.threadstart() + 0x44 bytes private static void stopall(bool force) { if( !force ) loghelper.sendallclosestate(logger); _forcablyexit = force; _running = false; _stopwait.set(); // line appears blocking } we've tracked down source of problem of our friends @ microsoft developer support. event

python - Is it possible to have 'Save' / 'Delete' anchors with hidden inputs -

don't know if possible or not. i'm trying make when user clicks save or delete anchor, doesn't redirect anywhere. guess i'm asking is, possible hidden input recognize anchor if input , send view? example: template: * updated ! <a class="delete" href="javascript:void(0)">delete</a> django view: (what started with) @login_required def edit_box(request): if 'edit' in request.post: deletes = [int(item) item in request.post.getlist('delete')] yadda yadda delete code ... return render_to_response('cart/boxcart.html', context, context_instance=requestcontext(request)) django view: * updated ! @login_required def edit_box(request): profile = get_object_or_404(profile, user=request.user) item_in_profile = item.objects.filter(profile=profile) deletes = [int(item_in_profile) item_in_profile in request.post.getlist('delete')] item_in_profile.filter(i

Dropdowns on Django Admin -

i new django , using allow users edit database tables through admin site. have 2 tables fields in common. want common fields appear dropdowns in 1 of tables. can't figure out how make multiple dropdowns. best gui tool use simple databases? here code far: class places(models.model): name = models.charfield(max_length=300) description = models.charfield(max_length=100) def __unicode__(self): return self.name # can add conditional here return 'description'? class more_places(models.model): name = models.foreignkey('places', null=true, blank=true, db_column = 'feature_name', related_name='featurename') # dropdown #1 description = models.foreignkey('places', null=true, blank=true, db_column = 'version', related_name='version') # want dropdown #2 more_data = models.charfield(max_length=10) i don't see errors in model. , working two dropdowns in django v1.3. don't understand need

javascript - Why doesn't console.log work when passed as a parameter to forEach? -

this out of curiosity, of have idea why code won't work? [1, 2, 3, 4, 5].foreach(console.log); // prints 'uncaught typeerror: illegal invocation' in chrome on other hand, seems work fine: [1, 2, 3, 4, 5].foreach(function(n) { console.log(n) }); so... ? it's worth pointing out there difference in behavior in implementation of console.log . under node v0.10.19 not error; see this: > [1,2,3,4,5].foreach(console.log); 1 0 [ 1, 2, 3, 4, 5 ] 2 1 [ 1, 2, 3, 4, 5 ] 3 2 [ 1, 2, 3, 4, 5 ] 4 3 [ 1, 2, 3, 4, 5 ] 5 4 [ 1, 2, 3, 4, 5 ] this because callback foreach three-parameter function taking value, index, , array itself. function console.log sees 3 parameters , dutifully logs them. under chrome browser console, however, get > [1,2,3,4,5].foreach(console.log); typeerror: illegal invocation and in case, bind will work: > [1,2,3,4,5].foreach(console.log.bind(console)); 1 0 [ 1, 2, 3, 4, 5 ] 2 1 [ 1, 2, 3, 4, 5 ] 3 2 [ 1, 2, 3, 4,