Posts

Showing posts from February, 2013

How to raise a custom Exception in Rails 3+ with normal control flow? -

given following controller method: def create @client = user.find(params[:client][:id]) respond_to |format| if @client.present? && @client.add_manager(current_user) format.html { redirect_to clients_path, notice: "successfully added manager" } else format.html { redirect_to clients_path, error: "could not find client" } end end end how fail in else block instead of throwing runtimeerror turns "something went wrong" on production? def add_manager(user) raise "already manager" if self.manager_users.include?(user) self.manager_users << user if user.trainer? end is code... you can try this: in controller class yourappname::alreadymanagererror < standarderror end now change "already manager" name of custom error def add_manager(user) raise yourappname::alreadymanagererror if self.manager_users.include?(user) self.manager_users ...

html - Drop Down IE 8 and Below Not Working -

hi finished redesigning site include drop down menus, learned today ie 8 , below don't display them near correctly. displays fine knowledge on every other browser. don't know i've gone wrong, i've been debugging , haven't been able figure out. any appreciated! here jsfiddle html , css: http://jsfiddle.net/sctqy/ here link live site: http://www.hearditfrom.com (this in js fiddle) here html/php: <nav id="hb2_nav"> <ul> <li><a class="hb2_nav" href="category.php">categories <span class="arrow-down"></span></a> <ul class="drop-shadow"> <span class="category_column"> <li><a href="category.php?category=1">u.s.</a></li> <li><a href="category.php?category=2">world</a></li> <li><a href="category.php?category=3">busines...

c - 2 FIFOs 1 Task - Synchronize them -

i have following problem: i have launch process various terminals can start running program after number of processes has started. in other words, have block somehow processes until right number of processes. i'm trying using fifos using first process called "server". problem resumed ticket entrance problem: "server" process writing in fifo number of next process. next process take "ticket" , send "server" number++. coded this, basically: server: count = 0; fd_w = open ("client", o_wronly); fd_r = open ("server", o_rdonly); { write (fd_w, &count, sizeof(int)); //write on client's reading fifo read (fd_r, &count, sizeof(int)); //read clients wrote printf ("msg read: %d\n", count); } while (count != 4); printf ("starting...\n"); client: fd_r = open ("client", o_rdonly); fd_w = open ("server", o_wronly); read (fd_r, &count, sizeof(int)); //...

android - TabWidget will not display, even though it displays in ADT editor -

Image
my tabwidget not display, though shows in eclipse graphical editor. can't find reason why. why isn't tab bar showing? eclipse emulator xml source of activity: http://pastebin.com/au9xfxpa extract activity: <tabwidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" > </tabwidget> results android lint: $ lint.bat res/layout/activity_calculator.xml scanning catalyst: . no issues found. it's hard tell without actual code of how activity implemented, seems need call setcontent() on tabhost : tabhost tabs = (tabhost)findviewbyid(r.id.tabhost); tabs.setup(); // calculator tabhost.tabspec calculatortab = tabs.newtabspec("calculator"); calculatortab.setcontent(r.id.calculator); calculatortab.setindicator("calculator"); tabs.addtab(calculatortab); // ...

php - Compilation failed: unmatched parentheses at offset -

i writing regular expression, when check following regex online, works correctly. however, return error in php. why that? preg_match_all('/^[([a-z]+\[[a-z| |,]+\])\,?]+$/', $methods, $result); return severity: warning message: preg_match_all() [function.preg-match-all]: compilation failed: unmatched parentheses @ offset 23 i tried 1 too: preg_match_all('/^[([a-z]+\\[[a-z| |,]+\\])\\,?]+$/', $methods, $result); if change outer character class ( [] ) character group (parentheses) compile, im not sure kind of string trying match: /^(([a-z]+\[[a-z| |,]+\])\,?)+$/ like in example i think caused because cant put nested character class because lose meaning regex ends in 3 parts this: [([a-z]+ \[[a-z| |,]+ \])\,?]+ ending in unmatched enter parentheses

.net - Show icons corresponding to the file type in asp.net -

Image
i need show icons corresponding file type. example have "sample.doc" in string, show in anchor tag link make downloadable. link have file name shown below <a title="sample" target="_blank" href="\files\sample.doc">sample</a> what need want link shown below there many filetypes require show on web page. how can achieve this. starting point me continue it. i (pseudo-code) foreach(var file in files){ var extension = path.getextension(file) ... <a title="sample" target="_blank" href="\files\sample.doc"> <img src="/images/@(extension).png" /> sample </a> }

browser - Vaadin request processing per http session -

am using vaadin 6.8. though below link describes how vaadin supports multiple browser tab, https://vaadin.com/web/joonas/wiki/-/wiki/main/supporting%20multible%20tabs tabs of same browser using same http session , hence same application instance. however, tabs use different window objects there giving illusion of multi tab support. but, vaadin locks application instance while processing httprequests (specially updateuidl calls). http requests given session processes serially. until tab1 request processed completely, tab2 request not processed. so, busy loading icon shown on both tabs. abstractcommunicationmanager.dohandleuidlrequest() locks application object. anyone has workaround issue? or is there anyway force vaadin use new http session each tab or pop up?

How to access the tokenized value in Java -

i have tokenized string, want access 1st,2nd,3rd value it. can this? thanks in advance! here code string cssvalue = webdriver.findelement(by.id(elementid)).getcssvalue("color"); string s = cssvalue; stringtokenizer st = new stringtokenizer(s, ",() "); while (st.hasmoretokens()) { log.info("token: "+st.nexttoken()); } this might help: string cssvalue = webdriver.findelement(by.id(elementid)).getcssvalue("color"); string [] s = cssvalue.split("rgb"); stringtokenizer st = new stringtokenizer(s[1], ",() "); list<integer> values = new arraylist<integer>(); int index=0; while (st.hasmoretokens()) { values.add(integer.parseint(st.nexttoken())); log.info("token: "+values.get(index)); index++; } integer [] = values.toarray(new integer[3]);

hadoop - About online distributed environment -

i learning mapreduce , hadoop now. know can tests , run samples on singe node. want practice on real distributed environment. want ask : there website can offer distributed environment me experiments? somebody told me can use amazon web service build distributed environment. real? have such experience? and want know how guys learn hadoop before use in work? thank you! there few options: if want learn map/reduce paradigm, recommend take @ jsmapreduce . embedded directly in browser, have nothing install, , can create real map/reduce programs. if want learn hadoop specifically, amazon has thing called elastic map reduce hadoop running on aws, enables write hadoop job, decide how many machines want in cluster, type of machines want, , run it, , emr everything, bootstrap machines you, run job , store results on s3. recommend looking @ this tutorial idea how setup job on emr. remember, emr not free , you'll have pay computing resources. alternatively if you...

html agility pack - c# htmlagilitypack parse first link from div with class? -

i trying parse first link in html code below /search?id=3 <div class="brs_col"> <p> <a href="/search?id=3"> <b> vastu shastra </b> </a> </p> <p> <a href="/search?id=1"> <b> bygga </b> bastu </a> </p> </div> i've tried select following xpath, cant seem of them work: //div[@class='brs_col']//p//a[@href] //div[@class='brs_col']//p[0]//a[@href] //div[@class='brs_col']//p//a[0][@href] any ideas? try this: var doc = new htmldocument(); doc.loadhtml(@"<div class=""brs_col""> <p><a href=""/search?id=3""><b>vastu shastra</b></a></p> <p><a href=""/search?id=1""><b>bygga</b>bastu</a></p> ...

network programming - Why are there ioctl calls in socket.c? -

trying understand why there ioctl calls in socket.c ? can see modified kernel using, has ioctl calls load in required modules when calls made. i wondering why these calls ended in socket.c ? isn't socket kind of not-a-device , ioctls used device. talking 2.6.32.0 heavily modified kernel here. ioctl suffers historic name. while developed perform i/o controls on devices, has generic enough construct may used arbitrary service requests kernel in context of file descriptor. file descriptor opaque value (just int) provided kernel can associated anything. now if treat file descriptor , think of things files, *nix constructs do, open/read/write/close isn't enough. if want label file (rename)? if want wait file become available (ioctl)? if want terminate if file closes (termios)? "meta" operations don't make sense in core read/write context lumped under ioctls; fctls; etc. unless used deserve own system call (e.g. flock(2) functionality in bsd4.2) ...

php - New project, graph database?(Neo4j) -

i've web project (in php) wanna work on , i'm going need alot of x (friend of friend) y kind of questions. so crossing neo4j i'm not sure if it's therese right approach. i understand real world graph i'm going have several regular tables users, articles, comments, messages , on. , lot of regular questions give me info user (old relationship type of info ) can done? servers, time , money no problem long turn out cool this can done, yes. take time figure out how graph based database work , how can retrieve data. first, have vertices instead of tables. can give vertices properties , connect them each other called edges. on technical side, need use rest-api of neo4j since have no natural support php (as far recall). there's cool tool called 'curl' serves purpose work rest api. have deal alot json formatted data way;) but again, it's whole different approach regular relational one. need read tutorials , stuff before can going. ...

Asterisk Play a file while calling for curl -

in dialplan need call php exten => 6666,n,set(foo=${curl(http://reports.cr.mrgroup.in/ivr/sp.php?tid=${tid})}) gives reponse after 1 min or 2min , want play music file in these times please give me idea how achieve what you're going want use startmusiconhold() -- use when i've got other processing need (in 1 case, while there's long tts conversion) you can find more running asterisk*cli> core show application startmusiconhold an example looks this: exten => test,1,answer() same => n,startmusiconhold() same => n,wait(20) ; processing here. same => n,stopmusiconhold() same => n,hangup() also music on hold configuration live @ /etc/asterisk/musiconhold.conf -- if install sample configuration, there documentation inline.

java - How to test void method in JUnit -

this question has answer here: how test void method junit testing tools? 6 answers how test void method using junit. void add(int a, int b) { int c= + b; } how test above method using junit in java. if method has side effects, can check them in junit test. in example, method has no side effects, there nothing test . if still want test it, can use reflection so, don't think practice. you can check junit faq related section: how test method doesn't return anything? often if method doesn't return value, have side effect. actually, if doesn't return value , doesn't have side effect, isn't doing anything. there may way verify side effect occurred expected. example, consider add() method in collection classes. there ways of verifying side effect happened (i.e. object added). can check size , assert expected: ...

php - How to retrieve query stored in session in codeigniter? -

while using codeigniter have saved current query in session can show pagination in detail page means prev/next button detail screen.but when use %10% in query shows in home page stored in session when go detail page not in session.any guess not storing session in database documented in user guide my query simple select contac.cm_id contact left join employer on (contact.c_id = employer.ei_contact_id) , (employer.ei_primary_employer = "y") ( contact.cm_staff_name '%s%' , contact.cm_staff_name not 'null' ) order contact.cm_id asc so when there 03 in contact.cm_staff_name '%03%' not passing query 1 page through session . please suggest if better solution instead of using session. guess there no point in storing a program anywhere. program have written in constant form , fed dynamical variables . using sessions pagination wrong idea - @ google example - use query string pass variables next page. let user bookm...

Changing an SVG marker's color - CSS? -

i've seen number of examples of using css affect style of svg elements, none far question markers. , honestly, i'm still working through syntax of both(svg & css). i want define marker, , able use in various places different colors. for example: <?xml version="1.0" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewbox="0 0 180 320"> <defs> <marker class="asteriskmarkerclass" id="asteriskmarker" viewbox="-1 -1 2 2" stroke-width="0.1"> <line x1="0" y1="-1" x2="0" y2="1" /> <line x1="-1" y1="0" x2="1" y2="0" /> <line x1="-0.7071" y1="-0.7071" x2="0.7071" y2="0.7071" /> <line x1="-0.7071...

c# - ASP Table to Excel -

when viewing aspx in website, got table few text in cells, e.g.: tab.rows[1].cells[1].innerhtml = "booked :" (in lot of rows , cells different text in each cell) now want click button, , data in table downloaded excel file. table id : tab protected void page_load(object sender, eventargs e) { if (!ispostback) { //table tbl = new table(); tablerow tr = new tablerow(); tablecell tcel = new tablecell(); tcel.text = "id"; tr.cells.add(tcel); tablecell tcel1 = new tablecell(); tcel1.text = "id1"; tr.cells.add(tcel1); tab.rows.add(tr); } } protected void button1_click(object sender, eventargs e) { string filename = "exportexcel.xls"; system.io.stringwriter tw = new system.io.stringwriter(); system.web.ui.htmltextwriter hw = new system.web.ui.htmltextwriter(tw); //datagrid dggrid = new datagrid(); //dggrid.datasource = tbl; //dggr...

c# - How do I have a sample image available in WP7 emulator when my project runs? -

i have windows phone project compiled 7.1 sdk. application processes image files , i'd have sample image file project when project runs in emulator , user asks application open image photo gallery (using photochoosertask ) sample image somehow magically appears in gallery , user can select it. i've seen this question , i'm not sure it's scenario. question op wants test custom image. want custom image included project , automagically appear in emulator when gets project github , opens in visual studio , runs it. is possible have sample image included wp 7.1 emulator when project being run? i wrote blog post explains how have sample images in emulator: http://www.softwareisinthedetails.com/2012/11/add-test-images-on-windows-phone-emulator.html

java - HashMap<String, Integer> Search for part of an key? -

this question has answer here: partial search in hashmap 4 answers i using hashmap<string, integer> filled keys of type string all, let's say, 5 chars long. how can search specific key of 4 chars or less, part , @ beginning of other keys , hits collection of <key, value> ? iterate option unless create custom data structure: for (entry<string, integer> e : map.entryset()) { if (e.getkey().startswith("xxxx")) { //add result list } } if need more time efficient you'd need implementation of map tracking these partial keys.

zend framework2 - access controller action variables to zf2 layout -

i have created 2 layouts: 1 login page , rest of site. after login want pass variables login controller zf2 layout, not able access. how can access variables in layout created in controller action? some ways in controller: using view model $viewmodel = new viewmodel(); $viewmodel->setvariable('myvar', $myvar); return $viewmodel; using layout() $this->layout()->myvar = $myvar; into view script <?php echo $this->myvar; ?>

iphone - Detect LED Flash for Alerts setting status in code -

how can detect "led flash alerts" (from settings) status in code? have tried: avcapturedevice *torched=[avcapturedevice defaultdevicewithmediatype:avmediatypevideo]; bool test = torched.torchmode; bool test1 = torched.flashmode; but seams not need. do this, bool test=no; bool test1=no; class capturedeviceclass = nsclassfromstring(@"avcapturedevice"); if (capturedeviceclass != nil) { avcapturedevice *device = [avcapturedevice defaultdevicewithmediatype:avmediatypevideo]; if ([device hastorch] && [device hasflash]){ if(device.flashmode==avcaptureflashmodeon) nslog(@"on"); else nslog(@"off"); } } hope helps you....

android - rawQuery arguments weird behaviour? -

i wrote rawquery gives me empty cursor: string query = "select * " + tbl_name + " ? = ?"; string[] args = new string[] {col_name, long.tostring(id)}; cursor c = db.rawquery(query, args); but if following query expected results: string query = "select * " + tbl_name + " " + col_name + " = " + long.tostring(id); cursor c = db.rawquery(query, null); i gathered can't use table name 1 of arguments of 'rawquery' method. i'm not sure why not (i presume surrounds argument ' ', it's guess). other came conclussion args should used in order include user inputs query, , in regards looks better use sqlitestatement . in summary: (and if possible why) shoul use args in rawquery (instead of concatenated in string). , why should use rawquery @ instead sqlitestatement (or query)? as far know col_name can't replaced "?". android takes "?" "arguments", not "selectio...

couchdb - extracting a json from a document -

i using couchdb employee management app. have created document in couchdb following employees json : {"employees" : [{"id":"123","name":"henry","address":"hsr"},{"id":"456","name":"erik","address":"kormangala"}]} and when type on terminal : curl -x http://127.0.0.1:5984/myapp/9351c38f9a64fd26e40b2ac4cf012efe where 9351c38f9a64fd26e40b2ac4cf012efe document id. : {"_id":"9351c38f9a64fd26e40b2ac4cf012efe","_rev":"7-77b5766b830a3c07c522e9ab17afae09","employees":[{"id":"123","name":"henry","address":"hsr"},{"id":"456","name":"erik","address":"kormangala"}]} what interested : [{"id":"123","name":"henry","address":"hsr"},...

ruby on rails - 'twitter/bootstrap/bootstrap.less' wasn't found -

Image
i trying play twitter bootstrap basics using rails 4.0.0.rc1 , ruby 1.9.3p392. then try access http://localhost:3000/products i'm having error: 'twitter/bootstrap/bootstrap.less' wasn't found. please see attached screenshot. code available @ https://github.com/tenzan/twitter-bootstrap.git you have require bootstrap less (bootstrap_and_overrides.css.less) in application.css /* *= require bootstrap_and_overrides */

html - IE10 - RTL reversed - how to fix? -

can't understand problem. reason - ie10 presents hebrew in reversed order. if use compatibility mode(ie developer tools, ie 10 compatibility mode) works fine... http://www.undergraduate.technion.ac.il/rishum/index.html tried sorts of rtl fixes(css, dir attribute, etc.) i'm no expert in rtl, considering works in compatibility mode, in short term try adding <meta http-equiv="x-ua-compatible" content="ie=5"> in long term (or if doesn't work) show consider rewriting pages current html standards. should @ least add charset declaration (to http header not html) since hebrew , not basic ascii. (this rtl problem). get rid of frames. frames obsolete , outdated technology. correct html syntax errors. use css styling. get rid of graphics links. (i'd love read page, graphics can't translated automatically). btw, use http://validator.w3.org/ check worst errors. since framed site, you'll need check each frame document se...

Three wordpress sites to share same data -

i have multiple domains like: www.site1.com, www.site2.com, www.site3.com i want them share same db tables except wp_options table. because each site act "separate" entity still have same pages, posts, products etc... how can achieve ? i don't why need kind of feature, seo of baaaad :) however several plugins let spread posts wordpress network installation. diamondmultisite allows publish posts in blogs in wordpress multisite install, guess works pages there threewp broadcast support more content , seems more active.

Issue in android programming json to listview -

i have been using following code in order create listview: public class androidjsonparsingactivity extends listactivity { // url make request private static string url = "http://api.androidhive.info/contacts/"; // json node names private static final string tag_contacts = "contacts"; private static final string tag_id = "id"; private static final string tag_name = "name"; private static final string tag_email = "email"; private static final string tag_address = "address"; private static final string tag_gender = "gender"; private static final string tag_phone = "phone"; private static final string tag_phone_mobile = "mobile"; private static final string tag_phone_home = "home"; private static final string tag_phone_office = "office"; this 1 above works, if change into: private static string url = "http://kondicioner.al/app/json.php"; // json node nam...

phpmyadmin - Access denied for user 'root'@'localhost' (using password: NO) while testing php website forms -

when test forms of php website @ local host below meassage... access denied user 'root'@'localhost' (using password: no) use phpmyadmin backend... plz suggest solution. that database related error. script trying access database root denied on system. check database connection user/password credentials.

ajax - MVC3 reloading part of page with data razor -

i have table data base , 3 buttons delete, create , update return partialviews. i want update part of page data after clicking submit button in corresponding dialog (delete, update, ...). what easiest way achive this? this i've got add, delete same. <div id="delete-dialog" title="delete product"></div> <script type="text/javascript" > $(".deletelink").button(); var deletelinkobj; // delete link $('.deletelink').click(function () { deletelinkobj = $(this); var name = $(this).parent().parent().find('td :first').html(); $('#delete-dialog').html('<p>do want delete ' + name + ' ?</p>'); //for future use $('#delete-dialog').dialog('open'); return false; // prevents default behaviour }); $('#delete-dialog').dialog({ dialogclass: "confirmbox", autoo...

c# - Using IQuery CreateQuery in NHibernate Performance is slow -

i'm facing performance issues using createquery, createsqlquery & createcriteria. when use these fetching data takes atleast 4-5 seconds. when run same query in query editor sql server management studio executes in less second. tried googling couldn't find solution. i'm bit confused why nhibernate taking time execute simple queries. below required code public ilist<masterforecastinputsourcematch> getmasterforecastinputsourcematchinfo(guid elementid) { var selectquery = _session.createquery("from masterforecastinputsourcematch elementinputinfo.id = :id") .setparameter("id", elementid); return selectquery.list<masterforecastinputsourcematch>(); } for createcriteria public virtual iqueryable<tpersistenttype> queryablelist() { return session.createcriteria(typeof(tpersistenttype)) .list<tpersistenttype>().asqueryable(); } thanks

jquery maskedinput. How to check availability of the mask -

can me checking availability of mask. use one: if ($.isfunction($("#id").mask)){ var val = $("#id").mask(); } else { var val = document.getelementbyid(id).value; } but condition true. don't matter written with: $(document).ready(function(){ $("#id").mask("8 (999) 999-9999"); } or not. if you're trying verify if .mask() function available, should try checking $.fn.mask . if you're trying verify whether element has mask, test if $("#element").data("rawmaskfn") defined.

joomla - JMail usage for cutsom component programming -

my code works when format html. <pre> public function partorder() { $input=jfactory::getapplication()->input; $mailer =jfactory::getmailer(); $config =jfactory::getconfig(); $mailer->setsender(array("email@email.com","name")); $mailer->addrecipient("somerecipient@somerecipent.com"); $body="some html message"; $mailer->ishtml(true); $mailer->encoding = 'base64'; $mailer->setbody($body); $send =$mailer->send(); $respond=""; if ( $send !== true ) { $respond= 'error sending email: ' . $send->message; } else { $respond= 'mail sent'; } echo $respond; } </pre> when use same function on controller json format "mail sent" message. mail doesn't reach recipient; i don't think there's wrong function. however, noticed gmail quite picky when comes emails come...

How to persist the changes, even an error is occured with in try catch in flyway? -

i using flyway , have procedure, migrate employees. in procedure using try/catch block , using begin/commit transaction within while loop of processing employee. if error occurring row, skip next employee. after processing employees, flyway rolling entire migration if there exception in @ least 1 row. there solution persist employees being migrated successfully. flyway rolls if sql exception thrown. double-check code make sure correct.

sql - sum by rows (include all columns) in Oracle -

i have structure of table ----------------------------------------------------------------- id-prod | monday | tuesday | wednesday | thursday | friday |.... ----------------------------------------------------------------- 012 213 879 516 213 435 013 953 837 361 862 014 123 583 879 519 573 015 963 016 798 id-prod primary key, i sum values each product example --------------------------------------------------------------------------------------- id-prod | monday | tuesday | wednesday | thursday | friday |....| total --------------------------------------------------------------------------------------- 012 213 879 516 213 435 213+879+516+213+435 013 953 837 361 862 ..... 014 123 583 879 519 573 ..... 015 ...

windows 7 batch script- if statement not working -

cd c:\users\user1\desktop if "%time:~0,1%" == " " ren 85.txt %time:~1,1%.txt else ren 85.txt %time:~o,1%.txt pause the script above not working, if put following line file: ren 85.txt %time:~1,1%.txt it working. why if...else statement above not working? o doesn't work, try 0 (zero): cd c:\users\user1\desktop if "%time:~0,1%"==" " (ren 85.txt %time:~1,1%.txt ) else ren 85.txt %time:~0,1%.txt pause

vb.net - Getting error IndexOutOfRangeException was unhandled -

i trying read text sobj.txt & write in mpadd.txt prefix text. sobj.txt contains vertical strip of words (1 in each line) & number of lines in file variable (determined user). here script using: dim commands() = { "stmotd -a {0}", "stmotd -b 15 {0}" } dim counter integer = 1 dim objlines = file.readalllines("c:\temp\sobj.txt") using sw new io.streamwriter("c:\temp\mpadd.txt", true) each line in objlines sw.writeline(string.format(commands(counter), line)) counter += 1 next end using but when executed returns error "indexoutofrangeexception unhandled" says index outside bounds of array. please help. arrays in .net zero-based. use dim counter integer = 0 and obviously, objlines may contain no more 2 lines. maybe meant emit commands each line? for each line in objlines each cmd in commands sw.writeline(string.format(cmd, line)) next next ...

jquery - Best way to hide a button with .visible-desktop class? -

i'm trying hide button using jquery ( using $.fn.hide() ) ,but jquery method not work, because elements want hide contains bootstrap .visible-desktop / .hidden-desktop class (using bootstrap's responsive class, really). happens due .visible-desktop using display attribute !important . want display button version mobile/tablet different desktop version but want use 2 buttons unique identity. simpler version of issue be: in html file: <button class="my-button my-button-for-tablet-mobile hidden-desktop"></button> <button class="my-button my-button-for-desktop visible-desktop"></button> in jquery file (desired, not work): //a line of type should hide 2 buttons. $(".my-button").hide(); i don't know better way implement this... edit: there jsfiddle question: http://jsfiddle.net/bdlnn/ one way use attr() override it. the following should work: $('.my-button').attr('style', ...

php - How to order the category that has most product -

i'm not clear in 1 of mysql. have 2 tables: tblcategory id, name tblproduct id, name, qty, price, category_id and when use sql select catogories order product count: select c.id,c.name,count(p.id) product_count tblcategory c inner join tblproduct p on c.id=p.category_id group c.id,c.name order product_count; the result category has no product not appear in result! how can of them? you need use left outer join : select c.id,c.name,count(p.id) product_count tblcategory c left outer join tblproduct p on c.id=p.category_id group c.id,c.name order product_count; the inner join keeps records match in both tables. want product categories, when there no matches. left outer join keeps records in first table ( tblcategory ) along matching records in second table ( tblproduct ). if there no products on category, you'll value of 0 instead of missing row.

Crash when trying to play AVC High Profile video on Android 4.2 (Nexus 7) -

i have ts avc high profile video , not play @ on on android 4.2. short stream sample available at: vid-avc-hp_aud-mp3.ts the stream "vid-avc-hp_aud-mp3.ts" played using mediaplayer on such devices: 1. asus transformer tf201 (with android 4.1.1) 2. acer iconia tab a510 (with android 4.1.2) when try play stream on nexus 7 (with android 4.2.2) using mediaplayer not play @ all. there here crash in logcat: 05-08 14:25:31.275: a/avc_utils(15626): frameworks/av/media/libstagefright/avc_utils.cpp:63 check_eq( br.getbits(1),0u) failed: 1 vs. 0 05-08 14:25:31.275: a/libc(15626): fatal signal 11 (sigsegv) @ 0xdeadbaad (code=1), thread 15666 (timedeventqueue) the full logcat nexus 7 available at: logcat_crash the crash media/libstagefright/avc_utils.cpp @ following function of android sources: // determine video dimensions sequence parameterset. void findavcdimensions( const sp<abuffer> &seqparamset, int32_t *width, int32_t *height) { abitread...

web services - WebService in asp.net using visual studio 2008 -

as know, if build web service using visual studio, visual studio automatically generate 2 files, first 1 .asmx , second 1 .vb code behind. in code behind(.vb) got : imports system.web imports system.web.services imports system.web.services.protocols <webservice(namespace:="http://tempuri.org/")> _ <webservicebinding(conformsto:=wsiprofiles.basicprofile1_1)> _ <global.microsoft.visualbasic.compilerservices.designergenerated()> _ public class webservice inherits system.web.services.webservice <webmethod()> _ public function helloworld() string return "hello world" end function end class and in .asmx file, got : <%@ webservice language="vb" codebehind="~/app_code/webservice.vb" class="webservice" %> the question is what main purpose of .asmx file? show 1 row code, useful? can make method .asmx file , not in code_behind? , how consume .aspx file? yes possible. refer below l...

crash - C# application crashes in Windows CE -

i have console c# application, working on windows ce environment. application start other main application.this part working. have detect when/if main application crash , in case restart main application. there way detect application crash program? thanks, slava. i have found solution, pretty match needs.i put application \windows\startup folder , it. after restart applications in startup folder coming up,including myapp.

webdeploy - Strange Web Deploy access issue -

i'm getting odd problem connecting server. the server's logs read: 2013-05-21 11:18:24 [ip address] head /msdeploy.axd site=[site name] 8172 administrator [my ip] - 401 1 1326 214 i using administrator account can't understand why it's not allowing access! i using vs2012 , web deploy 3.0 on server 2008r2 x86. update when using command msdeploy.exe -verb:dump -source:iisapp=<sitename>,username=administrator,password=<urpassword>,authtype=‌​basic,computername=https://<yourserver>:8172/msdeploy.axd?site=<sitename> -authtype=basic suggested @shaikhowais following error: error code: error_user_unauthorized more information: connected remote computer ("[computer name]") using web management service, not authorize. make sure using correct user name , password, site connecting exists, , credentials represent user has permissions access site. "make sure using correct user name , password" - yep. "tha...

pass newly added attributes from product detail page to cart page (magento) -

i using magento version 1.7.0 i have added shirt size(newly added attributes) drop down box in product detail page.using below code app\design\frontend\default{mytempalte}\template\catalog\product\view.phtml <?php $product = $_product->getattributetext('size_chart'); ?> shirt size <select name="size_chart"> <option value="select">select</option> <?php for($i = 0;$i < count($product);$i++) { ?> <option value="<?php echo $product[$i]; ?>"><?php echo $product[$i]; ?></option> <?php } ?> </select> customer can able select shirt size .after select shirt size need show shirt size in cart , checkout page. how pass shirt size value product detail other page?. thanks actually, in cart page may cart items in quote object. $cart = mage::getmodel('checkout/cart')->getquote(); $items = $cart->getallvisibleitems(); foreach ($items $item){ ...

.net - Installing a Vb.NET Windows application by including Crystal Report runtime -

i have windows application developed in vs2010 , .net framework 4.0. have used crystal reports in application. we need create installer including crystal report runtime , required visual c++ dependencies per following link: http://wiki.sdn.sap.com/wiki/display/bobj/using+crystal+reports+for+visual+studio+2010+merge+modules+(msm)+to+create+a+setup+project we tried below 2 solutions part of our effort far. errors when using installer install application on target machine. the first solution included using following merge module files part of installer (as per above link): 1. crruntime_12_3.msm 2. microsoft_vc80_atl_x86.msm 3. microsoft_vc80_crt_x86.msm 4. microsoft_vc80_mfc_x86.msm 5. microsoft_vc80_openmp_x86.msm the second included using following merge modules files part of installer (as per site: http://csharp.net-informations.com/crystal-reports/csharp-crystal-merge-module.htm ): 1. crruntime_12_3.msm 2. crystalreportsredist2005_x86.msm 3. microsoft_vc80_atl_x...

Ruby create tar ball in chunks to avoid out of memory error -

i'm trying re-use following code create tar ball: tarfile = file.open("#{pathname.new(path).realpath.to_s}.tar","w") gem::package::tarwriter.new(tarfile) |tar| dir[file.join(path, "**/*")].each |file| mode = file.stat(file).mode relative_file = file.sub /^#{regexp::escape path}\/?/, '' if file.directory?(file) tar.mkdir relative_file, mode else tar.add_file relative_file, mode |tf| file.open(file, "rb") { |f| tf.write f.read } end end end end tarfile.rewind tarfile it works fine far small folders involve large fail following error: error: application used more memory safety cap how can in chunks avoid memory problems? it looks problem in line: file.open(file, "rb") { |f| tf.write f.read } you "slurping" input file doing f.read . slurping means entire fi...

sql server - The sql command automatically creates a row number -

mytable: name family ----------------- aa b bb c cc d dd my desired output sql code(by direction select): row name family ----------------- 1 aa 2 b bb 3 c cc 4 d dd use row_number() function, 1 of ranking functions in sql server: with cte ( select row_number() over(order name) row, name, family tablename ) select * cte;

How to set HLSL compiler tags with Visual Studio 2010 and XNA -

referring answer here , how set tag [branch] hlsl compiler in visual studio 2010 compiling fx files in xna project? as in linked documentation ( doc ) write hints direct before if. don't need tell globally compiler.

Request fields in Python Facebook SDK -

this way fetching /me object: self.facebook_user = facebook.graphapi(access_token).get_object('me') but if want, example, request name , id fields /me , how build request? you can pass in query parameters using **args: graph = facebook.graphapi(access_token) profile = graph.get_object('me') args = {'fields' : 'id,name,email', } profile = graph.get_object('me', **args)

javascript - Call controller $scope methods from nested directives -

i have following directives: directive 1 app.directive('tablediv', function () { return { templateurl: 'js/directives/table-div/table-div.html', replace: true, scope: { table: '=', }, controller: function ($scope, $element, $attrs) { }, link: function postlink(scope, element, attrs) { } } }); directive 1 template: <div data-table-div-row value="row" sizes="table.tbody.sizes" ng-repeat="row in table.tbody.values"> </div> directive 2: app.directive('tabledivrow', function ($rootscope) { return { templateurl: 'js/directives/table-div/table-div-row.html', replace: true, scope: {value: '=', sizes: '='}, controller: function ($scope, $element, $attrs) { $scope.showinfo = function () { $scope.visible = true; }; ...

mobile - Fun web based programming environment for tablet? -

sometimes away computer , have spare time. love programming fun or experiments. can imagine web site can edit , execute javascript (or other language ok). must ready keayboardless tablet. unfortunately typing google contains javascript , ide or website, give millions of links not suitable request. hence write here. not start flame or unproductive discussion. option can think of. jsfiddle allows write html/javascript/css in 1 editor , run it.

CSS hell, I just want a box with min sizes and 1 pixel gap -

please achieve css: have array of text strings, 1 char 200 chars. need display them in webpage each in separate box. the box flow similar text, left right until end of page wrap the background color of each box must cyan. minimal width , height must both 50 pixels 1-2 pixel space between boxes (maybe achieve margin=1) there must @ least 2 pixels between text , edge of box text vertically aligned middle text horizontally aligned center maximum width of box must 300 px if text not fit in 50x300 cropped inside box (box not grow) each box should have 1 pixel black border this must simple experienced! try every possible css tag; wrong. read css boxing, surprisingly made more compilcated. <style> z { min-width: 50; #min-height: 50; padding: 1px; padding-color: magenta; margin: 1px; margin-color: red; #padding-left: 10px; display: table-cell; #height: 50; #vertical-align: middle; #text-align:center; background-color: c...

ubuntu - Failed to load session "gnome" on beaglebone black -

good day, using beaglebone black , have install ubuntu 13.04 on board. following instructions on http://www.armhf.com/index.php/boards/beaglebone-black/ not able load gui did sudo apt-get install gdm xfce4 network-manager this loads gui when login, shows me "failed load session "gnome" " have searched soloution online , found website http://ubuntuforums.org/showthread.php?t=1750430 i followed instrustions , did following commands sudo apt-get update sudo apt-get upgrade sudo apt-get purge gnome-session sudo apt-get install gnome-session sudo apt-get install gnome-accessibility-themes however when log in, still failed load session "gnome" does know how can solve problem? thank you i had same problem. did said , started working. i did step did not. run following command also: sudo apt-get install gnome-shell i connecting through rdp protocol using windows remote desktop. hope command help. br, adrian.

PostgreSQL CAST(x AS typename) or x::typename -

should use cast(x typename) or x::typename in postgresql? i not able find documentation x::typename version of cast except 1 sentence in documentation (" by default, cast can invoked explicit cast request, explicit cast(x typename) or x::typename construct." is difference cast(x typename) in sql-standard while x::typename not? i prefer x::typename time shorter. x::typename postgresql specific. if prefer , doesn't have work on non postgresql databases can use it. the manual casting here . see there third style not recommended.

Using an array coming from a module to be used in another subroutine or main program in Fortran -

i'd glad if me this. i'm studying modules in fortran, , have question. let's module creates matrix [a(3,3)] read user's input. then, i'd use such matrix in new subroutine can operation (for sake of simplicity let's sum). code looks this: module matrixm contains subroutine matrixc integer i,j real, dimension(3,3) :: 10 i=1,3 20 j=1,3 read(*,*) a(i,j) ...

Highcharts - Highlight / Shade date range -

i need add new series chart allow me highlight / shade particular range of dates. needs 100% height of chart. i looking @ using area series, couldn't working wanted given have 2 existing area series on chart. i thought series had 1 or 0 particular point indicate if should highlighted or not? {name: 'mydates', color:'red', fillopacity: 0.3, data: [0, 0, 0,1,1,1,1, 1, 1,1,0,0], type:'area', stacking: 'percent' }, http://jsfiddle.net/l3ynm/ the problem sample: the 'mydates' series doesn't take 100% height of chart if 'mydates' series begins midchart, starts angle. i'd go straight up unless need legend entry, recommend using plotbands instead http://api.highcharts.com/highcharts#xaxis.plotbands you can this, if need legend: http://jsfiddle.net/jlbriggs/jvnjs/305/ data:[[1.5,0],[1.5,80],[2.25,80],[2.25,0]] it relies in part on setting min , max, , using min , max values y data points....

Php ratchet websocket $conn->send($msg)! How to get this messenge in client? -

here code (websocket php using rachet , wamp server! public function onclose(connectioninterface $conn) { $conn->send("close client"); } i using $conn->send() send message client don't know how message using autobahnjs on client? update found sulutions problem! 1) enabled debug mode in autobahnjs ab.debug( true, true ); 2) using conn._websocket.onmessage every messenge response server. conn._websocket.onmessage = function (e){ data = json.parse(e.data); console.log(data[1]); if(data.cat=='serverevents'){ switch(data.action) { case 'updateserverinfo': jquery.updateserverinfo(data.actiondata); break; } } }; thanks all. autobahnjs has own way of handling client requests made server. trying send request server (a "close clients" request) clients. best way this, have thread that's polling server events every x seconds, using js's setinte...

sql server - How can I use a WITH XMLNAMESPACES clause with correlated queries? -

i'm trying use for xml feature of sql server generate xml, specific namespaces. my target xml should like: <ns1:customerinvoices xmlns:ns1="urn:example.com:invoice:01.00"> <customerinvoice> <header> <orderdate>2001-11-13t00:00:00</orderdate> <salesordernumber>so44643</salesordernumber> </header> <lines> <linetotal>3578.270000</linetotal> <unitprice>3578.2700</unitprice> <orderqty>1</orderqty> </lines> </customerinvoice> <customerinvoice>...(abbreviated)...</customerinvoice> </ns1:customerinvoices> the problem have, when use with xmlnamespaces clause, namespace declaration appears on lots of child nodes, third party consumer of xml "prefer not get", i.e. i'm doing like: use adventureworks2008 ;with xmlnamespaces ('urn:example.com:invoice:01.00' ns1) select (sele...

r - How to find offset diagonal of a matrix? -

is there easy way extract vector of 'offset' , 'reverse' "diagonal" (the x's) of matrix in r? [,1] [,2] [,3] [,4] [,5] [1,] x 0 0 0 0 [2,] 0 0 0 0 x [3,] 0 0 0 x 0 [4,] 0 0 x 0 0 [5,] 0 x 0 0 0 i tried diag() does'nt seem take options.. 1) i -th offset reverse diagonal of square matrix m : off.rev.diag <- function(m, = 0) m[ (row(m) + col(m) - 1) %% ncol(m) == ] for example: > m <- matrix(1:25, 5); m [,1] [,2] [,3] [,4] [,5] [1,] 1 6 11 16 21 [2,] 2 7 12 17 22 [3,] 3 8 13 18 23 [4,] 4 9 14 19 24 [5,] 5 10 15 20 25 > off.rev.diag(m, 1) [1] 1 10 14 18 22 > off.rev.diag(m, 2) [1] 2 6 15 19 23 2) can write replacement function : "off.rev.diag<-" <- function(m, = 0, value) { m.ix <- matrix(seq_along(m), nrow(m)) replace(m, off.rev.diag(m.ix,...