Posts

Showing posts from February, 2013

eclipse - dynamically rectify error from java code using java program (Source Code analysis + error removal) -

i have been given task need convert c# library java library, use utility tool (c# java converter) convert c# code java. however, tool 60% efficent in converting code. need write program rest of rectification. to achieve it, have used java compiler api locate errorneous code. error returned java compiler diagnostics generic, , not give lot of indication program error , how rectified? i believe eclipse has quick fix (hint , solution given @ compile time) in practicality achieves same, there way can use eclipse api 'quick fix' out code, , if not ideal approach towards problem? i did eclipse api unable locate quickfix api.

html / css how to Middle (vertically) align text inside a <textarea> -

Image
i want centre text inside text area; trying line height, doesn't work. you use contenteditable="true" attribute on <div> , skin css. here link cross browser compatibility: reliable cross-browser info on contenteditable

floating point - python float to in int conversion -

i have issue drives me mad. doing int(20.0) result in 20 . far good. but: levels = [int(gex_dict[i]) in sorted(gex_dict.keys())] while gex_dict[i] returns float, e.g. 20.0 , results in: "invalid literal int() base 10: '20.0'" i 1 step away munching last piece of keyboard. '20.0' string, not float ; can tell single-quotes in error message. can int out of first parsing float , truncating int : >>> int(float('20.0')) 20 (though maybe you'd want store floats instead of strings in dictionary, since seem expecting.)

c++ - overloaded global new operator issue with msvc2008 -

i'm working @ own library, , have own allocators. i've declared common interface this: class myallocator { public: void * allocate(size_t size); void * allocate(size_t size, size_t align); void deallocate(void *); //... }; now, if want allocate c++ objects allocators must use placement new in manner: myallocator a; myobject * o = new(a.allocate(sizeof(myobject))) myobject(param1, param2, ...); this, of course, works pretty well. now, time ago wanted make global allocator, take allocator parameter, in order avoid repetitive sizeof(). come this: template< typename allocatort > inline void *operator new(size_t n_bytes, allocatort & allocator) { return allocator.allocate(n_bytes); } with this, can call: myallocator my_alloc; myobject * o = new(my_alloc) myobject(param1, param2); a syntax clean, , cool. works pretty (with gcc, , msvc2010), today, when have tried in msvc2008 got errors: that's because of msvc2008 compiler fooled temp...

ruby - 'Require' works on one computer but not on another -

i error on server i'm trying run ruby script. require: no such file load -- ssch_mail_lib (loaderror) however, on workstation computer script runs fine. here's relevant code. #!/usr/bin/ruby $: << './lib' require 'ssch_mail_lib' output of $load_path /library/ruby/site/1.8 /library/ruby/site/1.8/powerpc-darwin11.0 /library/ruby/site/1.8/universal-darwin11.0 /library/ruby/site /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/vendor_ruby/1.8 /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/vendor_ruby/1.8/universal-darwin11.0 /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/vendor_ruby /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/1.8 /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/1.8/powerpc-darwin11.0 /system/library/frameworks/ruby.framework/versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 . ./lib i've tripled checked names , directo...

javascript - Loading Text file to HTML textarea from mobile phone storage -

i writing app mobile phones using html5, javascript , css. 1 part of app should allow user load text file present phone's local storage on text area provided on page. questions are: how create file dialog box ask user select txt file. (is possible?) i read php etc load files have no experience in it. there code snippet use load text file? can javascript, jquery mobile has this? once load textarea, want edit , save again. it helpful if can throw light on or direct me towards resource can learn it. local i/o never allowed directly, should obvious security reasons. need set <input type="file"> form this, i'm not sure how behave on mobile platform. i'm sure that between platforms. assuming successful file upload , transmission editing area, saving storage require file download have initiate, , user choose accept or ignore. you use words "local storage" , tags include html 5, there additional options. can in localstorage api, al...

objective c - Clang NSTask with streams -

never-mind "why?","useless?", , "don't bother" comments. want compile program inside program using clang. can create nstask , set arguments , work if file exists, (ie. no stream), , writes physical file. haven't been able use streams both input , output. know both clang , gcc allow compiling stdin if use -xc , - options unable implement feature using pipes. not sure how redirect clang's output file handle or stream. here code have compiles , generates correct output in outfile task = [[nstask alloc] init]; nspipe* outputpipe = [[nspipe alloc] init]; [task setstandardoutput:outputpipe ]; [task setstandarderror: [task standardoutput]]; nspipe* inpipe = [nspipe pipe]; [task setstandardinput:inpipe]; [task setlaunchpath:@"/usr/bin/clang"]; nsstring* outfile= [nsstring stringwithformat:@"%@.out",[[filename lastpathcomponent] stringbydeletingpathextension]]; //[data writetofile:@"file.c" atomically:yes]; [t...

regex - Regular Expression for javascript to validate name and version -

i trying write regular expression in javascript. need validate name , version, following conditions: name: only alphabets, no numbers , special characters no trailing spaces @ start or end, , no multiple spaces between words. minimum of 3 , maximum of 50 characters. version: format should [number].[number].[number] only single dot between numbers ( 1.3..4 invalid, 1.3.4 ok) each number can of 1 or 2 digits, 1.11.26 (valid), not 2.343.23 (invalid) name the regex ^(?! )((?! )(?! $)[a-za-z ]){3,50}$ only alphabets, no numbers , special characters => use character class that [a-za-z] no trailing spaces @ start or end, , no multiple spaces between words. => "anchoring" regex should thing on line , can't partially match. negative lookahead more 2 spaces not allowed ^...$ (?! ) no spaces @ beginning , and end => again can use lookaround ^(?! )...(?<! )$ but since javascript doesn't support lookbehind have use loo...

php - Codeigniter mail library, fifth parameter error -

the company hosts web site has disabled fifth parameter in mail(), , can´t activated. wonder why that? security risk? i use codeigniter when i´m developing. when use mail library following php warning: "mail(): policy restriction in effect. fifth parameter disabled on system". wonder how should write code don´t warning. this code looks today: $this->load->library('email'); $this->email->from('my e-mail', 'web site´s name'); $this->email->to('an e-mail'); $this->email->subject('a subject'); $this->email->message("a message"); if ($this->email->send()) { } else { } what need change avoid warning? help! this because php running in safe mode, can add '@' before function call causing warning there's nothing can (i guess you're on shared host). example: @functioncauingwarning($param1, $param2); of course that's if it's working warning.

api - Facebook app in a page: auth and error 191 on redirect_uri -

i'm following this docs create facebook app work in page, i've errors. i've created index.php with: $i = parse_signed_request($_post['signed_request'], $mysecret); if ($i['oauth_token']){ echo "<script type='text/javascript'> var oauth_url = 'http://www.facebook.com/dialog/oauth/'; oauth_url += '?client_id=myappid'; oauth_url += '&redirect_uri=' + encodeuricomponent('http://www.facebook.com/pages/null/page_id/app_myappid'); oauth_url += '&scope=email'; window.top.location = oauth_url; </script>"; }else{ location.href="mypage.html"; } my app's settings are: website facebook login: http://mysite.com/app/ canvas url : http://mysite.com/app/index.php?canvas=1 page tab url: http://mysite.com/app/index.php this code generate api error code: 191 api error description: specified url not owned app...

api - Twitter Issue : Rate limit exceeded -

i using twitter's api finding location / place of tweets.i using twitters status/show/:id http://api.twitter.com/1/statuses/show/205935129938497537.json which gives me location of tweet tweet id. however getting ' rate limit exceeded. clients may not make more 150 requests per hour ' error. does know solution this? had searched on google says pasing access_token url exceed requests 350 only. want more requests. or has better solution / alternative way of finding place /location of twitters tweers?

symfony - Symfony2: Custom 404 error for NotFoundHttpException -

so far, "twigbundle" custom error404.html.twig page displays correctly on production mode when throw: $this->createnotfoundexception('whatevs'); however, when "notfoundhttpexception" thrown symfony (such whenever route not found), "no route found" page displays indeed on app_dev, mentioning "404 not found", on production mode displays blank page... which not seem normal since, according symfony documentation: "the createnotfoundexception() method creates special notfoundhttpexception object, triggers 404 http response inside symfony." then why don't same behavior? there missing? i using master branch. edit: here security.yml file, using fosuserbundle , fosfacebookbundle: security: providers: chain_provider: chain: providers: [fos_userbundle, my_fos_facebook_provider] fos_userbundle: id: fos_user.user_manager my_fos_facebook_provider: id: my.facebook.user e...

(clang) How to parse macros themselves, getting an ast where possible? -

hi i'm using clang extract information c files. , i'm trying extract values of macros. e.g. i'd want value '13' or ast (+ (* 3 4) 1): #define some_constant 3*4+1 or macro function, i'd want ast e.g. (some_macrofunc (x y) (+ (add4 x) (* y 9))) : int add4(int q) {return q+4;} #define some_macrofunc(x,y) add4(x)+y*9 so far i've managed iterate through macros via 'preprocessor' class's macro_begin() , macro_end() functions. then i've gotten macro names, , 'macroinfo' class i've been able whether macro functionlike (including param names) or not. i've got access tokens in macro, able token kind e.g: string_literal, identifier, comma, l_paren, r_paren, etc. so 2 things: how access actual value of tokens, rather kinds. is there way generate ast macros given tokens? 1 way thought parse source code, extract macros, , using names, add code including macros source , reparse ast. e.g. like: char *tempsome_consta...

javascript - Add class to all elements which have a certain class when clicked on -

i add class named "group" elements have class "someclass" - , e.g.: <div class="someclass">sometext</div> <div class="someclass">someothertext</div> <div class="someotherclass">somemoretext</div> <div class="someotherclass">somemoreothertext</div> should become following if user clicks on div containing class "someclass": <div class="someclass group">sometext</div> <div class="someclass group">someothertext</div> <div class="someotherclass">somemoretext</div> <div class="someotherclass">somemoreothertext</div> if user clicks on div containing "someotherclass" should added class "group". i tried following jquery - unsuccessfully: $("#someid").live("click", function() { var selectedclass; selectedclass = $(this).attr(...

android - in customize listview unable to fetch proper data -

here using activity in there list view,which populating form xml string,the population fine,in listview there 2 buttons clicking on no increasing , decreasing.onsubmit buttons want datum modified 1 shown in submit.e.g 2 seaters selected 2. the code snippts are: my xml private static string seatxml="<?xml version=\"1.0\" encoding=\"utf-8\"?><seatlist>" +"<seatselection><seater>two</seater></seatselection>" +"<seatselection><seater>four</seater></seatselection>" +"<seatselection><seater>six</seater></seatselection>" +"<seatselection><seater>eight</seater></seatselection>" +"<seatselection><seater>ten</seater></seatselection>" +"</seatlist>"; here populating listview private void populateseatlist() { ...

c# - update app.config file at runtime -

i trying update app.config file @ runtime. error system.nullreferenceexception: object reference not set instance of object. line 59. what trying change url @ runtime, having pop form has textbox used url, used update config file. public void changesettings() { configuration config = configurationmanager.openexeconfiguration(configurationuserlevel.none); keyvalueconfigurationcollection settings = config.appsettings.settings; try { console.writeline("nothing " + configurationmanager.appsettings["client_postcoderef_service"]); settings["client_postcoderef_service"].value = textbox1.text; <- line 59 config.save(configurationsavemode.modified); configurationmanager.refreshsection("applicationsettings"); console.writeline("nothing 2 " + configurationmanager.appsettings["client_postcoderef_service"]); ...

Not receiving email from PHP mail() contact form -

i know question has been asked countless times have been unable find answer specific me. my contact form seems validating fine , when suitable data entered , "send message" button clicked, message displayed saying message has in fact been sent. there no error messages on screen. my html code looks this: <form action="send.php" id="contact_form" method="post" name="contact_form"> <ul> <li> <label>name <span class="required">*</span></label> <input type="text" name="name" id="name" value="" class="requiredfield" /> </li> <li> <label>email <span class="required">*</span></label> <input type="text" name="email" id="email" value="" class="requiredfield email" /> </li> <li...

jQuery dialog box not working properly on Android -

i having issue jquery dialog box on specific versions of android. have used phonegap build app, have noticed works on browsers , android 4.0.3. however, when try load in 2.2.3, scroll not seem work. can please have @ code below see why not, have done lots of research , tried various things suchs scrollx: true, overflow: scroll etc. call function on click of button: var $upgrade = $('<div></div>') .html('<p>lots of text goes here</p>') .dialog({ autoopen: false, height:270, width: 400, title: 'upgrade' }); thanks in advance i found simplest , effective solution reduce jquery font-size down 11px, fitted nicely within set box size , still readable. <div style="font-size:11px;"></div>

subprocess - Verifying Perl Arguments to a Subprocesses -

so beginning perl programmer. have been using month, in last week or have been using other sysadmin type tasks. in doing ran following question, perl subprocesses flexible, , don't impose many/any constraints on arguments pass in. how possible either enforce number of arguments and/or check whether they're references, scalars etc etc? to clarify, here's perl subprocesses: sub mysub{ ($a, $b) = @_; continue , use these methods } but provides no guarantees $a , $b hold. there anyway make sure contain values, reference $a , scalar $b ? thanks in advance. edit: when said scalar $b mean containing integer, , not being reference other datastructure. you can use params::validate module, provides wide possibilities of checking argument list. in case, like validate_pos(@_, { type => hashref | arrayref }, { type => scalar }) would (note doesn't have single type "ref"). dies when parameters don't match.

mobile - How to effectively store large amount of content in Cordova (PhoneGap) application? -

i'm working on cordova application contains data approx. 3000 objects. in general data contains of title, object location, description , object image. for i'm storing "metadata" (location, title , id) in javascript file using object literal notation , loading on startup. descriptions (formatted text) stored in seperate html files loaded on demand iframe. everything fine while because had 10 object descriptions added project. after loading of descriptions, application startup time increased more 10 seconds. it seems problem cordova unable handle projects lots of files getting processed on startup. techniques used minimize file count without increasing code complexity , improve application performance? if have 3000 objects better off storing them in db , setting on startup of application: http://simonmacdonald.blogspot.com/2011/12/on-second-day-of-phonegapping-copying.html

ajax - Why does Internet Explorer Cache xhr requests? -

i see lot of questions on how fix overly-aggressive caching ie , ajax can't seem find information on why such thing. there ever reason cache ajax calls? caching ajax results wise same reasons cache non-ajax responses. don't want make round-trip server if have data in cache. if want force trip made, instruct data not cached via response headers, or use of various other methods cache-busting appending current timestamp request's query-string.

c++ - StillImage::GetDeviceList Pointer -

i'm trying make call method call called getdeviceslist in interface called stilliamge , getting empty results. think pointer problem i'm not c++ expert , think problem. method call is: hresult getdevicelist( dword dwtype, dword dwflags, [out] dword *pdwitemsreturned, [out] lpvoid *ppbuffer ); i know working when plug imaging devices in , out eh nubmer of returned devices goes , down. fact result blank think due me not getting pointers correct - take quick , let me knwo if reason please? #include "stdafx.h" bool debug = true; int _tmain(int argc, _tchar* argv[]) { dword dwstitotal = 0; psti psti = null; hresult hres = sticreateinstance(getmodulehandle(null), sti_version, &psti, null); sti_device_information deviceinfo[255]; memset(deviceinfo,0, sizeof(deviceinfo)); hres = psti->getdevicelist(null, null, &dwstitotal, (lpvoid*) deviceinfo); printf("number devices %d\n", dwstitotal); (int i=0...

objective c - UIImagePickerControllerCameraDeviceFront only works every other time -

in app i'm attempting use front camera default in uiimagepicker . know, seems simple enough... imagepicker.cameradevice = uiimagepickercontrollercameradevicefront; now, first time launch picker works fine , front camera initialized, when picker dismissed, , presented again camera used. there on out if continuously open , close picker camera used be: front, back, front, back, front, back... i've stripped code down bare basics of picker attempting isolate problem , persists. has run issue before? pointers or direction appreciated! edit: problem solved! calling imagepicker = [[uiimagepickercontroller alloc] init]; in viewdidload instead of viewdidappear ! the problem must @ how try initialize/present/dismiss controller. so, why , forth between cameras? it seems underlying avcapturesession reason kept running after dismiss of controller. next time presented it, tried add input bussy, went next available (the rear camera), interrupted (thus freeing prev...

How do I dynamically create properties in Python? -

suppose have class this: class alphabet(object): __init__(self): self.__dict = {'a': 1, 'b': 2, ... 'z': 26} @property def a(self): return self.__dict['a'] @property def b(self): return self.__dict['b'] ... @property def z(self) return self.__dict['z'] this long , cumbersome task define , seems highly redundant. there way dynamically create these properties? know can dynamically create attributes built-in setattr, want have control on read/write/delete access (for reason want use property). thanks! don't use properties implement following methods: __getattr__(self, name) __setattr__(self, name, value) __delattr__(self, name) see http://docs.python.org/reference/datamodel.html#customizing-attribute-access your __getattr__ method this: def __getattr__(self, name): try: return self.__dict[name] except keyerror: ...

ruby on rails - how to send mail through user emailID instead of userID in has_mailbox gem? -

is there way send message recipient using email id in has_mailbox gem? what kind of changes needs done plug-in has_mailbox? actually happen when try send through user id works well,but when write email in recipient text_box of user gives me following error. e.g. case1 :sending message through user id:1,which send message recipient case 2: here i'm sending though email(e.g xyz@gmail.com), gives me following error after click on send, activerecord::recordnotfound in mailboxescontroller#create couldn't find user id=0 so, how solve this?

javascript - Identifying Jquery Selector -

i'm new javascript , jquery. what selector mean: " #layoutcolumn2 > div > div > div > ul" contect (the function comes from): function loadnexttier(tierid, changeditemvalue) { linkarray.length = 0; $("#placeholderforload").load(changeditemvalue + " #layoutcolumn2 > div > div > div > ul", function(){ $("#placeholderforload li").each(function(){ var itemname = $(this).children("a").text(); var itemvalue = $(this).children("a").attr("href"); linkarray.push(itemvalue+";"+itemname); }); if (tierid == "tier1") { tierid = "tier2"; } else if (tierid == "tier2"){ tierid = "tier3"; } else if (tierid == "tier3") { tierid = "tier4"; } resettiers(tierid); fillmylist(linkarray, tierid); }); it match following structure <a...

ios5 - Is there any supported Bluetooth profile which is used in iOS except 6 profiles(HFP, PBAP, A2DP, AVRCP, PAN, HID)? -

is there supported bluetooth profile used in ios5 except 6 profiles(hfp, pbap, a2dp, avrcp, pan, hid)? can use spp(serial-port profile) developing iphone app? if want use serial port profile(spp),either need apply mfi or use mfi certified devices communicate ios. here mfi link https://developer.apple.com/programs/mfi/ in addition above profiles map supported ios6. you can find supported profile under link http://support.apple.com/kb/ht3647

graph - JavaScript graphing tools -

i have page im making ajax call data php page. display data graph using javascript in page. tools out there sort of task ? data getting updated every half minute or so. need handle time axis well, , line graphs needed mainly. thanks in advance. highcharts jscharts plotkit jquery sparkline jquery visualize plugin jqplot milkchart canvas 3d graph moochart tufte graph protochart flot protovis plotly original source

How to run a specific condition in script after a specific time in php -

i have 2 ad's , want run them in difference of 8 hours, means ad1 start when script start , ad2 start after 8 hour specified 28800 seconds. seeking functions sleep() , time_sleep_until() , bit confused how use them between ad's. my ad's defined in array. also, tried once sleep function in localhost execute 1 ad , 1 after sleep(28800) , , script continues executing , displays output of both ad's. might small problem , didn't apply logic properly. it sounds there confusion on php responsible doing here. when makes request web server, php script being invoked, after serving request, done , exits. when next request comes in, has no knowledge of first request. if use sleep(n) function sleep n seconds, pause response of web server, bad idea , not trying achieve. generally speaking, if want switch content based on time, better work off of server time (which known) rather "how long server has been running" has no meaning in real world. in...

jquery - How to add the hyphen in html textbox? -

i use following code create textbox enter phone number in run time .how add hyphen(-) in between phone numbers.for example if type 1234567 entry should show 123-45-67 how this? how in jquery? <input id="abcd" type="text" value="" style="width:220px"> you have use javascript this. think this starting point... bottom line is, though, have scripting this. (basically, when field changed, check if it's right amount of #s, , add hyphen if necessary.) i recommend jquery this; a quick google turns useful results. keep in mind phone numbers different parts of world hyphenated differently. usa, example, uses +x-xxx-xxx-xxxx, while argentina uses +xx-xx-xxx-xxxx. european countries use +xxx-xxxx-xxxx.

Reading Json Data in Jquery -

i have json data returning service. here complete json data d: "[{"imagepath":null,"themetemplateid":1,"borderwidth":null,"borderstyle":null,"optiontextunderline":null,"optiontextitalic":null,"optiontextbold":null,"optiontextsize":null,"optiontextfont":null,"questiontextunderline":null,"questiontextitalic":null,"questiontextbold":null,"questiontextsize":null,"questiontextfont":null,"surveytitleunderline":null,"surveytitleitalic":null,"surveytitlebold":null,"surveytitlesize":null,"surveytitlefont":null,"bordercolor":null,"surveytitlecolor":null,"optiontextcolor":null,"themename":null,"backgroundcolor":null,"questiontextcolor":null},{"imagepath":null,"themetemplateid":2,"borderwidth":null,"bord...

matlab - how to generate possible distinct sets of pairs from a given set? -

in matlab how do this? have set of n elements from set make new set of n/2 pairs such elements in different pairs distinct. how generate distinct sets of such n/2 pairs n elements in matlab? e.g. input set - {1,2,3,4} possible output sets - {{1,2},{3,4}} {{1,3},{2,4}} {{1,4},{2,3}} i not find clean solution "distinct elements each halved-vector" requirement. suggest check each result individually. expect there's better solution around: 1 job. x = [1 2 3 3]; xsize = size(x,2); p = perms(x); = unique(p,'rows'); result = []; entry=up' left = entry(1:xsize/2); right = entry(xsize/2+1:xsize); if numel(unique(left)) == xsize/2 && numel(unique(right)) == xsize/2 result = vertcat(result,entry') end end just completeness, result is: 1 3 2 3 1 3 3 2 2 3 1 3 2 3 3 1 3 1 2 3 3 1 3 2 3 2 1 3 3 2 3 1 i not sure if needed split halved vectors. in case, put left , rig...

database - Impact of bulk insertion and bulk deletion to the MS SQL server 2008 -

does know what's impact of mssql 2008 database when executing insert , delete sql statement around 100,000 records each run after period of time? i heard client saying mysql , specific data type, after loading , clearing database period of time, data become fragmented/corrupted. wonder if happens ms sql? or possible impact database? right statements use load , reload data in tables in database simple insert , delete statements. please advice. thank in advance! :) -shen the transaction log grow due inserts/deletes, , depending on data being deleted/inserted , table structure there data fragmentation the data won't 'corrupted' - if happening in mysql, sounds bug in particular storage engine. fragmentation shouldn't corrupt database, hamper performance you can combat using table rebuild, table recreate or reorganise. there's plenty of info regarding fragmentation online. article here: http://www.simple-talk.com/sql/database-administrati...

c - ERROR:../../mono/io-layer/handles-private.h:362 -

i execute application in debian 6 os. time time there exception: error:../../mono/io-layer/handles-private.h:362:_wapi_handle_share_release: assertion failed: (info->handle_refs > 0) stacktrace: at (wrapper managed-to-native) system.io.monoio.close (intptr,system.io.monoioerror&) <0x00004> @ (wrapper managed-to-native) system.io.monoio.close (intptr,system.io.monoioerror&) <0x00004> @ system.io.filestream.dispose (bool) <0x00094> @ system.io.stream.close () <0x0001b> @ system.io.stream.dispose () <0x00019> @ (wrapper remoting-invoke-with-check) system.io.stream.dispose () <0x00053> @ sarum.logger.log.writetofile (sarum.logger.slogmessage,bool) <0x0077d> @ sarum.logger.log.writelineasync () <0x00212> @ (wrapper runtime-invoke) object.runtime_invoke_void_ this _ (object,intptr,intptr,intptr) <0x00040> native stacktrace: /usr/bin/cli() [0x80d5b19] [0xdf6600] /...

How to correct this MySQL database set up? -

one of mysql databases using on 99% cpu when running php/drupal queries. i investigating root cause. using following profiling , configuration data can suggest main db setup problems or missing/incorrect configuration ? bash free : total used free shared buffers cached mem: 2048 1635 412 0 0 0 -/+ buffers/cache: 1635 412 swap: 0 0 0 ps auxf : root 7430 0.0 0.0 9176 1400 ? s may30 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/db.pid mysql 7617 0.6 12.3 486900 258956 ? sl may30 114:26 \_ /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/db.err --pid-file=/usr/local/mysql/data/db.pid --socket=/tmp/mysql.sock he...

ruby - How do I add to a rails session when submitting to same page? -

i have need number of form pages in row each form submits same index page. on each submit different view displayed depending on how input fields validated. controller: class formscontroller < applicationcontroller include formshelper def index #if know view show, show it, else show first view in flow if(!session.has_key?(:flow_page)) set_flow_page end # if form submitted, want add pages submit data have in session[:quote] if(params.has_key?(:form)) temp = params[:form] form = session[:quote] form.merge(temp) #session[:quote].deep_merge!(session[:temp]) end # other stuff if params[:back] == "back" && params[:flow][:previous_page] != "refused" session[:flow_page] = params[:flow][:previous_page] end if params[:next] == "next" session[:flow_page] = params[:flow][:next_...

c - How to do arithmetic with OpenCL host vector types? -

heres code: #include <stdio.h> #include <cl/cl.h> #include <cl/cl_platform.h> int main(){ cl_float3 f3 = (cl_float3){1, 1, 1}; cl_float3 f31 = (cl_float3) {2, 2, 2}; cl_float3 f32 = (cl_float3) {2, 2, 2}; f3 = f31 + f32; printf("%g %g %g \n", f3.x, f3.y, f3.z); return 0; } when compiling gcc 4.6, produces error test.c:14:11: error: invalid operands binary + (have ‘cl_float3’ , ‘cl_float3’) very strange me, because opencl specification demontrates in section 6.4 that, addition of 2 floatn . need include other headers? but more strange when compiling -std=c99 errors like test.c:16:26: error: ‘cl_float3’ has no member named ‘x’ ..for components (x, y , z)... opencl programs consist of 2 parts. a program runs on host. written in c or c++, it's nothing special except uses api described in sections 4 & 5 of opencl specification. a kernel runs on opencl device (normally gpu). written in languag...

ruby on rails 3 - jQuery ujs inside of a jquery modal not working -

i have of forms different controllers in jquery dialog modal box, , problem i'm running when modals loaded, ujs links(data-remote, data-confirm, etc) ignored jquery. i'm thinking when partials getting loaded through ajax, events aren't bubbling include new links added dom ajax. has run this? can't seem figure out way around it. can post code if wasn't clear... if markup being added dynamically events going work if make use of event delegation. there's pretty writeup on basics of event delegation in jquery here - http://jqueryfordesigners.com/simple-use-of-event-delegation/ . you'll want switch handlers created through bind use on .

web applications - How can a Blackberry app send push notifications to both BIS and BES users? -

i've been tearing what's left of hair out days trying wrap blackberry version of mobile app producing. although other parts of bb dev have been frustrating, nothing compares implementing push notifications. i have read of pdfs , other doc pages rim provides push notifications, seems purposely vague important details. there pages , pages in every pdf trying sell on push plus service, , sentence or 2 important details. have looked @ scant few samples, contrived , don't help. the 1 question (which seems me pretty common 1 mobile devs) can't answer this: is possible write public app blackberry -- normal persons app not crazy company specific stuff -- both bis , bes (personal , corporate) users can both install , use push notifications? it seem answer yes, facebook uses push notifications , assume both kinds of users can use facebook -- docs clear mud how go making public app can send notifications bes users. this problem have solve if @ possible, if means ...

javascript - Inner HTML if statement not recognizing a div tag -

i tested following code in ie, chrome, , firefox , not work in of them. have read several questions similar problems have not offered solutions fix example. i trying create pause/play button interfaces jwplayer (i want interface flowplayer, once button working) , image change depending on image there. have stop button stops player , changes image of pause/play button pause. here current code: <script type="text/javascript"> function changeimg() { var obj = document.getelementbyid('image1'); var imgtag1 = '<img src=\'play.png\'>'; var imgtag2 = '<img src=\'pause.png\'>'; if(obj.innerhtml == imgtag2) {obj.innerhtml = imgtag1;} else {obj.innerhtml = imgtag2;} return; } function playimg() { document.getelementbyid('image1').innerhtml = '<img src=\'play.png\'>'; return; } </script> <div id="image1" href="#" onclick="changeimg();...

java - best way to code for Netty FrameDecoder.decode -

i running problems coding framedecoder.decode() tcp netty client. protected object decode(channelhandlercontext ctx, channel channel, channelbuffer buffer) throws exception { in above signature , buffer supposed contain bytes need framed. why obejct have returned ? aware if returned object null , indicates more data required buffer, happens if return buffer unread bytes of partial frame in ? invoked more bytes added ? lets given invocation of decode() has buffer 100 bytes in it. out of 100 , there 2 full frames of 25 , 55 bytes , partial frame of 20 bytes. can read first full frame ( of 25 bytes ) , return buffer ( 75 bytes in - 1 full frame of 55 bytes , 20 bytes of partial frame ) ? cause bytes overwritten next time decode invoked ? or ok me read next frame ( of 55 bytes ) in next invocation ? you return 1 frame per each call of decode. framedecoder continue read , forward read frames until return null. bytes left in framedecoder saved , once new channel...

c# - Add loading indicator to google maps infoWindow -

currently, when user clicks on location marker on our map screen, page method called retrieve additional information server. when page method successful, results used define contents of infowindow displayed on map. in situations page method slow, infowindow displayed immediately, loading indicator. after page method successful, content of infowwindow updated. so far, naive approach has been create infowindow loading indicator , display initial infowindow call open(map), , update contents of infowindow after page method successful. approach, however, not work, since map canvas not updated until after page method has completed (the initial version of infowindow therefore never displayed). ----- page code ----- <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.8&client=my_client&sensor=false"></script> <script type="text/javascript"> function initialize_map() { map = new google.ma...

Get div content with jQuery for PHP -

update : wow fastest response ever , many answers in minutes of each other. amazing. ok here trying do. http://edvizenor.com/invoice33/ i want edit invoice on fly when hit blue box @ top want preview or see content on next page contained php var echoed out. this blue box change later button @ bottom testing using it. as see calls ajax script need edited content of div sent php var can echo on preview page. if can put in php var on next page. make sense? guys quick responses. old post is possible contents of div using jquery , place them in php var send via or post? i can contents of div jquery this: <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script> $(document).ready(function() { $("#mybutton").click(function() { var htmlstr = $("#mydiv").html(); }); }); ...

sql - Replace all occurrences of a substring in a database text field -

i have database has around 10k records , of them contain html characters replace. for example can find occurrences: select * table textfield '%&#47%' the original string example: this cool mega string contains &#47 how replace &#47 / ? the end result should be: this cool mega string contains / if want replace specific string string or transformation of string, use "replace" function in postgresql. instance, replace occurances of "cat" "dog" in column "myfield", do: update tablename set myfield = replace(myfield,"cat", "dog") you add clause or other logic see fit. alternatively, if trying convert html entities, ascii characters, or between various encoding schemes, postgre has functions well. postgresql string functions .

svn checkout to viewvc link give back redirecting url error -

i'm trying svn checkout following: http://website.com/viewvc/tool error: svn: e195019 redirect cycle detected url... i'm not quite sure if should using viewvc link svn checkout, couldn't find else checkout on viewvc page. doing wrong? thanks michael's able answer. viewvc urls not same svn urls , cannot interpreted in same way. calling svn checkout viewvc link not work. have change link: website.com/viewvc/tool website.com/svn/tool and svn should work usual

caching - Why Spring message converters still being invoked in @Cachable methods -

lets have 2 methods in controller support both json , xml. @requestmapping(value = "/get/response.json", method = requestmethod.get) @cacheable(json_cache) public @responsebody jsonresponse getjsonresponse(){ return responseservice.getjsonresponse(); } @requestmapping(value = "/get/response.xml", method = requestmethod.get) @cacheable(xml_cache) public @responsebody xmlresponse getxmlresponse(){ return responseservice.getxmlresponse(); } and 2 message converters, marshalling objects suitable response. <bean class="org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter"> <property name="messageconverters"> <list> <ref bean="jsonconverter"/> <ref bean="xmlconverter" /> </list> </property> </bean> the problem spring 3.1, though method annotated @cachable , still invokes marshaller every call....

png - Image properties in XCode inspector does not show size for images -

Image
i'm curious why right-hand property inspector window xcode not show dimensions , resolution png images when select image (the image preview works fine). image properties shows "--" (double dash) each property in screenshot: 1 ps. use xcode 4.3.3 , lion 10.7.4

android - SQLite sorting by Fields -

i newbie sqlite , don't know how sort fields. searched use "order by", cannot well. have class implement sqlite functions follow: public class plsqliteopenhelper extends sqliteopenhelper{ public string tablenames[]; public string fieldnames[][]; public string fieldtypes[][]; public static string no_create_tables = "no tables"; private string message = ""; public plsqliteopenhelper(context context, string name, cursorfactory factory, int version, string tablenames[], string fieldnames[][], string fieldtypes[][]) { super(context, name, factory, version); tablenames = tablenames; fieldnames = fieldnames; fieldtypes = fieldtypes; } @override public void oncreate(sqlitedatabase db) { if(tablenames == null){ message = no_create_tables; return; } for(int = 0; < tablenames.length; i++){ string sql = "create table " + tablenames[i] + "("; for(int j = 0; j < fieldnames...

How to upsert (update or insert) in SQL Server 2005 -

i have table in inserting rows employee next time when want insert row don't want insert again data employee want update required columns if exits there if not create new row how can in sql server 2005? i using jsp my query is string sql="insert table1(id,name,itemname,itemcatname,itemqty)values('val1','val2','val3','val4','val5')"; if it's first time insert database else if exists update it how do? try check existence: if not exists (select * dbo.employee id = @someid) insert dbo.employee(col1, ..., coln) values(val1, .., valn) else update dbo.employee set col1 = val1, col2 = val2, ...., coln = valn id = @someid you wrap stored procedure , call stored procedure outside (e.g. programming language c# or whatever you're using). update: either can write entire statement in 1 long string (doable - not useful) - or can wrap stored procedure: create procedure dbo.insertorudp...

mysql - generate 16M unique random numbers -

i'm trying generate 16 000 000 unique random numbers (10-digits: range 1 000 000 000 - 9 999 999 999) , insert them empty table (or fill table if not empty). the table: create table `codes` ( `code_id` bigint(20) unsigned not null auto_increment, `code` bigint(20) unsigned not null, `is_used` tinyint(1) not null default '0', primary key (`code_id`), unique key `code` (`code`) ) engine=innodb default charset=utf8 auto_increment=1 ; ...and function: delimiter $$ create definer=`root`@`localhost` function `codes`(`minrange` bigint unsigned, `maxrange` bigint unsigned, `_amount` bigint unsigned) returns tinyint(1) modifies sql data begin declare pick bigint; while (select count(*) codes) < _amount begin set pick = minrange + floor(rand() * (maxrange - minrange + 1)); insert ignore codes (code) values (pick); end; end while; return 1; end$$ delimiter ; -- call: select codes(1000000000,9999999999,16000000); the function extremaly slow: generating 20k rows ...