Posts

Showing posts from 2011

how to find file from blockName in HDFS hadoop -

what's easiest way find file associated block in hdfs given block name/id the long , painful way, assuming have read access files (and execute directories): hadoop fsck / -files -blocks | grep blk_520275863902385418_1002 -b 20 then scan block match previous file name: /hadoop/mapred/system/jobtracker.info 4 bytes, 1 block(s): ok 0. blk_520275863902385418_1002 len=4 repl=1 in case blk_5202... part of /hadoop/mapred/system/jobtracker.info file programmatically, these isn't interface name node allows search block id, source secondary name node , see how consolidates edits - experiment on saved output secondary name node (rather risking working on live name node file). good luck!

ios - Expand and Shrink UIScrollView with animation -

i having uitableview inside scrollview. trying accordion component using uitableview . need expand uitableview add more cell. in case have increase height of uiscrollview animation matches table animation. - (nsindexpath *)tableview:(uitableview *)tableview willselectrowatindexpath:(nsindexpath *)indexpath { nsinteger row = [indexpath row]; bool preventreopen = no; if (row == expandedrowindex + 1 && expandedrowindex != -1) return nil; [tableview beginupdates]; if (expandedrowindex != -1) { familytableview.frame = cgrectmake(familytableview.frame.origin.x, familytableview.frame.origin.y, familytableview.frame.size.width, 3*50+22); toolstableview.frame = cgrectmake(toolstableview.frame.origin.x, familytableview.frame.origin.y + familytableview.frame.size.height + 20, toolstableview.frame.size.width, 4*50+22); myaccounttableview.frame = cgrectmake(myaccounttableview.frame.origin.x, toolstableview.frame.origin....

How to plot specific rows in GNUplot -

i have two-column file has 1000000 entries, 1000000 rows, don't want plot data, want plot points every 100 lines? how in gnuplot? also, possible specify particular rows plot in gnuplot? you have @ least 2 options here. first, check out documentation help datafile every plot 'datafile' every 100 using 1:2 another option use pseudo-column 0 ( help datafile using pseudo ) in conjunction ternary operator ( help ternary ) , knowledge gnuplot silently ignores undefined numbers filter lines: plot 'datafile' u ( ((int($0)%100)==0)? $1 : 1/0 ):2 you can make little more easy understand if use macro: set macro line_number='int($0)' plot 'datafile' u ( ( ( @line_number % 100 ) == 0 ) ? $1 : 1/0 ) : 2 note include second because (in principle) use select strange line numbers datafile (e.g. 1,100,1000,10000) can't using every -- e.g. plot 'datafile' u ( ((@line_number == 1 || @line_number == 100 || @line_number == 1000 ) $...

java - How can I debug pauses in execution in the App Engine production environment? -

when looking @ appstats graphs google app engine/java application, see gaps of seemly unexplainable time between rpcs. in attached screenshot, there gap of 2 seconds between 2 calls memcacheservice.get for-loop. behavior not appear when run code locally. how can investigate cause of anomalies such one, when code running in app engine cloud? apparently wont let me post images, here's link graph: http://i.imgur.com/bbcxr.jpg remember app engine shared hosting. while doesn't seem near oversold shared vps hosting still on machine running other sites. if sites code takes on resources possible impact applications performance. not aware of resources app engine sensitive too, @nick-johnson more able tell those. way app engine works prevent of common problems. when @ graph looks me application had grabbed machine gap.

PHP Count number of occurrences in numeric array -

i have php array , have dumped below using zend_debug: $ids = array(13) { [0] => string(1) "7" [1] => string(1) "8" [2] => string(1) "2" [3] => string(1) "7" [4] => string(1) "8" [5] => string(1) "4" [6] => string(1) "7" [7] => string(1) "3" [8] => string(1) "7" [9] => string(1) "8" [10] => string(1) "3" [11] => string(1) "7" [12] => string(1) "4" } i trying how many times each number occurs in array , output array. i have tried using array_count_values($ids) outputs in order of occurred cant total times numbers occur. gives me below output: array(5) { [7] => int(5) [8] => int(3) [2] => int(1) [4] => int(2) [3] => int(2) } i can see above array 7 occurs 5 times can access when loop through array! any thoughts? cheers j. you can acc...

How to fit Android "layout-normal" xml design for all normal screen sizes? Beginning from screen size 3.2 inch to 4.7 inch -

i confused of normal layout in android 2.2 because tried fit ui design screens takes normal layout in runtime failed, galaxy sii (4.3) , htc sensation (4) , galaxy gio (3.2) normal layout. know how fit design of them? appreciate , in advance

sharepoint - Trigger workflow from CEWP button -

i have created site workflow, need trigger manually when button in content editor web part(cewp) clicked. how can trigger cewp? thanks. you cant directly start workflows javascript ( inside cewp ) using 2010 client object model. can call web service: https://www.nothingbutsharepoint.com/sites/eusp/pages/4-clicks-or-1-using-jquery-to-start-a-sharepoint-workflow.aspx or use spservices http://spservices.codeplex.com/wikipage?title=startworkflow&referringtitle=workflow

Block wise processing of an image in matlab -

i have image of size 256*256 , want block wise processing of image. want 64*64=4096 blocks, each of 16 pixels. i'm new matlab found hard find specific commands that. far have is, i=imread('kidneyimage.jpg'); i=rgb2gray(i); % block wise processing needed. any commands appreciated. to can use function im2col . http://www.mathworks.fr/help/toolbox/images/ref/im2col.html

how to setup JDBC in Eclipse? -

i have eclipse , j developer,i more comfortable eclipse.i want know how setup jdbc driver in eclipse,i downloaded driver oracle.com not appear anywhere when browse after clicking 'external jars' in 'java build path' in "libraries" tab. database oracle express edition. are there pdf's or tutorials java application development?i want make front end application enter data fields , inserts db,and make such can retrieve information when enter example id. what materials required this?i don't want learn deep want learn in process(this not project wanna achieve month) guessing need 1. book on awt,swing classes 2. need set jdbc thing don't understand how , running in eclipse,i type code gives me error. 3.a book on how connect java oracle express edition db. have jdk 1.7.0.0.3 thanks in advance(i'm beginner ;)) if you're wanting include jar file eclipse project, create 'lib' folder inside project folder, , put file in there...

android - Combine 2 ArrayAdapter -

i want make real time trading app.. have problem combine 2 adapter 1 adapter. need :d here's code @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.list_item); final uraikonversiactivity cp = new uraikonversiactivity(this); final listview list = (listview) findviewbyid (r.id.list); final string list_array[] = new string[cp.kodekonversi.size()]; final float list_nilai[] = new float[cp.nilaikonversi.size()]; (int = 0; < cp.kodekonversi.size(); i++) { list_array[i] = cp.kodekonversi.get(i); } (int = 0; < cp.nilaikonversi.size(); i++) { list_nilai[i] = cp.nilaikonversi.get(i); } arrayadapter adapter = new arrayadapter(this,android.r.layout.simple_list_item_1, list_array); arrayadapter adapter1 = new arrayadapter(this, android.r.layout.simple_list_item_1, list_nilai); list.setadapter(adapter); }} (note : real time got arraylis...

java - Smartclient: How to show a canvas on a modal mask? -

i have listgrid displayed on dashboard layout. in few case need show notes messages using sc.say() . but have designed own canvas display such messages , have placed on parent dashboard. now when need comes display message when action take place on listgrid component. window set modal notes canvas displays masked dashboard layout. i want display canvas without masking ? how can achieve show canvas without mask , listgrid showing ? ![enter image description here][1] happening window set ismodal(true) , setmodalmask(true) , know optional required in our project need bring yellow canvas message display normal highlighted , not mask showing now public class getmessagedialogbox extends canvas { private getmessagedialogbox(string messagetext) { mainlayout = new gethorizontallayout("100%", "40", null, 0, 5, null); btnclose = new getimgbutton(16, 16, "red_square_close.png"); btnclose.setvisible(true); btnclose.setshowtitle(tr...

javascript - Facebook like button overwhelms IE7 -

i noticed facebook button on site seems overwhelm ie7, not other browsers. browser slows down point in unusable. tripled memory in virtual machine see if help, didn't. markup: <script src="http://connect.facebook.net/en_us/all.js#xfbml=1"></script> <fb:like show_faces="false" width="35" font="" layout="button_count"></fb:like> if remove these lines, issue goes away. i noticed loading swirl keeps swirling in ie7 (never seems finish), opened fiddler. page seems refresh once second. request made refresh page, , ?fb_xd_fragment appended query string. the referer header on of these requests http://static.ak.facebook.com/connect/xd_artiber.php?version=6 . javascript errors thrown. does know if changing particular settings on facebook tags fixes issue? know of workarounds? i've posted sample fiddler (this first one, please bear me): http://jsfiddle.net/jhoppe/yqdst/ if go edit text of ...

Running PyQt4 demos --- How? -

i have downloaded , installed latest release of pyqt4 windows. have tested simple pyqt4 examples , have seen no obvious problems. however, unable execute demos when follow directions given in readme file of demos: finding pyqt examples , demos launcher ============================================ on windows: the launcher can accessed via windows start menu. select menu entry entitled "examples , demos" entry in submenu containing pyqt4. i have no problem finding , clicking on "examples , demos" entry; but, never able see demo execute. using windows vista (32-bit) python 2.6? try go <pythoninstallation>\lib\site-packages\pyqt4\examples in cmd prompt , see if can run examples directly there. should @ least give error messages if doesn't work. the louncher should runnable demos\qtdemo\qtdemo.pyw , can run single examples without louncer.

symfony1 - Symfony cyrillic routing slug -

i have problem whit slugify routing parameter. want replace intervals , symbols "-". when parameter latin letters work, if try slugify parameter whit cyrillic letters error. routing: cattests: url: /cat/:id/:name_slug class: sfdoctrineroute options: { model: categories, type: object } param: { module: categories, action: testsbycat } requirements: id: \d+ slug functions: static public function slugify($text) { // replace non letters or digits - $text = preg_replace('/\w+/', '-', $text); // trim , lowercase $text = strtolower(trim($text, '-')); return $text; } public function getnameslug() { $text= category::slugify($this->getname()); return $text; } example: have 2 names in databace: english language Български език normally whitin function url : english+language Български+език when put function result : english-language and on cyrillic version parameter empt...

java - JSON-RPC in Spring framework 3 -

i need recomendations, best practice/libs, when implementing json-rpc in spring 3 web application. i found http://code.google.com/p/jsonrpc4j/ didn't seem relases available. edit: for clarification, want provide json-rpc service spring mvc jackson can provide json response rest call. easy. don't think there facility in native spring accept json-rpc request including method name , return response including json-rpc error codes. your best bet may @ library jsonrpc4j .

ruby - How the wildcard ** work within fnmatch? -

i notice surprising behavior of fnmatch function of ruby: file.fnmatch('**.rb', 'main.rb') #=> true file.fnmatch('**.rb', './main.rb') #=> false as far being explained in the ruby reference , ** will: matches directories recursively or files expansively. so why doesn't expands , matches ./main.rb ? this behavior documented , it's easy miss. buried in examples says: wildcard doesn't match leading period default. to enable behavior, need specify file::fnm_dotmatch flag: file.fnmatch('**.rb', './main.rb', file::fnm_dotmatch) => true

Truncating the end of a string in R after a character that can be present zero or more times -

i have following data: temp<-c("air bags:frontal" ,"service brakes hydraulic:antilock", "parking brake:conventional", "seats:front assembly:power adjust", "power train:automatic transmission", "suspension", "engine , engine cooling:engine", "service brakes hydraulic:antilock", "suspension:front", "engine , engine cooling:engine", "visibility:windshield wiper/washer:linkages") i create new vector retains text before first ":" in cases ":" present, , whole word when ":" not present. i have tried use: temp=data.frame(matrix(unlist(str_split(temp,pattern=":",n=2)), + ncol=2, byrow=true)) but not work in cases there no ":" i know question similar to: truncate string character in r , used: sub("^[^.]*", "", x) but not familiar regula...

c# - Is there anyway to call a function in a class that inherits from system.web.ui.page from a mvc3 controller? -

i have cs file delivered vendor structure following: public partial class test : system.web.ui.page { public void insertsignature() { response.write("asdfasdfaf#wrrasdfcaerasdcdsaf"); } } i attempting use insertsignature function in mvc 3 application using following code mysample sample = new test(); sample.insertsignature(); i'm getting following httpexception: "response not available in context." there anyway can work out modifying vendor delivered product. know there ways make work modifying file if @ possible great avoid doing this. thanks in advance. it seems known issue ( response not available in context ) just replace response.write("asdfasdfaf#wrrasdfcaerasdcdsaf"); with httpcontext.current.response.write("asdfasdfaf#wrrasdfcaerasdcdsaf"); and trick. doesn't seem big change. update : if wish prevent code rewriting future updates, rename method - e.g. insertsignat...

SSRS 2008 R2 - Cascading parameters - Design view -

so have been tasked modifying stories overview report tfs. can report run fine in preview. in design time cascading parameters cannot seem see each other. how supposed be? going have enter in (and modify) parameters each dataset \ parameter try to changes working? i ended filling in design mode parameters dialog.

Static function in Java web application -

i have static function in class called servlet. suppose, if 100 requests come @ time, function available requests? all requests processed same vm, in same process, different threads. yes, static members available requests. be aware though if change static data multiple threads, synchronize on data thread safety. or use threadlocal objects, these distinct every thread.

sql - Oracle: Errors Creating A Table With A Foreign Key -

i'm new oracle. i'm trying create table foreign key, keep getting cryptic error message: ora-00907: missing right parenthesis for: create table purchase_history ( purchase_number varchar(16) not null, credit_enabled char(1) not null check (credit_enabled in ('t','f')), constraint fk_customers foriegn key (customer_id) references customers(customer_id) ); i'm not seeing missing parenthesis. i'm guessing else going on. i've googled around on examples creating tables foreign keys. found couple of different styles syntax , tried few no joy. how need change statement above? thanks much steve start with: foriegn -> foreign

layout - Android reset activity component state on navigation back -

i have 2 activities in application. in activity1 , set configuration , modify state of component (ex: set button state disabled ). , navigate activity2 . in activity2 stuff , @ end, finish activity , come activity1 . but in activity1 , components state same when leave activity. how reset components state valuesdeclared in xml file ( layout ) ? when return previous activity result of calling finish() onactivityresult method called. can repopulate view desired state within method. for example: ... intent result_intent = new intent(); setresult( activity.result_ok, result_intent ); finish(); } public void onactivityresult( int requestcode, int resultcode, intent data ) { setcontentview( r.layout.my_activity ); }

javascript - Click event not executed -

an onmouseover on cell generates div inside cell. div has onclick. onclick not executed. here's sample code: jsfiddle javascript: var oldcell=''; function adddiv(cell){ if(oldcell != ''){ oldcell.innerhtml = ''; } cell.innerhtml = "<div class='innerdiv' onclick='console.log(this.parentnode);'></div>"; oldcell = cell; } html <table border='1px solid black'> <tr> <td class='cell' onmouseover='adddiv(this)'></td> <td class='cell' onmouseover='adddiv(this)'></td> </tr> <tr> <td class='cell' onmouseover='adddiv(this)'></td> <td class='cell' onmouseover='adddiv(this)'></td> </tr> </table>​ i've tried focussing on div, not wok either. i've tried giving cell onclick, , focussing o...

qt - drawText() on a QImage crashes program -

i have image in uint8_t buffer , trying use qimage wrapper write text on image. have used drawline() no issues, drawtext() crashes program. below code part of boost thread in want write text unto each image iterates through function. there bugs in qt unaware of? uint8_t *framebuffer; // contains image pixels qimage img(framebuffer, sizex, m_sizey, qimage::format_rgb888); qpainter p(&img); p.setpen(qpen(qt::green)); p.setfont(qfont("times", 10, qfont::bold)); p.drawline(img.rect().bottomleft().x(), img.rect().bottomleft().y()-10, img.rect().bottomright().x(), img.rect().bottomright().y()-10); //works! p.drawtext(img.rect(), qt::aligncenter, "help"); //crashes program my project set qcoreapplication (i had no gui). changing qapplication did trick!

php - restore permissions after set by error chmod -R 775 / -

by error set folders , files permissions on 775, executing command sudo chmod 775 -r /website/folder / and need restore server folders , paths permissions @ least centos files, moment can't send emails websites... system centos 5 thanks... this not meant complete solution, rather idea how solve this. you query packet database (in centos afair rpm) , set permissions way meant according database. some helpful commands rpm: rpm -va verifies files registered in rpm database. files have wrong permissions listed there. files wrong mode displayed m in 2nd column. rpm -va | grep ^.m | cut -c 13- should start. another option query files in packets with rpm --queryformat='%{filemodes}\t%{filenames}\n' -qa and process output piping kind of loop such as | while read mode fn; chmod -v ... "$fn"; done but here have convert decimal output filemodes octal chmod understands it. alternatively, process output else, python script or so, giv...

c++ - How to create-edit-remove excel files? -

i doing project has simple values(login,password,name,age). searching on internet how create excel file on visual c++, , cant undestand . want simple way, want see on excel files 2 colums 1 having login codes of program , on other passwords. programing level not high , im not english speaker, id guys explain bit or give me simple. thanks time if want simple file 2 columns of data, i'd make csv (comma seperated values) file, can opened in excel, or text editor. csv "nice" in excel, if actual xls file. also, won't tied microsoft office. file can written simple string manipulations , file i/o. the format : column1,column2 data1,data2 data3,data4 however, , big one... storing usernames , passwords in plain text never idea.

Jquery copy form inputs with keyup -

solved needed use val instead of text. mistake! what difference when copying form field form field vs copying form field span id? i can copy input field span id no problem, using same method copy form field form field doesnt work. using jquery keyup can enlighten me? heres demo thanks in advance <input type="text" name="quantity" value="100" id="quantity2" /> <input type="text" name="quantity" id="quantity_img2" /> $("#quantity2").keyup(function () { var value = $(this).val(); $("#quantity_img2").text(value); }).keyup(); to set value of textbox element use val() method instead of text() . working demo http://jsfiddle.net/lndya/20/

php - unable to fetch value from second dynamic dependent drop down box -

i hope whole day trouble @ least on now. have 2 drop down box. after submitting have first's dropdown box value in action page. second drop down box dependent on value selected in first dropdown box. this ajax code in head section <script> function getxmlhttp() { //function return xml http object var xmlhttp=false; try{ xmlhttp=new xmlhttprequest(); } catch(e) { try{ xmlhttp= new activexobject("microsoft.xmlhttp"); } catch(e){ try{ xmlhttp = new activexobject("msxml2.xmlhttp"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getscreen(strurl) { var req = getxmlhttp(); ...

white labeling and Django application -

i've been approached boss possibility of white labeling our django-based site new, large customer. basically, sounds changing graphics/logos on site. but, i'm sure @ point want start tweaking business logic well. i'm still unclear whether desire subdomain (e.g. customer.mydomain.com) or new custom domain. ultimately, will need share database rest of system (for multiple reasons). use of sites framework in django? or there better way of doing this? more info: django 1.3.1; postgresql 9.1; hosted on heroku use combination of middleware (to set active site) , context processors (to act on that). try hook contrib's site framework, i've outgrown rather quickly.

linux - Inhibit screensaver with Python -

what's better cross-de way disable screensaver in linux? found something here it's gnome-screensaver. i'm wondering if there's way simulate keystroke or x.org api disable screensaver activation. i have been looking while ago , ended using xdg-screensaver call via subprocess . import subprocess def suspend_screensaver(): window_id = subprocess.popen('xwininfo -root | grep xwininfo | cut -d" " -f4', stdout=subprocess.pipe, shell=true).stdout.read().strip() #run xdg-screensaver on root window subprocess.call(['xdg-screensaver', 'suspend', window_id]) def resume_screensaver(window_id): subprocess.popen('xdg-screensaver resume ' + window_id, shell=true) this not ideal apparently there no other solution not involve messing around de-specific stuff dbus or gnome-screensaver-command . i don't call xwininfo , wish there cleaner way far not find better. issue xwininfo approach uses id of root...

xml - Converting average response times to a summable node-set -

i've been running series of webservice tests in jmeter, , i'd take total sum of average response times returned each test. have way find average response times each test, no way add averages tests together. aware in order use xpath's sum() function values need part of node-set, understand once find average values out of xml no longer part of one. need use node-set() function, new xslt/xpath , unsure how things working. any appreciated! this sample xml jmeter running 2 iterations: <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="../style/jmeter-results-detail-report_21.xsl"?> <testresults version="1.2"> <httpsample t="78" lt="78" ts="1338826079163" s="true" lb="html" rc="200" rm="ok" tn="vuserver 1-1" dt="text" by="4418" ng="1" na="1"/> <https...

c# - This Lambda OrderBy seems superfluous in my case - is it? -

i don't want have unnecessary code, want "safe," too. empirical observations have shown orderby below nothing - list ordered correctly. can rely on being case, , remove orderby line? hashset<int> hashset = new hashset<int>(); list<int> listints = new list<int>(); using (var file = new system.io.streamreader(selectedfile)) { string line; int linenum = 0; int offset = (int)numericupdownlinesofcontext.value; while ((line = file.readline()) != null) { linenum++; if (line.contains(platypustosearchfor)) { // adds lines before , after provide desired context // (n lines log file before , after searched value) hashset.unionwith(enumerable.range(linenum - offset, offset * 2 + 1)); } } // remove negative numbers, 0, might have been added // (0, -1, -2, or -3 possibilities, first line #1) listints = hashset.where(i => >= 1).tolist(); // seem ordere...

c - What is the difference between char *str being null and str[0] == '\0' -

i have pointer char *str; for particular case, if (!str) not null str[0] == '\0' , how , when possible? edit:0 responses. need pass string source param in strlcpy() sag faulting because empty string. seems need check this: if (!str || str[0] == '\0') not pass strlcpy(). sound right? \0 null-byte or null-terminator. therefore, seen null. c-strings null-terminated. is, first time null-byte seen, string considered complete. if nothing other \0 exists, null . if have information beyond byte (this bad practice strings) try check str+1 advance passed null-byte. in event, str+1 , on garbage data , cause invalid memory accesses (causing program crash).

php - get number day of month without Friday -

i need number of days in month, without example fridays. $num = cal_days_in_month(cal_gregorian, $month, 2012); here can total number of days, need substract fridays count. how do it? i found handy function here : function num_days ($day, $month, $year) { $day_array = array("mon" => "monday", "tue" => "tuesday", "wed" => "wednesday", "thu" => "thursday", "fri" => "friday", "sat" => "saturday", "sun" => "sunday"); $month_array = array(1 => "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"); /* * check our arguments valid. */ /* * $day must either full day string or 3 letter abbreviation. */ if (!(in_array($day, $day_array) || array_...

gwt - any way to delay code execution until page is opened -

hi have gwt app hosted on google app engine. in 1 of page bound entry point class (using root panel id) call rpc service data. the problem observing when home page loaded time entry module class bound page gets instantiated , service called un-necessary. any options defer behavior until page opened? you can load data page in onload method instead of in constructor data isn't loaded till after widget attached dom.

asp.net - Error 'Executing Child Request' for MVC Action when called from HttpServerUtility.Execute -

we have started moving on asp.net mvc 3 webforms. there pdf export utility written take page path (url) , render html using httpserverutility.execute method. http://msdn.microsoft.com/en-us/library/k8e2dw5s this works fine when url being requested webform, when mvc action error "error executing child request /mycontrollername/methodname.". when debugging our idependencyresolver class , controller constructor never hit, isn't action failing. what doing wrong? there way make server side request current context html output of mvc action? have looked @ this: http://connect.microsoft.com/visualstudio/feedback/details/102401/httpserverutility-throws-httpexception-in-attempt-to-transfer-from-httphandler-httpmodule-to-another-httphandler

Android seekbar not showing -

folks, have following layout: http://dpaste.com/hold/755261/ it has 2 seekbar widgets. both not showing. if move them root linearlayout, appear, otherwise not. need them inside first linearlayout. me how achieve that? it looks need put following in third linearlayout: android:layout_weight="1"

Qibla Compass in Android -

this question has answer here: calculate compass bearing / heading location in android 11 answers i have try can not make qibla compass application. cant understand .i need qibla compass work perfect me . parag you know location of mecca , know users current location (if have gps or other location provider). bearing given formula, latitudes , longitudes should in radians. float londelta = (lon2 - lon1); float y = math.sin(londelta) * math.cos(lat2); float x = math.cos(lat1) * math.sin(lat2) - math.sin(lat1) * math.cos(lat2) * math.cos(londelta); float brng = math.atan2(y, x).todeg(); brng direction in degrees. you explore location.bearingto() method. http://developer.android.com/reference/android/location/location.html#bearingto(android.location.location) as-salaam-alaikum

iphone - Sorting mutable array by dictionary key -

i have looked through few answers using various sorting methods of nsmutablearray , reason not working me. i trying sort mutable array contains dictionaries delay key within each dictionary. however, "sorted" array exact same original array. by way, works fine if create dummy mutable array , populate dictionaries containing numbers, reason won't sort mutable array initializing. what doing wrong? here's code: playlistcalls = [[nsmutablearray alloc] initwitharray:[currentplaylist objectforkey:@"tunes"]]; nslog(@"original %@", playlistcalls); nssortdescriptor *delay = [nssortdescriptor sortdescriptorwithkey:@"delay" ascending:yes]; [playlistcalls sortusingdescriptors:[nsarray arraywithobject:delay]]; nslog(@"sorted %@", playlistcalls); here's array containing dictionaries: 2012-06-04 15:48:09.129 myapp[57043:f503] original ( { name = test tune; delay = 120; volume = 100; ...

c++ - Reading to object from .in file -

hello i'm having list of 3 int's spaced 2 white-spaces, , want read them , create object. paste code data strucutre, class , pre/post data. cant find reason error. welcome: class.h: class rangle{ private: int x,y,l,b; int solution,prec; rangle(){ x = y = solution = prec = b = l = 0; } rangle(int i,int j,int k){ x = i; y = j; l = k; solution = 0; prec=0; b=0; } friend ostream& operator << (ostream& out, const rangle& ra){ out << ra.x << " " << ra.y<<" " << ra.l <<endl; return out; } friend istream& operator >>( istream& is, rangle& ra){ >> ra.x; >> ra.y; >> ra.l; return ; } }; datastructure.h: template <class t> class list { private: struct elem { t data; elem* next; }; elem* first; ...

javascript - Dynamic variables for changing backgroundPosition -

i've found few loosely related answers none have level of variability need. i trying create color-changing chip palette similar find on automobile website: when paint swatch clicked, main image's background position change, giving illusion paint color has changed. i'm still new javascript, think elegant way go it. can syntax actual working script? defining css: #target { background: url("/images/center-stage.jpg") no-repeat; background-position: 0 0; } function on external script file: function colorchange(x,y) { var x=("x" + px); // don't how format stuff var y=("y" + px); document.getelementbyid("target").style.backgroundposition="(,)"; // doesn't go here, it? } and html call(s): <a href="#" onclick="colorchange(0,50)"><img src="/images/swatches/red.jpg"></a> <a href="#" onclick="colorchange(0,100)">...

php - Force download and htaccess = zero bytes files -

i trying deny access folder on server, in there files can downloaded via php script. php script used force download of files, that: function downloadfile($file){ $file_name = $file; $mime = 'application/force-download'; header('pragma: public'); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('cache-control: private',false); header('content-type: '.$mime); header('content-disposition: attachment; filename="'.basename($file_name).'"'); header('content-transfer-encoding: binary'); header('content-length: '.filesize($file_name)); // provide file size header('connection: close'); readfile($file_name); exit(); } and htaccess must provide access localhost: order deny,allow deny allow 127.0.0.1 but every time script downloa...

class - Why do C++ classes not have access specifiers like classes in Java have? -

i'm new c++, , i'm familiar java. first thing wondering when started looking @ c++ code classes (not members) don't have access specifiers such private , protected , public . exemples here , here . public class { // line. private class b { } // not line. } why so? there's no access modifier @ level of classes, since language has no concept of package . there @ level of data members, member functions , inheritence: class foo {}; class bar : public foo { public: void bar() const {} private: int bar_(float) {} int a, b, c; }; the closest can declaring nested classes inside class: class foo { struct bar0 { void bar0() const {} }; struct bar1 { bar0 b0; bar1() { b0.bar0();} }; };

C# fast chart aproximate comparison algorithm -

i have 2 series of values. showing them in chart, quite similar (they have same behavior, when 1 grows, other 1 grows, when 1 has small values, other has small values; but: may occur 1 growing , other descending). important not have strictly same values. interested in general behavior of these 2 charts. right now, comparing them doing average on both graphs, , building 2 bool arrays. when value above average, corresponding value in bool[] true, otherwise false. compare these 2 bool[], using hamming distance. algorithm works, not wished work. (it doesn't detect matches between charts). does have idea of better algorithm performing operation? thank you. a simple way of calculating distance between 2 lists of numbers calculate sum of squares of differences between them. used quite in statistics. double sum = 0.0; (int = 0; < n; i++) { double diff = a[i] - b[i]; sum += diff*diff; } but fundamental question is, kind of statement expecting such analysis....

iphone - Disable hyperlinks in PDF file in UIWebView -

i have webview pdf file , document in contains hyperlinks want disable. tried using approach didn't work, links still open , load nasty urls: i put uiwebviewdelegate in viewcontroller.h i put code in viewcontroller.m : - (bool)webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype { if (webview == myreadingarticleswebview) { return no; } else { return yes; } } any ideas how make simple , easy work? admit make mistakes in process described above. edit: - (bool)webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype { if ([request.url isfilereferenceurl]) { return yes; } else { return no; } } the code above nothing me well if trumpetlicks says pdf viewer ignores shouldstartloadwithrequest, , if don't want disable links (which...

How do I get HTML tags inside of a Javascript Text Node? -

my question pretty explained in title. how html tags inside of javascript text node? result of code on page is... <a href="http://www.example.com">click here</a> however, want "click here" link. new javascript, me out lot. below example of i'm talking about... <div id="mydiv"> </div> <script type="text/javascript"> var mynode=document.createtextnode('<a href="http://www.example.com">click here</a>'); document.getelementbyid('mydiv').appendchild(mynode); </script> you can't put links in text node. links elements. elements can (sometimes) contain text nodes, reverse not true. you need create element, set attributes on it, append text element. var link = document.createelement('a'); link.setattribute('href', 'http://www.example.com'); link.appendchild(document.createtextnode('click here')); document.getelementbyid(...

android - sqlite database not created -

i using standard approach learned popular notepad example building first app. got stuck strange problem. sqlite database file (.db) not being created in /data/data/package/databases. have cross checked manifest file , openhelper file headfirst android dev. book ( using reference ) found myself unable figure out why database file not created.. there special permissions or need switch on working?? strange thing working fine pre-loaded examples. means '.db' file created notepad example when try, fails. :( here files. package - database.test 1. androidmanifest.xml <?xml version="1.0" encoding="utf-8"?> <uses-sdk android:minsdkversion="10" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".database_testactivity" android:label="@string/app_name" > </activity> </ap...

java - Apache Ivy inside NetBeans to resolve imports -

i use apache ivy resolve dependencies(imports) inside project in java. i'm using netbeans 7.1.2 (java ee version). i've installed ivybeans plugin (version 1.2). built project , ivy has created ivyfiles , ivylibraries folder inside project folder (both of them empty). problem no libraries resolved. obtain following message builder: [path_to_project]\nbproject\ivy-impl.xml:92: settings file not exist: [path_to_project]\${ivy.settings.location} this ivy-resolve output : resolving compile scope ... :: loading settings :: url = jar:file:/c:/users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml :: resolving dependencies :: ivythriftapp#ivythriftapp;1.0 confs: [compile] :: resolution report :: resolve 6ms :: artifacts dl 0ms --------------------------------------------------------------------- | | modules || artifacts | | conf | number| search|dwnlded|evicted...

delphi - Add a IFileDialogCustomize PushButton Event -

i can create pushbutton filesavedialog1.dialog.queryinterface shown below. how setup , handle onpushbutton click event can respond button click? procedure tform1.filesavedialog1execute(sender: tobject); const dwvisualgroup1id: dword = 1900; var c: ifiledialogcustomize; d: ifiledialogcontrolevents; begin if filesavedialog1.dialog.queryinterface(ifiledialogcustomize, c) = s_ok begin // add advanced button c.addpushbutton(dwvisualgroup1id, 'advanced'); c.makeprominent(dwvisualgroup1id); // setup pushbutton click event? end; the following works fine me in xe2: type tmyfiledialogevents = class(tinterfacedobject, ifiledialogevents, ifiledialogcontrolevents) public { ifiledialogevents } function onfileok(const pfd: ifiledialog): hresult; stdcall; function onfolderchanging(const pfd: ifiledialog; const psifolder: ishellitem): hresult; stdcall; function onfolderchange(const pfd: ifiledialog): hresult; stdcall; ...

c# - Is there a way to automatically determine the possible exceptions a statement could throw? -

is there methodology -- , if so, -- finding out exceptions may thrown particular statement? e.g., given following code: string substr = selectedfilename.substring(date_begin_pos, date_length); return datetime.parse(substr); ...how know exception[s] might thrown second line? think 1 highlight line, , select context menu supply this/these... as far i'm aware there isn't way of finding out other looking on msdn: http://msdn.microsoft.com/en-us/library/1k1skd40.aspx the easy/lazy/c# way of doing "catch (exception e)" , deal generic exception type. have of information need in type exceptions anyway. exception handling should used logging/promoting, imho knowing datetime.parse can throw either formatexception or arguementnullexception pointless (to me).

If birthdate's are stored as type "Date" in MySQL, how would you determine if it's a user's birthday today in PHP? -

if birthdate's stored type "date" in mysql, how determine if it's specific user's birthday today in php? is matter of grabbing birthdate column value, doing on explode on - , , checking if day , month match current day , month in php? or there simpler , less crude way of doing it? also, query use select all users birthday today? since you'll need exclude year, can use month , day sql functions so: select * table month(birthday) = month(now()) , day(birthday) = day(now()); don't forget add index on column or degrade performance data grows. in php, can use date function: if (date('m-d', strtotime($row['date'])) == date('m-d')) //-- today birthday! hooray!

google app engine - Python webapp2: redirect back -

i'm using google app engine basic app. the scenario simple: click logout , want logout handler redirect me page came from. how achieve this? thnx when creating logout url can pass in url want user redirected to, in case current url. (i'm not python dev, ...): users.create_logout_url(self.request.url)

Nagios Emails not working -

i've tried figure out im failing or maybe im overlooking something. i've setup nagios server , clients. problem im having server not send email contact or contactgroup. instead see notifications in /var/log/syslog (ubuntu server). postfix installed fine , have sent numerous tests using mail , mailx (read somewhere mailx preferred nagios3). i should mention, same problem happening on icinga runs on same host. any appreciated. thanks, patrick you config file command.cfg should have similar this: define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** nagios *****\n\nnotification type: $notificationtype$\nhost: $hostname$\nstate: $hoststate$\naddress: $hostaddress$\ninfo: $hostoutput$\n\ndate/time: $longdatetime$\n" | /usr/bin/mail -s "** $notificationtype$ host alert: $hostname$ $hoststate$ **" $contactemail$ } define command{ command_name notify-service-by-email command_lin...