Posts

Showing posts from September, 2011

php - Sort array by value then key -

this question has answer here: php array multiple sort - value key? 9 answers i'm using asort sort simple array: $arr = array('a'=>30, 'b'=>12, 'k'=>23, 'x'=>1, 'h'=>11, 't'=>1, 'u'=1); asort($arr) yields array ( [a] => 30 [k] => 23 [b] => 12 [h] => 11 [x] => 1 [t] => 1 [z] => 1 ) is there native way sort value and key in 1 call (while preserving key/value relationship)? for example, i'm wanting results end this: array ( [a] => 30 [k] => 23 [b] => 12 [h] => 11 [t] => 1 [x] => 1 [z] => 1 ) native function not, there ways easily php array multiple sort - value key?

jquery - Ecommerce thumbnail gallery viewer -

usually found on ecommerce websites, have main image , 5 thumbnails. have main image change when click on smaller thumbnail (different views). here's example of i'm looking on site. i'm looking plugin of sort allow me achieve this. html: <div class="product"> <img src="pro.jpg"> </div> <ul class="product-thumb"> <li><img src="1.jpg"></li> <li><img src="1.jpg"></li> <li><img src="1.jpg"></li> </ul> this looks simple . you should check in different browsers . ie http://jquerytools.org/demos/scrollable/gallery.html http://papermashup.com/simple-jquery-gallery/

sql - TSQL Convert rows to columns -

i have query returns data looks this: description ---------- thing1 thing2 thing3 thing4 thing5 thing6 thing7 i make data this: desc1 desc2 desc3 ----- ----- ----- thing1 thing2 thing3 thing4 thing5 thing6 thing7 could provide example on how this? thanks! you stated comments order of data in desc columns not matter. if case, can use following implement ntile , row_number() : ;with cte ( select description, 'desc'+cast(ntile(3) over(order description) varchar(10)) col yt ) select desc1, desc2, desc3 ( select description, col, row_number() over(partition col order col) rn cte ) d pivot ( max(description) col in (desc1, desc2, desc3) ) piv; see sql fiddle demo . the ntile function distributes rows separate groups. once done, apply row_number() give unique number each row while grouping. this gives result: | desc1 | desc2 | desc3 | ---------------------------- | thing1 | thing4 | thing6 | | thing2 | thing5 |

javascript - Image wrong orientation in html5 preview -

Image
suppose image not upright (i open in window browser , image not upright), when upload server (such gmail, stackoverflow). image becomes upright. i asked question writing preview logic html5 , javascript. image talk show see in window browser. wondering if server did trick adjust orientation? image shown in windows: image directly upload stack overflow: i'm guessing talking image generate or manipulate client-side using canvas element rendered img tag. correct? server-side, orientation can determined looking @ image's exif orientation flag. possible examine flag client-side using library jquery fileexif .

c - Assign Latitude and Longitude values to pixels -

this problem have been trying solve time. have binary file, that, after processing, leaves me binary bmp file, i.e, pixels have 2 values. now, have me following hdr file: envi description = { polsarpro file imported envi} samples = 2618 lines = 2757 bands = 1 header offset = 0 file type = envi standard data type = 4 interleave = bsq byte order = 0 map info = {utm, 1, 1, 399711.555, 2641320.529, 12.500, 12.500, 45, north, wgs-84} wavelength units = meters band names = { spf_l1.bin } generated envi , polsarpro. problem facing softwares envi calculate latitude & longitude values each pixel, while not able find method replicating same in program ( using c, using polsarpro's source files base ). if 1 me explaining how assign positional information, highly appreciated! p.s: point of view, map info - lists geographic coordinates information in order of projection name (utm), reference pixel x location in file coordinates, pixel y, x pixel size, y pixel size, projection

android - Get resource id from which view was inflated -

is there way obtain resources id (like r.layout.viewtoinflate) of layout view inflated? i trying implement list view uses 2 custom layouts list items. item layout used based on field in objects used populate list view. what missing in custom adapter way know resource 'convertview' in getview() inflated from. if info can compare , determine whether can re-use convert view or if have replace appropriate layout current item. so ideally this: @override public view getview(int position, view convertview, viewgroup parent) { viewholder holder; jsonobject curritem = mitems.getjsonobject(position); int layouttype; if (curritem.getboolean("alternate")) layouttype = r.layout.list_item_b; else layouttype = r.layout.list_item_a; if (convertview == null || <convertview.resourceid> != layouttype ) { convertview = inflater.inflate(layouttype, null); //finish setting new view , holder } else {

command - launch a folder in windows explorer with php -

hi there trying launch folder in windows explorer dosent seem work code trying $contain_path = 'e:\something\some folder'; $folder = '9999 - folder name here'; $command = 'explorer "'.$contain_path.'\\'.$folder.'\\"'; system($command,$var); i tried, didn't succeed with system($command,$var); its local wampserver project. making such when press button. ajax script call php page , php page executes above code , explorer window pops when execute command given above through command prompt. doing wrong here? quickest guess explorer should c:\windows\explorer.exe

powershell - Conditional loading of snapins in profile -

we have internal application utilizes powershell. in profile (microsoft.powershell_profile.ps1) have added references various snap-ins we've created: # # profile joe blow # add-pssnapin companysnapin add-pssnapin powershelltesttools add-pssnapin sqlservercmdletsnaps -erroraction silentlycontinue the problem i'm having when start internal application, above lines of code, throw errors. my question is, there way (in profile script) can test or trying open profile , things accordingly ? example might be: if (!internalapplication) { add-pssnapin companysnapin add-pssnapin powershelltesttools add-pssnapin sqlservercmdletsnaps -erroraction silentlycontinue } so snapins if launch powershell command line utility. otherwise, nothing "added". thanks ! it depends on custom app/ host implementation, really. means there @ least few ways skin cat. you can start checking if $host.name differs. next - check if properties present/ set (like

Math proof required (Probability) -

from pr[e] = pr[e|a].pr[a] + pr[e|a'].pr[a'] how can prove pr[e] <= pr[e|a] + pr[a'] pr[e] <= pr[e|a] + pr[a'] the left side can replaced first line.. pr[e|a].pr[a] + pr[e|a'].pr[a'] <= pr[e|a] + pr[a'] hmm lets subtract "pr[e|a].pr[a]" on both sides. on right side, can translate pr[e|a] = pr[e|a]*1 = pr[e|a] (pr[a] + pr[a']) pr[e|a'].pr[a'] <= pr[e|a].pr[a'] + pr[a'] now can put both sides brackets in order isolate pr[a'] ( pr[e|a'] ) * pr[a'] <= ( pr[e|a] + 1 ) * pr[a'] and divide pr[a'] pr[e|a'] <= pr[e|a] + 1 so.. if.. pr[e|a] = 0 both sides can equal (if left side 1) in other cases right side larger, since more 1, , left side can maximum 1

datetime - Solr: Best way to query for documents added this current week? -

alright guys. want query in such way hit same filter cache, dont want calcuate start of week in code , structure query based on that. there way solr returning based on week ? i couldnt find here : http://docs.lucidworks.com/display/lweug/solr+date+format using [now/day-7days now/day+1day] wont since not know start , end of week. does involve calculation on client side , formulating query based on that, so, not looking :) in java (if week starts on monday): client: (new date().gettime()-345600000)/604800000 = 2257 query: select?q=*:*&fq={!frange%20l=2257%20u=2258}div(sub(field(last_update),345600000),604800000)&wt=json&indent=true

c++ - How can I resize a 2D vector of objects given the width and height? -

my class, gameboard , has member variable 2d vector of object of class tile . gameboard constructor takes width , height parameters. how can 2d vector of tile objects resize according width , height passed constructor? how can fill tile objects can this? myvector[i][j].getdisplaychar(); snippet m_vvtiles.resize(iheight); for(auto = m_vvtiles.begin(); != m_vvtiles.end(); it++ ){ (*it).resize(iwidth,tile(' ')); } you have resize outer , inner vectors separately. myvector.resize(n); (int = 0; < n; ++i) myvector[i].resize(m);

ms access - 'Object Required' to send Email -

i'm trying make function sends email email address in 1 of queries (upcomingbirthday). i've got code in function , in macro autoexec runs when load database. public function emailsend() dim imsg object dim iconf object dim flds object dim schema string set imsg = createobject("cdo.message") set iconf = createobject("cdo.configuration") set flds = iconf.fields schema = "http://schemas.microsoft.com/cdo/configuration/" flds.item(schema & "sendusing") = cdosendusingport flds.item(schema & "smtpserver") = "smtp.live.com" flds.item(schema & "smtpserverport") = 25 flds.item(schema & "smtpauthenticate") = cdobasic flds.item(schema & "sendusername") = "myemail@hotmail.com" flds.item(schema & "sendpassword") = "mypassword" flds.item(schema & "smtpusessl") = false flds.update imsg call emailsend(upcomingbirthday.[email

c# - Accessing coded char set id in IBM MQ -

when read message remote queue manager has coded character set id 819, sent message has codedcharsetid=1208 , connecting via 7.x client 6x (remote queue)? how 819 in export queue instead of 1208, don't want hard code in message mqqmgr.codedcharsetid =819; instead want access coded char set id attribute/property(so that, can dynamic). this might you: if using mq .net client, character set unicode, 1208 because .net applications run in unicode. readstring & readline methods of mqmessage class convert data in message characterset specified while doing whereas writestring , writeline methods convert given data characterset specified during put.

html5 - Rich Snippet Duplicates - Harmful? -

does using rich snippet duplicates effect seo search engines google? im implementing clients website , have 2 telephone numbers. using telephone snippet twice cause harm? best if stick schemas on http://schema.org . organisation schema requires 1 telephone number, add multiple contactpoint types accomodate phone numbers, particularly if each number has particular purpose

html5 - Horizontal menu using css transform on hover -

i'm trying make pull out navigation user hovers on "menu" handle , pulls out. i'm having success doing coming top, want boxes stacked horizontally , coming left side, moving right. this code: <!doctype html> <html> <head> <style> nav { position:absolute; top:-190px; } .menu:hover { -webkit-transform:translate(0px,190px); -moz-transform:translate(0px,190px); -o-transform:translate(0px,190px); -ms-transform:translate(0px,190px); transform:translate(0px,190px); -webkit-transition:ease-in-out; -moz-transition:ease-in-out; -o-transition:ease-in-out; -ms-transition:ease-in-out; transition:ease-in-out; -webkit-transition-duration: .5s; -moz-transition-duration: .5s;

xcode - iOS mapView animatesDrop -

in mapview, have bool animatesdrop annotations set no. because when mapview annotations plotted during viewwillappear, don't when them animated. however, have refresh button used re-plot annotations , them animated (drop) when pushed. there way of accomplishing this? thanks. -(mkannotationview *)mapview:(mkmapview *)mapview viewforannotation:(id<mkannotation>)annotation { if ([annotation iskindofclass:[mkuserlocation class]]) { return nil; } mypin = [[mkpinannotationview alloc] initwithannotation:annotation reuseidentifier:@"current"]; uibutton *calloutbutton = [uibutton buttonwithtype:uibuttontypedetaildisclosure]; uibutton *directionsbutton = [uibutton buttonwithtype:uibuttontypecustom]; directionsbutton.frame = cgrectmake(0, 0, 23, 23); [directionsbutton setbackgroundimage:[uiimage imagenamed:@"directions.png"] forstate:uicontrolstatenormal]; mypin.leftcalloutaccessoryview = directionsbutton; mypin

android - Catch adb messages in the device -

is there way catch messages of adb inside android device - i'd os messages too, not in log cat? if possible want see messages coming application while testing , sort them algorithm show in maketoast message app? ok found looking for http://elinux.org/android_logging_system

javascript - Can one detect if an element's style is just the browser default vs. is set by a stylesheet or inline styles? -

my javascript included in x's site, don't have other control on site or includes it. if she's styled #element , want leave alone, if hasn't, i've got stylesheet i'll inject in <head> . there way detect whether or not she's styled it? checking it's height 0 or 1 fails because it's got content in , browser makes default decisions. any way javascript/jquery/other framework tell css specificity of style answer , incredible. a straightforward imperfect way of knowing if there intent style element check if style attribute of element has value or if class attribute of element has been set. http://jsfiddle.net/ybspc/ html <div id="test_unstyled"></div> <div id="test_styled" style="background-color: red;" class="something"></div> js var unstyled = document.getelementbyid('test_unstyled'), styled = document.getelementbyid('test_styled'); co

python - Get a list of dynamic properties with an NDB Expando Model? -

with db appears myexpando.dynamic_properties(), trying in ndb attributeerror dynamic_properties. can't find in docs change this. when using ndb should using _properties list of properties db, ndb, users, urlfetch, , memcache modules imported. dev~cash-drawer> class x(ndb.expando): ... pass ... dev~cash-drawer> dev~cash-drawer> dev~cash-drawer> y = x() dev~cash-drawer> y.a = ndb.genericproperty() dev~cash-drawer> y.a = 100 dev~cash-drawer> y.a 100 dev~cash-drawer> repr(y.a) '100' dev~cash-drawer> type(y.a) <type 'int'> dev~cash-drawer> y._properties {'a': genericproperty('a')} dev~cash-drawer> see docs https://developers.google.com/appengine/docs/python/ndb/entities#expando

ASP.NET 4.5, ImageButton OnClick not firing on MasterPage -

i have imagebutton in masterpage , it's not firing onclick event. in pages without masterpage works. http://www.quotehd.com/default.aspx not have masterpage , if enter word 'funny' in search works, if try search http://www.quotehd.com/topics uses masterpage not fire code masterpage. this masterpage aspx code: <asp:imagebutton id="lnkgo1" runat="server" cssclass="searchsubmit" imageurl ="/content/themes/pin/images/search.png" onclick="lnkgo1_click" causesvalidation="false" viewstatemode="disabled" enableviewstate="false"> </asp:imagebutton> c# masterpage code: protected void lnkgo1_click(object sender, imageclickeventargs e) { response.redirect("~/quotes/search/words/" + httputility.htmlencode(txtsearch1.text)); } the same code works on /default.aspx not have masterpage, if access homepage default.aspx

oracle - Result doubles when the row count is greater than 9 -

i have problem query because doubles results when total number of columns greater 9. query used is: select * ( select lol.* , row_number() on (order regexp_substr(wipdatavalue, '^\d+')) n , count(*) over() m ( select wipdatavalue , containername , l , q qtybox , d , qtyperbox q , productname , dt , dsn , case when instr(wipdatavalue, '-') = 0 to_number(wipdatavalue) else to_number(substr(wipdatavalue, 1, instr(wipdatavalue, '-') - 1)) end una , case when instr(wipdatavalue, '-') = 0 to_number(wipdatavalue) else to_number(substr(wipdatavalue, instr(wipdatavalue, '-') + 1)) end dulo trprinting_ls containername = :lotid )lol start instr(wipdatavalue, '1') > 0 connect level between regexp_substr(wipdatavalue, '^\d+') , regexp_substr(wipdatavalue, '\d+$') ) n :n; i'm guessing because of connect level between regexp_substr(wipdatavalue, '^\d+') , regexp_substr(wipdatavalue, '\d+$') maybe d perta

php - Iterate an array for HTML -

i have following array unsure how via foreach can break through key can use in html this: <?php echo $key['cat_id'];?> php: <?php foreach($by_category_manufacturer $key ):?> <pre><?php var_dump($key)?></pre> <?php endforeach;?> array: array(6) { [0]=> object(stdclass)#92 (5) { ["brand_name"]=> string(5) "kioti" ["brand_id"]=> string(2) "10" ["image_id"]=> string(2) "23" ["cat_id"]=> string(1) "3" ["cat_name"]=> string(9) "machinery" } convert php object associative array convert object associative array, may done recursively

android - Read and return the apps installed on the device -

this question has answer here: list of user installed apps 6 answers i new developer in android , struggling develop application, because need function or read , return apps installed on device, if can me thank you //getting label name install packagemanager p = mcontext.getpackagemanager(); list<applicationinfo> info = p.getinstalledapplications(0); for(int i=0;i<info.size();i++){ string label = p.getapplicationlabel(info.get(i)).tostring(); system.out.println("label:"+label); }

sitecore6 - Sitecore ECM Engagement plan Custom action in "Message Opened" state -

i need update few information regarding visitor when visitor in message opened state of sitecore ecm standard engagement plan. therefore need create custom action or can push in custom code visitor data manipulation. i tried doing via creating script , attaching trigger , attaching trigger state. no luck unfortunately. is task possible or missing ? thanks in advance the message opened state forbidden change. kind of system ecm state. can customize states of green area (productive, unproductive, etc.). however there way want. moment of message open handled of small image added @ bottom of mail. image source aspx page. when recipient downloads mail images, aspx page requested. can customize aspx page requested image (add code there).

ios - Why this prepare segue is not working? -

Image
when click tableview want send currentbook details viewcontroller "detailpage" , here not sending value?? why shows error? error : unknown receiver "tableview" why creating 2 gmmdetailpage objects? also, should have self.tableview instead of tableview. better pass tableview prepareforsegues:sender: method so: - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [self performseguewithidentifier:@"bookitem" sender:tableview]; }

user interface - Sending Matlab GUI into the background -

i have annoying problem matlab gui. once start program gui can not send background, pops again arbitrary number of times, until decides stay. have minimize @ least 10 times before stays there. is common behaviour? have not modified of gui initialization code, added button execute function in loop. any ideas welcome! cheers, chris yeah, annoyed too. can hide gui (either within code or on command line) with set(myguifigurehandle, 'visible', 'off') and restore set(myguifigurehandle, 'visible', 'on') which fine in situations, not if user wants minimize time being. detect minimize , hide, figure window disappear task bar, , way restore visibility code or command line.

javascript - Collapsing table rows with multiple tbody elements -

i have table looks this: <table> <thead> <tr><th>customer</th><th>order</th><th>month</th></tr> </thead> <tbody> <tr><td>customer 1</td><td>#1</td><td>january</td></tr> <tr><td>customer 1</td><td>#2</td><td>april</td></tr> <tr><td>customer 1</td><td>#3</td><td>march</td></tr> </tbody> <tbody> <tr><td>customer 2</td><td>#1</td><td>january</td></tr> <tr><td>customer 2</td><td>#2</td><td>april</td></tr> <tr><td>customer 2</td><td>#3</td><td>march</td></tr> </tbody> <tbody> <tr><td>customer 3</td>&l

Sql .Print maker producing all the products -

i have table called "product".there 3 columns in table.maker,model , type. model primary used link other tables.the content in table this model maker type 1 laptop 2 pc 3 b laptop 4 c laptop 5 b printer 6 d printer 7 b pc 8 d printer 9 c pc 10 printer i want makers make 3 products.how obtain result?please me. how about: select distinct(maker) product maker in (select maker product type='laptop') , maker in (select maker product type='pc') , maker in (select maker product type='printer');

javascript - Execute two onsubmit functions; second function executes only if first function is true -

i have email form validation script. if first function returns true (no errors in email field), second function execute, url redirect. can combine these 2 functions, need put in the form like, onsubmit="return checkform();" call second function within first: function checkform() { // validation logic here if (valid) doredirect(); }

highcharts - Highstock lineWidth -

i want set chart linewidth has strange behavior. on mouse on turns linewidth:2(default) , when mouse outs turns linewidth setting. plotoptions:{ series:{ linewidth: 5 } }, what's problem? demo: http://jsfiddle.net/bahar_agi/hepx3/2/ thanks yes there is. said, can configure state described in api. see http://jsfiddle.net/hepx3/4/ plotoptions: { series: { linewidth: 5, states: { hover: { enabled: true, linewidth: 5 } } } }

How to export to Collada form in Blender for cocos3d -

i using blender 2.66a create 3dobject cocos3d. in brenwill tutorial have used blender 2.4.9 export collada file. cannot find options have mentioned in tutorial(like triangle,only export selection), when export collada file. where can find options in blender 2.66 ? or there difference in options higher version? as pod file collada-pod file creation important in cocos3d. in blender 2.4.9 have specify options create collada file. in blender 2.66 can create collada file using default options. convert pod file using powervr sdk.

sql - Reducing Queries while looking for associated records -

i have code, performing awful lot of sql queries, last method ('most related'). following setup this: class user < activerecord::base authenticates_with_sorcery! has_and_belongs_to_many :items def purchased_categories ids = [] self.items.each |item| ids << item.categories.pluck(:id) end ids.flatten.uniq end def recommended_items item.includes(:categories).where("categories.id in (?)", self.purchased_categories).references(:categories).uniq - self.items end def most_related cs = self.purchased_categories self.recommended_items.sort { |a, b| (a.categories.pluck(:id) & cs).length <=> (b.categories.pluck(:id) & cs).length } end end my item model looks following: class item < activerecord::base has_and_belongs_to_many :categories has_and_belongs_to_many :users end i have ton of queries in most_related method, , wondering, if can reduce somehow? edit: the main issue i&

mongodb - MONGO DB Alias name usage in find query not working -

i using below command find records in contacts collection's db.contacts.find({"field1":"1"}) the problem want use alias name field1 sl.no i tried way , not working... db.contacts.find({"field :n, as: :sl.no" : "1"} can anyne me in issue? btw using mongo 1.6.5 some drivers mongoose support feature, there no such feature in mongodb or mongo shell.

c# - Openid show images for providers -

while trying out tutorial http://mvcrocksonasp.net/oauthwithmvc4 followed instructions add facebook.png so dictionary<string, object> facebookextradata = new dictionary<string, object>(); facebookextradata.add("icon", "../images/facebook.png"); but didn't work able images on browser ? i didn't gone link in detail. check out following 2 links may useful looking for. for how implement oauth in mvc. check related post in bottom of link. http://blogs.msdn.com/b/webdev/archive/2012/08/15/oauth-openid-support-for-webforms-mvc-and-webpages.aspx to customize provider images. http://blogs.msdn.com/b/webdev/archive/2012/08/24/customizing-the-login-ui-when-using-oauth-openid.aspx

asp.net - Hiding one td and collapse other td in row for not showing space between the tds (auto merge) -

Image
code snippet: <td><center> <asp:imagebutton id=imgmanagord runat="server" imageurl="images/manageorders.jpg"></asp:imagebutton></center></td> <td><center> <asp:imagebutton id=imgstockorder runat="server" imageurl="images/stockorder.jpg"> </asp:imagebutton></center></td> <td><center> <asp:imagebutton id=imgadmin runat="server" imageurl="images/admin.jpg"> </asp:imagebutton></center></td> <td><center> <asp:imagebutton id=imgcontact runat="server" imageurl="images/contact.jpg"> </asp:imagebutton></center></td> i hiding specific td codebehind depending upon permission , have not specify width of these tds respectivly. so result there odd spaces between final tds. please find images : all tds: few td hidden: please tell how can align resulted tds

python - Clustering of 1D signal -

Image
i've got several 1d signals, showing 2 or more bands. example shown below. i need extract datapoints belonging single band. my first simple approach taking moving average of data, , indices data larger average. def seperate(x): average = scipy.ndimage.gaussian_filter(x, 10) # gives me boolean array indices of upper band. idx = x > average # return indices of upper , lower band return idx, ~idx plotting these , average curve this, red denotes upper , blue lower band. this works quite example, fails when more 2 bands present and/or bands not separated. i'm looking more robust , general solution. looking scikit-learn , wondering if 1 of clustering algorithms can used achieve this. have time series similarity measures . indeed, have seen binary thresholding tried there called "threshold crossing", , many more. in general, there no "one size fits all" time series similarity. different types of signals require

loops - Looping insert statement in SQL without using cursor -

i have problem looping in sql. want loop startdate until reaches enddate. they said me not use cursor, found example this: with mycte ( select cast('2007-01-01' datetime) datevalue union select datevalue + 1 mycte datevalue + 1 < '2030-12-31' ) select * mcte this works, changed variables situation: with view_solidnet_training ( select startingdate datevalue union insert obj_availability values(34, datevalue + 1, 'am', 2, 'test') select datevalue + 1 view_solidnet_training datevalue + 1 < endingdate ) select * view_solidnet_training but following error: msg 156, level 15, state 1, line 5 incorrect syntax near keyword 'insert'. msg 128, level 15, state 1, line 5 name "datevalue" not permitted in context. valid expressions constants, constant expressions, , (in contexts) variables. column names not permitted. msg 102, level 15, state 1, line 9 incorrect syntax near ') please try: with view_solidnet

c++ - How to convert pointer value obtained via reference operator to string? -

i beginner in c++. working on project required trace memory address. unfortunately, tracing function has following prototype declaration: void trc(uint8_t, uint8_t, uint8_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, const char*) now options available me are: convert memory address (pointer value) uint64_t type. i've read somewhere not recommended, pointer value returned reference operator platform dependent , conversion of pointer integer may return wrong value. convert memory address string , pass via last parameter. in python easy had str() function. have similar in c++ too? please let me know if inferring wrong in approach/understanding here. you use streams convert if not need fast code. #include <sstream> #include <iomanip> ... std::ostringstream os; os << std::hex << static_cast<void*>(my_pointer); trc(..., os.str().c_str());

matlab - Error: At compilation, "varargout" was determined to be a variable -

the full error message reads: at compilation, "varargout" determined variable , variable uninitialized. "varargout" function name , previous versions of matlab have called function. however, matlab 7 forbids use of same name in same context both function , variable. error in c:\programs\comsol43a\mli\mphglobal.p>mphglobal (line 177) the function call looks this: [param_values{1:length(params)}] = mphglobal(m, params); note mphglobal(..) closed-source. this works sometimes, gives error message @ other times. the problem params empty. error message appears.

c# - Best practices for base controller -

in old days when asp.net webforms developer used create basepage , in there used put common methods , properties used in application, every page inherit page. i wonder how mvc 4, there guideline, or create base controller class , inherit controllers class? what put in base controller class? thanks i avoid using base controller (inheritance) problem, because kinda smells. sure controllers need common methods , properties? @ least of functionality can implemented extension methods on controller type. also other functionality might more suitable service injected controller. common methods require (request)state prefer service approach. it's possible @ least functionality belong action filter (checking rights, setting user profile, handling exceptions ;) etc ). as thumb rule, try avoid using inheritance controllers. controllers should simple can , utility behavior i'd need, try encapsulate in 1 of ways presented above.

gsm - How to read an SMS from Arduino and get LED to switch on or off -

#include <softwareserial.h> char inchar; //will hold incoming character serial port. softwareserial cell(2,3); //create 'fake' serial port. pin 2 rx pin, pin 3 tx pin. int led1 = a2; void setup() { // prepare digital output pins pinmode(led1, output); digitalwrite(led1, high); //initialize gsm module serial port communication. cell.begin(19200); delay(30000); // give time gsm module register on network, etc. cell.println("at+cmgf=1"); // set sms mode text delay(200); cell.println("at+cnmi=3,3,0,0"); // set module send sms data serial out upon receipt delay(200); } void loop() { //if character comes in cellular module... if(cell.available() >0) { delay(10); inchar=cell.read(); if (inchar=='a') { delay(10); inchar=cell.read(); if (inchar=='0') { digita

CodeIgniter getting Value from Database to display -

error ---- parse error: syntax error, unexpected t_return in c:\wamp\www\jobsite\application\models\model_users.php on line 71 public function profile_data() { $this->load->database(); $query = $this->db->get('tbl_studentreg') //tbl_studentreg table name return $query->result(); // line 71 } may know how fix it? in advance. you're missing semicolon here: $query = $this->db->get('tbl_studentreg'); //semicolon added

java - TableCellRenderer - setRowHeight gone crazy -

i developing java swing application. cell has ability wrap text , automatically increase height if needed wrap text. i need setrowheight method me set row height. work fine before write setrowheight method application. after setrowheight method written, application overload , becomes heavy. global variable processing used count how many times texttablerenderer called. found out processing gives me value of thousand , more when application running. why happen? have update runnable code on it. copy , paste , compile it. found out processing keep increasing unstoppable. import java.awt.color; import java.awt.component; import javax.swing.*; import javax.swing.border.matteborder; import javax.swing.table.tablecellrenderer; import javax.swing.table.tablecolumn; import javax.swing.text.view; public class sscce { public string[][] data = {{"a","b","c"},{"d","e","f"}}; public string[] column = {"1&quo

Get Table and Index storage size in sql server -

i want table data , index space every table in database: table name data space index space ------------------------------------------------------- how can achieve result? this query here list total size table takes - clustered index, heap , nonclustered indices: select s.name schemaname, t.name tablename, p.rows rowcounts, sum(a.total_pages) * 8 totalspacekb, sum(a.used_pages) * 8 usedspacekb, (sum(a.total_pages) - sum(a.used_pages)) * 8 unusedspacekb sys.tables t inner join sys.schemas s on s.schema_id = t.schema_id inner join sys.indexes on t.object_id = i.object_id inner join sys.partitions p on i.object_id = p.object_id , i.index_id = p.index_id inner join sys.allocation_units on p.partition_id = a.container_id t.name not 'dt%' -- filter out system tables diagramming , t.is_ms_shipped = 0 , i.object_id > 255 group t.name, s.name, p.rows order s.nam

android - Open Source Static Source Code Analysis Tool (Security Oriented) For Java -

i looking open source static source code analysis tool can used security testing of android application. need make sure application pci compliant. example of non-open source tool fortify. can in providing list of recommended software? pmd , findbugs of best static code analysers have worked on. can try them. can add own rule , delete of existing ones them. https://www.sparkred.com/blog/open-source-java-static-code-analyzers/

How do we generate a random but unique number in Java -

i trying generate random unique number every http request hitting application. how make sure uniqueness of such number. java provide method or api this? you use java.util.random - http://java.about.com/od/javautil/a/randomnumbers.htm

xcode - Call a web service with MKNetworkoperation -

in our development team have implemented web service authenticate client. iphone application need send client's information web service , in order so, have written following function. -(void)authenticateclient:(nsstring*)thecontractnumber clientcode:(nsstring*)theclientcode cellphone:(nsstring*)thecellphone appleid:(nsstring*)theappleid { nslog(@"begin send information web service",nil); nsstring *uid = [uidevice currentdevice].uniqueidentifier; nsdictionary *formparams = [nsdictionary dictionarywithobjectsandkeys: theclientcode, @"clientcode", thecontractnumber, @"contractcode", theappleid, @"appleid", @" ", @"androidid", @" ", @"windowsid", uid, @"appledeviceid",

I got ActivityNotFoundException error when i was trying to startup a new activity in android -

i trying start activity setup email account main activity. not working , driving me nuts. have is: button.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { edittext username = (edittext) findviewbyid(r.id.edittext1); edittext password = (edittext) findviewbyid(r.id.edittext2); componentname cname = new componentname("com.android.email", "com.android.email.activity.setup.accountsetupbasics"); intent intent = new intent("android.intent.action.main"); intent.putextra("com.android.email.accountsetupbasics.username", username.gettext().tostring()); intent.putextra("com.android.email.accountsetupbasics.password", password.gettext().tostring()); intent.putextra("com.android.email.extra.eas_flow", true); intent.setcomponent(cname); intent.setflags(intent.flag_act

gcc - How to prefix CMake Compiler? -

i want prefix compiler utility script, instead of example g++-4.7 main.cpp , kinst-ompp g++-4.7 main.cpp invoked. i tried doing in cmakelists.txt, i'm getting "not found" error: set(cmake_cxx_compiler "${ompp_cxx} ${cmake_cxx_compiler}") set(cmake_c_compiler "${ompp_cc} ${cmake_c_compiler}") how configure using cmake? i got work setting compiler prefix , passing real compiler name first argument. ugly, know. set(cmake_cxx_compiler "${ompp_cxx}") set(cmake_cxx_flags_release "${cmake_cxx_compiler} ${commoncxxflags} ${commonreleaseflags}")

c# 4.0 - How to catch HttpRequestValidationException -

how can redirect user custom error page, when httprequestvalidationexception occurred. tried catch in basecontroller : protected override void onexception(exceptioncontext exceptioncontext) { if (exceptioncontext.exception httprequestvalidationexception) { this.view("customerror").executeresult(this.controllercontext); } } but still exception : potentially dangerous request.form value detected client this exception occurs earlier in execution of request , cannot handled onexception method in base controller. write global exception handler showed in this post .

javascript - why does is say - underscore is undefined -

why - '_' undefined, below basic simple example , fiddle. thank you http://jsfiddle.net/fuefq/ -------------index.html--------------------------- <html> <head> <title></title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="underscore.js"></script> <script type="text/javascript" src="myjs.js"></script> <head> <html> <body> <script> <button type="button" onclick = "loadthis();">click me!</button> </script> </body> </html> -------------myjs.js--------------------------- var loadthis = function(){ vas x = _.uniq([1, 2, 1, 3, 1, 4]); alert(x); }; the problem fiddle loadthis contained within function jsfiddle provides (wrapping code), ,

FlipView control is not available in Windows Phone 8 SDK -

flipview control not available in windows phone 8 sdk, alternate approach implementing similar functionality? there few options here. if want display fixed number of "pages", can use panorama app. if have lot of pages display, you'll want use pivot control. if absolutely have re-implement flipview, can putting "left" , "right" buttons in application bar. you'll need build own content area custom control. if you're going "cool" gesture-based navigation, you'll want toolkit .

audio - SHOUTcast stream in Windows Phone 8 -

does have idea how can play shoutcast streams in audio player of windows phone 8? i've tried these links: stream/ stream/; stream/; stream.mp3 any welcome! this project windows phone 7 , hasn't been update in while; however, worked fine couple of windows phone 8 applications built. http://shoutcastmss.codeplex.com

performance - From explicit threading to TBB -

assuming have parallel algorithm uses explicit threading 1 or 2 locks synchronization , optimized take advantage of cache lines (including shared l3 cache between multiple cores), ways of incorporating tbb program? algorithm in question not break down nicely tasks threads. without further information (code sample, or kind of generic presentation of algorithm, such flowchart) best way make such transition refactoring algorithm, isolating repeatable actions , trying combine them in tasks (a range of 1 or more activities have common purpose)... unfortunately there's no magical formula make transition because these techniques fundamentally 2 answers solve same problem, therefore share common ground, tackle problem 2 different angles...

web services - how to get product price detail using zbarsdk barcode scanner -

i using zbarsdk product detail scanning product bar code, getting bar code no bar code,but need product detail product name,price etc. please me issue. thanks the ultimate result after scanning barcode number.you have search barcode product details. try following api search product details http://www.searchupc.com/handlers/upcsearch.ashx?request_type=3&access_token= {my_token}&upc={scanned_code}

java - An array in main reffering to an array outside main -

i'm trying create array in main making identical array created in method outside main. cant think of way this... here's code: public class grid { public void creategrid() { int n = stdin.readint(); int thisarray[][] = new int[n][n]; (int x = 0; x < n; x++) { (int y = 0; y < n; y++) { int n = (int) (math.random() * 6 + 1); thisarray[x][y] = n; } } } public static void main(string []args){ grid g = new grid(); int [][] newarray = //thisarray } } are looking answer? have changed return type of method int[][] , inside main method can call creategrid method int[][] public class grid { public int[][] creategrid() { int n = stdin.readint(); int thisarray[][] = new int[n][n]; (int x = 0; x < n; x++) { (int y = 0; y < n; y++) { int n = (int) (math.r

redirect - Struggling with friendly urls in wordpress -

i edited permalink settings changing custom structure to: /%postname%/ now, when click on page link it'll take me domain.com/postname, 404 error. doing digging shows need setup 301 redirects, i'm confused how this. i've edited .htaccess file - looks like: # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase /mgassoc/ rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /mgassoc/index.php [l] </ifmodule> # end wordpress can me i'm doing wrong? try doing , see if helps. add following httpd.conf , re-start apache. <directory "/path/to/your/app"> options followsymlinks allowoverride order allow,deny allow </directory>

Android ask password on disabling app from device admin? -

is there way ask password on deactivating device admin android device or else hide or protect app un-checking in device administrator. what asking not possible. problem if applications protect being uninstalled. think malware application gets installed , can't rid of it.

ruby on rails - submit function of jquery submit form and not validate the livevalidation -

i have used livevalidation.js validating form field. can't validate radio button live validation have written following code on form submit jquery event. the problem that, when select these radio buttons , not other fields of form, submit form , model validation applied, should applied live-validation. what problem in code or submit function? $('#new_league_info').submit(function(){ if($('#league_info_state').val() != '') { if($('.re_conditioner_radio').is(':checked')){ $('#reconditioner_msg').css("hidden"); var spans = $('.reconditioner_err'); spans.text(''); } else{ $('#reconditioner_msg').replacewith('<span class=" reconditioner_err lv_invalid">please select reconditioner</span>'); return

vba - Formating all tables in file with style -

i'm working kind of documentation @ moment, consists of lots , lots of tables. , may have guessed now, need format them style. so, there's vba macro exclusively made purpose - creates required style , applies tables in file. seems problem when i'm working large document. so, let's see working code, ommiting part, style created: dim otable table each otable in activedocument.tables otable.select selection.tables(1).applystyledirectformatting ("foostyle") selection.tables(1).autofitbehavior (wdautofitfixed) selection.tables(1).applystylerowbands = true selection.tables(1).borders .insidelinestyle = wdlinestylesingle .insidelinewidth = wdlinewidth025pt .outsidelinestyle = wdlinestylesingle .outsidelinewidth = wdlinewidth025pt end 'make list last row of table selection.tables(1).cell(row:=8, column:=1).range.select selection.range.listformat.applylisttemplate listtemplate:=listgalleries(wdoutlinenumbergallery).listtemplates(2) next so

Programming Keyboard what to choose -

i can't make mind regarding choice of new keyboard. in daily life programmer know requires extensive use of brackets etc... have tried several keyboards in low , high price ranges. at moment using low profile logitech keyboard because got idea low profile keys causing less finger tip pain when type longer periods of time. feel low profile keyboard seem making quit lot of typo's compered high/normal height. therefore wondering experience / tips regarding following. low profile vs mechanical any knowledge of keyboards suited programming (special character key placement) any other useful info programming keyboards might find useful thank reading! i recommend happy hacking professional 2 keyboard, little expensive ($270) worth it. keyboard made computer scientist , made used in vi text editor (you can google , check out layout). started using keyboard after coming mechanical keyboard, , have best keyboard have used programming. absolutely love keyboard a

objective c - What did the compiler and run-time system really do in my generated assembly? -

i understand how generated assembly , runtime work together, , came across question while stepping through generated assembly code. source example here 3 lines of objective-c, running in xcode 4.5: // line 1: nsobject *obj1 = [[nsobject alloc] init]; // line 2: [obj1 release]; // line 3: nsobject *obj2; comparing generated assembly stepping through generated assembly, made few observations. before line 1, address of obj1 shown: obj1 (nsobject*) 0x00003604 after line 1, changes: obj1 nsobject * 0x08122110 observations 1) address of obj1 changed. when source code compiled, compiler allocates temporarily memory obj1 . then, (after line 1) compiler apparently re-allocates, object's address changes. 2) after line 2, address of obj2 still same ( 0x08122110 )! when call [obj1 release] , telling compiler: "i don't need anymore. please take away." system doing release @ point in future , can not seem control directly. 3) debugger can&#