Posts

Showing posts from May, 2014

javascript - Creating web application using ruby only without using any framework -

i have develop application in ruby without using framework (rails, sinatra, shoes n all). there way can create html pages, css files , call ruby script on click of button. there method it. why want this? frameworks take away of hard work you. if want extremely lightweight, use rack. everything need should there, or dig source code @ https://github.com/rack/rack started

android - How to implement card layout as in new Google Play -

Image
i implement androidy list tile layout new google play below: don't need implement exact content, tile-like layout of list items. know attributes should set, such color, margin, , how set subtle shadow below each item? i have following listview <listview android:id="@+id/cardlist" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margintop="6dp" android:background="@color/light_gray" android:cachecolorhint="@null" android:divider="@null" android:fadingedge="none" android:listselector="@android:drawable/selector" /> and selector.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/pressed" android:state_pressed="true"/>

java - Synchronizing on a passed object, JFrame is freezing -

i created jframe contains , internalframe draws figures moving(each figure thread ) wanted pausebutton make pause, wanted synchronize them on passed object. but when hit pause button whole window freezing , cannot hit play button thing 1 running @ time, want them running pause. class extends jframe{ .... object o = new object(); jbuttton pausebutton = new jbutton("pause"); jbuttton playbutton = new jbutton("play"); b b = new b(o); pausebutton.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent arg0) { synchronized (synchronizator) { try { synchronizator.wait(); } catch (interruptedexception e) { e.printstacktrace(); } } } }); playbutton.addactionlistener(new actionlistener() { @ov

php - Retrieve data from MySQL database after jQuery autocomplete -

have implemented on site jquery autocomplete function works well. however, use result autocomplete retrieve selected person's telephone number database. the database structure this; id | name | type | tel | mobile | email | level =============================================== 1 | john smith | judge | 01234 567890 | 07812 345678 | jsmith@example.com | bs 2 star here updated code far autocomplete function <script> jquery(document).ready(function($) { $('#inputchiefjudge').autocomplete({ source:'lookups/shows-sj-searchforjudge.php', change: function (event, ui) { $.ajax({ type: post, url: 'lookups/shows-sj-findtel.php', data: 'id='+ id, success: function(data) { details = $.parsejson(data); $('#inputchiefjudge').text("hello"); $('#chiefjudgetel').text(d

javascript - addthis.toolbox() method: buttons cut off and alt text displaying -

as i'm doing jquery html replacement on responsive design, suggested use addthis.toolbox method instead of init method addthis. even though code specifying 32x32 pixel buttons they're getting displayed bottom half of graphic cut off , alt text displaying. here's code: <div id="zazoo" class="addthis_toolbox addthis_default_style addthis_32x32_style"> <a class="addthis_button_facebook_follow" addthis:userid="example"></a> <a class="addthis_button_twitter_follow" addthis:userid="example"></a> <a class="addthis_button_google_follow" addthis:userid="xx"></a> <a class="addthis_button_youtube_follow" addthis:userid="example"></a> </div> <script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=example&async=1"> </script> <script type="text/javascript"> addthis.toolbox(&q

javascript - JSON encoding by browser -

i sending below json response: { "employees": [ { "firstname":"john" , "lastname":"doe" }, // response json { "firstname":"peter" , "lastname":"jones" } ] } but browsers interpreting above json { "firstname":"john" , "lastname":"doe" }, // interpreted json { "firstname":"peter" , "lastname":"jones" } it trailing out wrapped object of json. i thought because default, first tag read. however,that can still loop through records, since still in array format. to prevent this, should include tag, example: { "data":{ "employees":[ { "firstname":"john", "lastname":"doe" }, { "firstname":"peter", "lastname"

c# - Ragdoll joint angle constraints -

i doing c# project on ragdolls based on thomas jakobsen's article http://www.gpgstudy.com/gpgiki/gdc%202001%3a%20advanced%20character%20physics i have converted logic 2d , seems working having problems implementing angle constraints. this code using @ moment: public static void satisfyangleconstraint(particle p1, particle p, float minangle, float maxangle) { float a1 = (float)math.atan2(p1.m_x.x - p1.getfixpoint().x, p1.m_x.y - p1.getfixpoint().y); float a2 = (float)math.atan2(p.m_x.x - p.getfixpoint().x, p.m_x.y - p.getfixpoint().y); float diffangle = a2 - a1; game.currentgame.window.title = "a " + diffangle; //vector2 oldposition = p.m_x; if (diffangle > maxangle) p.m_x = rotatepoint(p.m_x, p.getfixpoint(), (diffangle - maxangle)); else if (diffangle < minangle) p.m_x = rotatepoint(p.m_x, p.getfixpoint(), (diffangle - minangle)); //p.m_oldx += p.m_x - oldposition; } particles p1 , p joints , getfixpoint()

ios - Not Triggering event handler of UIButton from a Method -

i need trigger uibutton programmatically . have seen many of posts such http://stackoverflow.com/questions/5625651/programmatically-fire-button-click-event [btnlocations sendactionsforcontrolevents:uicontroleventtouchdown]; this statement working fine in " viewdidload " , in button handler. -(void)viewdidload { [btnname2 sendactionsforcontrolevents:uicontroleventtouchdown]; } &&&&&&& - (ibaction)btnname1:(id)sender { [btnname2 sendactionsforcontrolevents:uicontroleventtouchdown]; } this works fine . why not triggering user defined method . : -(void) mymethod { if(true) { [btnname2 sendactionsforcontrolevents:uicontroleventtouchdown]; } } simple 1 . didn't reason i need know why not happening ?? , alternative achieve it? thanks. could issue trying invoke ui event on thread. try adding this: - (void)firebuttonevent:(id)unused { [btnname2 sendactionsforcontrolevents:uicontroleventtouchdo

ios - how to display data from sqlite in UITableView in Storyboard -

i create 1 application. in application store 2 array in sqlite table database can't display sqlite in uitableview. searching in google not found display data in storyboard sqlite.!!! please guide me how display data sqlite db in tableview. code : #import "viewcontroller.h" #define dataname @"db.sqlite" @implementation viewcontroller { nsdictionary * dictionary; } - (void)viewdidload { [super viewdidload]; nsarray *name = [nsarray arraywithobjects:@"ribery",@"ronaldo",@"messi",@"zannati",@"totti", nil]; nsarray *team = [nsarray arraywithobjects:@"byern",@"r.madrid",@"barcelona",@"inter",@"rome", nil]; (int = 0; < [name count]; i++) { nsstring * name = [name objectatindex:i]; nsstring * team = [team objectatindex:i]; dictionary = [nsdictionary dictionarywithobjectsandkeys:name,@"name",team,@"te

jquery - How does scrollTop() work -

i trying out how scroll or down table , snippet worked $('.scroll-down').click(function() { $('.tableholder').animate({ scrolltop: $('.tableholder').scrolltop() + 10 }); }); $('.scroll-top').click(function() { $('.tableholder').animate({ scrolltop: $('.tableholder').scrolltop() - 10 }); }); here fiddle http://jsfiddle.net/thiswolf/45glr/3/ what explanation can given explain why scrolltop worked in way? when clicked on scroll-down button value of $('.tableholder').scrolltop() 0 , after event occurred it's value changed 0 + 10 = 10; next, if clicked on scroll-top button value of $('.tableholder').scrolltop() 10 time , after event occurred it's value changed 10 - 10 = 0; and thats, how goes down , up. to make code, bit faster , better, can this: var $tableholder = $('.tableholder'); $('.scroll-down').click(function () { $tableholder.

Association Rule Mining on Relational DataBase -

i working on project "association rule mining on relational data base". have completed implementation problem don't have other tool compare (check) results can 1 suggest me tool association rule mining on relational data base. example input in implementation is: a b c 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1 output : a:1 --> b:1 c:1 100.0% b:1 --> a:1 c:1 66.66667% a:1 b:1 --> c:1 100.0% c:1 --> a:1 b:1 50.0% a:1 c:1 --> b:1 100.0% b:1 c:1 --> a:1 66.66667% in output a:1 means column , value 1. export data, , analyse in weka/knime/whatever. there no benefit of keeping data in database, , results should same after all.

excel - Trying to copy conditional format to pivottable -

all want copy conditional format each column in source range corresponding columns on pivottable. it's getting closer, i'm getting error 1004 while trying apply format. here's code: sub createpivot() ' define rngtarget , rngsource range type variables dim rngtarget range dim rngsource range dim intlastcol integer dim intcntrcol integer dim ws worksheet dim pt pivottable set ws = thisworkbook.sheets("sheet2") ws.cells.clear ' rngtarget pivottable created (ie: sheet2, cell b3) set rngtarget = thisworkbook.worksheets("sheet2").range("b3") ' rngsource defines range used create pivottable set rngsource = activeworkbook.activesheet.usedrange ' select range rngsource.select ' copy range clipboard rngsource.copy ' create new pivottable using rngsource defined above

Installing dust.js for node.js (Error: require.paths is removed...) -

i've googled , read threads come on here in forum, still can't work. i'm trying make dust.js work node.js test.js: var dust = require('dust'); running it: $ node test error: require.paths removed. use node_modules folders, or node_path environment variable instead. @ function.object.defineproperty.get (module.js:388:11) @ object.<anonymous> (/usr/local/lib/node_modules/dust/lib/server.js:6:8) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ module.require (module.js:364:17) @ require (module.js:380:17) @ object.<anonymous> (/usr/local/lib/node_modules/dust/lib/dust.js:511:7) @ module._compile (module.js:456:26) $ node -v v0.10.5 i installed dust it' supposed installed: $ npm install -g dust npm http https://registry.npmjs.org/dust npm http 200 https://registry.npmjs.org/dust npm http https://regi

c# - How can I move next/previous in List using LINQ? -

i have class : public class city { public city() { // // todo: add constructor logic here // } public int id { get; set; } public string title { get; set; } public string description { get; set; } public string image { get; set; } } and list : list<city> list = new list<city>(){ new city{id=1,title="city1",description=""}, new city{id=2,title="city2",description=""}, new city{id=3,title="city3",description=""}, new city{id=4,title="city4",description=""} } how can move next or move previous in list using linq ? you want elementat , it's logically equivalent using list indexer property, , potentially far faster using skip & take @ runtime contains specific check see if sequence implements ilist , if uses indexer, if not iterates on sequence (similar doing skip(n).take(1) ) var namelist = list<string>{"h

ios - NSPredicate for phone number -

my phone number format (987) 786-5645. - (bool)validatephonenumberwithstring:(nsstring*)phone { nsstring *pnregex = @"[(0-9)]{3}+\\ +\\[0-9-]{3}+\\[0-9]{4}"; nspredicate *pntest = [nspredicate predicatewithformat:@"self matches %@", pnregex]; return [pntest evaluatewithobject:phone]; } i using above code. what should exact regex rule this? able figure out digits, , brackets also. what should use detecting whitespace after closing bracket? replace pnregex this, nsstring *pnregex = @"^(\\([0-9]{3}\\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$"; hope helps you.

javascript - Considerations on loading speed with AngularJS one page app -

the argument of one-page app angularjs not clear @ me. specifically why should 1 prefer one-page apps on standard implementation? is there free service turn multiple-pages app android app? opting go one-page app (as show in beginner tutorial) what's best way implement website/app (inclusive of user panel ecc) doesn't become slow in phones? loading controllers when they're called significantly? there relevant page in documentation on how should app implemented in multiple pages? it depends on want build, if it's website, spa (single page app) not you, if it's web application spa aimed give user more application feeling (especially when intended used on phones or tablets , wrapped phonegap ) not sure mean, if want take app written js/html/css , make native on android/ios etc. up-mentioned phonegap trick. if mean want make multiple page app single page app, no, there no service that, you'll have manually it. this complex question , has lot w

Best practice: database referencing tables -

in database design feelings of tuple vs referencing table small pieces of data? for instance, supposing designing schema involving office management. want record department each employee belongs to, otherwise uninterested in information relating departments. have department string/char/varchar/etc in employee table, or have instead foreign key, relating department table. if department table recording nothing other department names, 1 want combine employee table. if contained in employee table cannot guarantee users call hr "humanresourses", may call "h-r", may call "human resources", etc. having foreign key guarantees can 1 thing. also, if other information ever added departments, easy if in table of own. so people think it? naturally more tables , referencing have negative impact on performance. question asked oracle 11g in mind, doubt type of rdms involved has bearing on design consideration. if use related table, don't have perfor

haskell - Formatting a list of doubles into a string -

i trying format list of doubles string. turn list such as: [0.38, 0.94] into like: "astring 0.380 0.940" i have tried: "astring" ++ map (printf "%7.3f") [0.38, 0.94] and feedback: <interactive>:80:19: no instance (printftype char) arising use of `printf' possible fix: add instance declaration (printftype char) in first argument of `map', namely `(printf "%7.3f")' in second argument of `(++)', namely `map (printf "%7.3f") [0.38, 0.94]' in expression: "astring" ++ map (printf "%7.3f") [0.38, 0.94] i've not been able fix this. have unable compose signature works. thank you the problem map (printf "%7.3f") [0.38, 0.94] of type [string] , not string . use concatmap : prelude text.printf> "astring" ++ concatmap (printf "%7.3f") [0.38, 0.94] "astring 0.380 0.940"

configuration - Drupal 7, SMTP module + Gmail -

gmail blocks suspicious activity, , kudos them that. example of when you're configuring smtp module use gmail account sending mail drupal 7 + smtp module-enabled site. how enable gmail accept mail drupal site? here steps use allow drupal + smtp access gmail's smtp server: note: disabling "overlay" module may reading output generated in step #6; consider disabling it. install , configure smtp module drupal. configure gmail account. instructions here prepare gmail "watch" new application access account. ensure you've logged in gmail using same account wish associate drupal site visit https://accounts.google.com/displayunlockcaptcha you see instructions how enable application send on behalf. have 10 minutes after clicking [ continue ] complete next step. the last field @ admin/config/system/smtp "send test e-mail" which doubles excellent smtp debugger, btw . enter email address here , check enable debuging below field.

Greyscale Background Css Images -

Image
i've searched lot on web cannot find cross browser solution fade css backgrund image greyscale , back. the working solution apply css3 filter greyscale: -webkit-filter: grayscale(100%); but works chrome v.15+ , safari v.6+ (as can see here: http://css3.bradshawenterprises.com/filters/ ) many pages online speaks solution grey out elements: filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><fecolormatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* firefox 10+, firefox on android */ filter: gray; /* ie6-9 */ (as can see here: http://www.karlhorky.com/2012/06/cross-browser-image-grayscale-with-css.html ) but not seem work css background images, webkit filter do. are there solution (maybe jquery?) hack lack of support filter on less advanced br

Qt QListView with different delegates per column -

the delegate system not clear me now. i have qlistview displaying custom model. my model composed following columns: column 1, 2 , 3 text column, column's item's text filled using qabstractitem::settext(); column 4, 5, 6 , 7 qvariant of custom class. these column have items filled qabstractitem::setdata(qvariant::fromvalue(mycustomclass()); what need qlistview display text on column 1,2 , 3, , display custom qstring obtained method of mycustomclass on clumns 4,5,6 , 7. how can achieve that? use qabstractitemview::setitemdelegateforcolumn(int column, qabstractitemdelegate* delegate) , docs . have got custom model? if pulling out of custom data text, easier reimplement qabstractitemmodel::data(const qmodelindex& index, int role) const , query column index is, , if custom data column return display role custom data text; otherwise call parent implementation.

javascript - Visual studio 12 and regular expressions error -

i getting strange error in vs2012. i've got following script: <script type="text/javascript"> function validateemail($email) { var emailreg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if( !emailreg.test( $email ) ) { return false; } else { return true; } } </script> this throws sot of errors in ide, , in vs2010 used run ok. what wrong? thanks! let me guess... using razor (a cshtml page)? if so, problem caused because ide thinks part @([\w-]+\.) razor expression , then, javascript reg ex looking missing parenthesis. fix this, need escape @ using @@ code be: <script type="text/javascript"> function validateemail($email) { var emailreg = /^([\w-\.]+@@([\w-]+\.)+[\w-]{2,4})?$/; if( !emailreg.test( $email ) ) { return false; } else { return true; } } </script>

multithreading - Terminating multithreaded application in C++11 by POSIX signal -

i wrote simple multithreaded application in c++11 on linux platform , terminate server , running threads sending sigint signal. obviously server application uses thread support c++11 ( std::thread etc.). although found support signal handling in c++11 ( std::signal ), couldn't find support handling signals in multithreaded environment. so question - there way how handle signals in multithreaded application in c++11 or have rely on pthreads because application needs deal signals? 2.4 signal concepts : at time of generation, determination shall made whether signal has been generated process or specific thread within process. signals generated action attributable particular thread, such hardware fault, shall generated thread caused signal generated. signals generated in association process id or process group id or asynchronous event, such terminal activity, shall generated process. ... signals generated process shall delivered 1 of threads withi

jQuery SlideToggle, toggles several times with Wordpress Custom Posts -

i've made template in wordpress contains portfolio generated custom post type. trying make slidetoggle effect when hover on portfolio image. the problem when hover image shows togglediv on first item , toggles several times. how fix this? you can see problem @ http://www.camillawestin.se (sorry if code bit messy). jquery: $(".portfolio-item").hover(function () { $("#port-link").slidetoggle("fast"); }); wordpress template: <?php $args = array( 'post_type' => 'portfolio' ); $portfolio = new wp_query( $args ); if( $portfolio->have_posts() ) { while( $portfolio->have_posts() ) { $portfolio->the_post(); ?> <div class="portfolio-item"> <a href="<?php meta('special-link'); ?>"><div class="port-image"><?php the_post_thumbnail();?></div></a>

c# - Generate a unique PIN code based on the phone number -

with unique phone number 0241194000 , want generate pin code based on phone number , way check or validate pin generated phone number. example number : 0241194000 lenght(10) pin : 675436 lenght(6) numeric checker : 673aa3738shzxcvder length alphanumeric. any links or great. what looking mathematical bijective function (preferably complex one) allows number (x) turned pin, means of said function f(number) = pin by having bijective function, can validate pins solving equation in opposite direction. http://en.wikipedia.org/wiki/bijection for example: given function: f(number) = number*2 function generatepin(number) return number*2 end function validatepin(pin,number) return pin == number*2 end

php - Wordpress: Get posts by tag where tag contains a name -

i working on portfolio website multiple artists, , each artist have own blog. for each artist have own blog decided them 'tag' in posts make, on portfolio pages list posts said tags. the name of page, name, thought using: <?php $args=array('posts_per_page'=>2, 'tag' => $post->post_title); $wp_query = new wp_query( $args ); ?> would work, doesn't seem pull results. yet when echo post title , tag both displayed same. so next thought match tag reg expression. like: <?php if( preg_match("/tony/i",$post->post_title)){ echo "tony"; } ?> but not know how work wp query. any idea how this, or if there better way same end result? i quite baffled exact same issue. trying display articles based on combination of first , last name, wasn't working using tag argument. ended using tag_slug__and mine. here's came with... <?php $original_query = $wp_query; $args = array( 

jQuery addClass to a div if another div has a class -

i looking ad class trigger div if panel div open. can;t quite crack it. basically: open panel = "active" class added it's trigger i threw fiddle make life easier: http://jsfiddle.net/markthelefty/nlzz4/ thanks! jquery: $(document).ready(function(){ // add initial action- first panel $(".trigger:first").bind("click",function(){ $(this).next().fadetoggle("slow", "linear"); }) $(".panel").each(function(){ $(this).addclass("close"); $(this).css("display","none"); }) $(".panel:first").removeclass("close"); $(".panel:first").addclass("open"); $(".panel:first").css("display","block"); var lastid=$(".trigger:last").attr("id"); $(".next").click(function(){ var

Google Oauth redirect to ios custom url -

goal: complete oauth2 google in ios application. i using phonegap launching oauth in browser. want redirect custom url app can store token. have read this post on how handle redirect still confused. custom url should enter in info.plist? redirect pass oauth page? var redirect_url='com.example.myapp:/oauth2callback' var url="https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=" + client_id + "&state=" + state + "&redirect_uri="+redirect_url+"&scope=" + scope; anyone experienced this? turns out above code correct. issue setting custom url scheme in info.plist. url scheme needs bundle id only(i.e. com.example.myexample). had ':/oauth2callback' appended end of it, incorrect.

html - Standardizing font-weight between OSX and Windows -

Image
i've read osx , windows have 2 different algorithms rendering fonts. such, it's common issue web fonts "heavier" when viewing them in osx in windows. for example, same font, on same site, in same browser, on different operating systems: here's arial exhibiting similar differences: is there way of altering rendering of fonts in either windows or osx closer each other? or there other technique deal difference? that font particularly bad example, deal lot of fonts , have never seen 1 that. keep in mind people used seeing fonts rendered way on own machines, , not job dictate how fonts should rendered. a few things keep in mind use weights you've included, example, not use font-weight: bold on custom font-face if haven't included bold version of font. "browser bold" looks messed compared actual bold font. also, fonts, find need change font-smoothing property webkit browsers, default (subpixel-aliased) can little heavy. can

php - View does not load after form submission through jQuery -

i have following form: html: <form name="newproductform" id="newproductform" action="http://localhost/tddd27/index.php/addproduct/addtodatabase"> <br><label>product name:</label> <input name="itemname" type="text"/></br> <br><label>category:</label> <input name="itemcategory" type="text"/></br> <br><label>description:</label> <input name="itemdesc" type="text"/></br> <br><label>price:</label> <input name="price" type="text"/></br> <input type="text" name="id" value="<?php echo $id; ?>" hidden="true" > <input type="text" name="name" value="<?php echo $name; ?>" hidden="true"> <input type="button" id="_newproduct" nam

ruby on rails - undefined method for _path, but route exists -

i getting rails error when create new "car_image"... ajax response is undefined method `car_image_path' #<carimage:0x007fdbb1b79258> route defined resources :car_images, :only => [:index, :create, :destroy] rake routes car_images /car_images(.:format) car_images#index post /car_images(.:format) car_images#create car_image delete /car_images/:id(.:format) car_images#destroy however, route setup , can see when rake routes, not sure issue is. using route in model method: class carimage < activerecord::base belongs_to :car attr_accessible :description, :image, :title, :car_id, :file mount_uploader :file, carimageuploader def to_jq_upload { "name" => read_attribute(:file), "size" => file.size, "url" => file.url, "thumbnail_url" => file.thumb.url, "delete_url" => car_image_path(:id => i

php - Laravel 3 bundles in Laravel 4 -

in l3 there great thing - packages. have own routes , worked plugins , made software more modular. how achieve in l4? see packages little different bundles. thank you! bundle specific packaging laravel 3, great add package not standard. laravel 4 more modular because accepts packages form php community. uses standard package manager, composer , , laravel 4 managed package. you have create composer.json file 1 : { "require": { "laravel/framework": "4.0.*" }, "require-dev": { "phpunit/phpunit": "3.7.*", "mockery/mockery": "dev-master@dev", "sebastian/phpcpd": "1.4.*" } } and execute composer update . dependencies of project installed in accordance versions specify in file. it's best pattern manage lot of libraries team. bundles , packages similar, gift wrap , shipping way change that's all.

knockout.js - dynamic column and rows with knockoutjs -

my input parameter code below tablename, i able query data return in json format, however, not able display rows item of data. idea did wrong? <script> var invtype = "@viewbag.invtype"; function viewmodel() { var self = this; function colname(tbstruct){ this.columnname = tbstruct.columnname } self.tbstruct = ko.observablearray(); self.items = ko.observablearray(); self.invtype = invtype; self.load = function () { //expected data self.items //[{"$id":"1","id":2,"inv_id":"pv0001-1","acx_no":"6","acx_name":"abc","s_no":"5", "acc_class":"local","direction":"two-way"},{"$id":"2","id":2,"inv_id":"pv0002-1","acx_no":"3","acx_name":"ckd",&quo

ruby on rails - ActiveRecord : Hide column while returning object -

is there out-of-the-box way hide/remove column (say, user.password) while returning activerecord object ? thanks. using built-in serialization, can override as_json method on model pass in additional default options: class user < activerecord::base # ... def as_json(options = {}) super(options.merge({ except: [:password, :oauth_token] })) end end there better serialization tools out there - if looking more fine-grained control recommend checking out active_model_serializers or rabl .

windows mobile - WCELOAD is not installing my CAB file -

we trying install cab file on windows mobile device. wceload.exe present on device on ram because able tap on cab , install it, not see in windows folder. have tried see hidden file, checking "show files". need on 1000 devices , need able programatically. can please recommend how can launch wceload in rom commandline or move windows folder? i need able install cab file command line. tried \windows\wceload.exe /silent xyz.cab did not work. have tried \windows\wceload.exe xyz.cab , did not work. can please tell me doing wrong? not see error messages. i'm not you're asking here. wceload.exe present in every windows mobile device. period. yes, it's hidden file, , can't see in explorer (remote file viewer show it), why, exactly, need "see" it? guaranteed there. , cannot deleted. what underlying problem you're trying solve here? suspect maybe you're getting error when attempting run cab file, question far clear. edit base

r - Trinity failed with differential expression analysis test -

i tried running de test comes trinity after installing that's mentioned on website, ran error. warning: edger comparison failed... cmd: r --vanilla -q < trinity_trans.counts.matrix.diauxic_shift_vs_plateau.edger.rscript > library(edger) > > data = read.table("/usr/local/trinityrnaseq-r2013.02.25/sample_data/test_full_edger_pipeline/trinity_trans.counts.matrix", header=t, row.names=1, com='') > col_ordering = c(4,1) > rnaseqmatrix = data[,col_ordering] > rnaseqmatrix = round(rnaseqmatrix) > rnaseqmatrix = rnaseqmatrix[rowsums(rnaseqmatrix)>=10,] > conditions = factor(c(rep("plateau", 1), rep("diauxic_shift", 1))) > > exp_study = dgelist(counts=rnaseqmatrix, group=conditions) calculating library sizes column totals. > exp_study = calcnormfactors(exp_study) > et = exacttest(exp_study, dispersion=0.1) comparison of groups: plateau - diauxic_shift > ttags = toptags(et,n=null) > write.table(ttag

icons - How to display Images in a wxListCtrl (multicolumn report style) -

i managed create wxlistctrls either icons or multicolumn text this picture of 2 wxlistctrls now i'd add icon each line of text list on left. thought should possible typical wxwidgets applications code::blocks , wxsmith diplay icons in list/tree views (resource browser window) , in tabs of notebooks (compiler log window). how can create this? (everybody knows windows explorer) picture of explorer window icons i tried this... setimagelist (toolimages, wximage_list_normal); insertcolumn (0, "icon"); setcolumnwidth (0, 40); ... (int i=0; i<5; i++) { insertitem (i, i); setitemcolumnimage (i, 0, i); setitem (i, 1, inttostr (i+1)); ... but can see, text gets displayd, image column blank. possible @ mix text , images in report mode? if not, other wxcontrol class can use desired result? many in advance. yes, possible, , listctrl sample shows how it, in particular see myframe::initwithreportitems() function. difference code seems use diff

java - Resize a picture to fit a JLabel -

i'm trying make picture fit jlabel. wish reduce picture dimensions more appropriate swing jpanel. i tried setpreferredsize doesn't work. i'm wondering if there simple way it? should scale image purpose? outline here steps follow. read picture bufferedimage. resize bufferedimage bufferedimage that's size of jlabel. create imageicon resized bufferedimage. you not have set preferred size of jlabel. once you've scaled image size want, jlabel take size of imageicon. read picture bufferedimage bufferedimage img = null; try { img = imageio.read(new file("strawberry.jpg")); } catch (ioexception e) { e.printstacktrace(); } resize bufferedimage image dimg = img.getscaledinstance(label.getwidth(), label.getheight(), image.scale_smooth); make sure label width , height same proportions original image width , height. in other words, if picture 600 x 900 pixels, scale 100 x 150. otherwise, picture distorted. crea

how to rebalance cassandra cluster after adding new node -

i had 3 node cassandra cluster replication factor of 2. nodes running either dsc1.2.3 or dsc1.2.4. each node had num_token value of 256 , initial_token commented. 3 node cluster balanced i.e. each owned around 30% of data. one of nodes crashed started new node , nodetool removed node had crashed. new node got added cluster 2 older nodes have of data (47.0% , 52.3%) , new node has 0.7% of data. the output of nodetool status is datacenter: xx-xxxx =================== status=up/down |/ state=normal/leaving/joining/moving -- address load tokens owns host id rack un 10.xxx.xxx.xxx 649.78 mb 256 47.0% ba3534b3-3d9f-4db7-844d-39a8f98618f1 1c un 10.xxx.xxx.xxx 643.11 mb 256 52.3% 562f7c3f-986a-4ba6-bfda-22a10e384960 1a un 10.xxx.xxx.xxx 6.84 mb 256 0.7% 5ba6aff7-79d2-4d62-b5b0-c5c67f1e1791 1c how balance cluster? you didn't mention running repair on new node, if indeed haven't yet

apache - Lower level htaccess does not override root htaccess -

after 2 days i'm out of ideas. have htaccess file inside "public_html" appears ignore other htaccess files in sub-directories. purpose of 2 htaccess files password protect different areas diffrent passwords. the problem: once gain access via password "public_html", automatically have access other sub-directory despite fact password protected own htaccess. thank clues may provide! paul.

java - sh: 1: Syntax error: Unterminated quoted string, ruby, linux -

i need run 2 java compilers in ruby in linux. code is: system("java -xmx2g -cp .:mul.jar:weka.jar:traintest1 -arff fileinput.arff -xml nilm.xml -k #{parameter1} -name c_#{parameter2}_ g_#{parametere3} -class \"-c #{parameter2} -l 0.0010 -p 1.0e-12 -n 0 -v 10 -w 1 -k \"weka.classifiers.functions.supportvector.rbfkernel -c 250007 -g #{parametere3} \"\\") i'm running weka , mulan libraries. have error sh: 1: syntax error: unterminated quoted string you have 3 quotes in command line (unbalanced), imagine want 4 (or other number).

android - Holoeverywhere : how to programmatically remove at runtime the action bar from an activity -

which correct way remove action bar inside activity ? my activity extends org.holoeverywhere.app.activity i've custom application class extends org.holoeverywhere.app.application , @ startup execs static code : thememanager.setdefaulttheme(thememanager.dark); thememanager.map(thememanager.dark, r.style.holo_demo_theme); thememanager.map(thememanager.light, r.style.holo_demo_theme_light); thememanager.map(thememanager.mixed, r.style.holo_demo_theme_light_darkactionbar); thememanager.map(thememanager.dark | thememanager.fullscreen, r.style.holo_demo_theme_fullscreen); thememanager.map(thememanager.light | thememanager.fullscreen, r.style.holo_demo_theme_light_fullscreen); thememanager.map(thememanager.mixed | thememanager.fullscreen, r.style.holo_demo_theme_light_darkactionbar_fullscreen); in activity : protected void oncreate(bundle savedinstancestate) { thememanager.removetheme(this); settheme(thememanager.dark | thememanager.fullscreen); super.oncreate

c# - Access parent data in a nested strongly typed repeater -

lets have class structure looks this: public class { public string poperty1 { get; set; } public string poperty2 { get; set; } public list<b> property3 { get; set; } } public class b { public string property4 { get; set; } public string property5 { get; set; } } ...and couple of nested repeaters this: <asp:repeater itemtype="a" runat="server"> <itemtemplate> <asp:label text="<%# item.property1 %>" runat="server" /> <asp:repeater runat="server" datasource="<%# item.property3 %>" itemtype="b"> <itemtemplate> <asp:label text="<%# item.property4 %>" runat="server" /> </itemtemplate> </asp:repeater> </itemtemplate> </asp:repeater> how access property2 second repeater? well, accessing parent data in nested re

selenium suite in ruby/rspec - how to run multiple cases and stay logged in? -

i have selenium suite in rspec. how can run multiple cases , keep browser open , logged in between them? i have test suite in selenium ide comprised of 20 unit cases. i've exported both individual test cases , test suite file ruby/rspec i can run individual tests , pass, e.g. rspec spec/2day/units/set_qa_district_name_spec.rb however when tried run converted suite either rake spec or rspec spec/2day/complete_district_suite_spec.rb it runs each spec one-by-one bringing (and closing) application each test. how can run suite , have browser 'stay' , logged in test test , not opening , closing down browser window each unit test runs. i have run these tests in standalone directory i've created have kept separate rest of applications test areas, in other words have avoid use of rails itself. i have set following gemfile / spec_helper / rake files in root directory these files follows: gemfile: gem 'rspec' gem 'selenium-webdriver&

express - Can i run more than one js script at Node.js startup -

i run additional script before main 'node app' called. so, have changed package.json follows: "name": "application-name", "version": "0.0.1", "private": true, "scripts": { "start": ["node helloworld", "node app"] }, ... then command line run: npm start this doesn't work. there way call 1 script before @ node.js startup? thank you don't use array processes. separate them semicolon instead this. "name": "application-name", "version": "0.0.1", "private": true, "scripts": { "start": "node helloworld; node app" }, ...

ruby - Unexpected $end after while loop and nested if -

i have program working on supposed find sum of first 1000 prime numbers. concerned making sure program finding first 1000 prime numbers, add functionality adding them later. here have: #!/usr/bin/ruby def prime(num) is_prime = true in 2..math.sqrt(num) if (num % i) == 0 is_prime = false else is_prime = true end end return is_prime end = 2 number_of_primes = 0 while number_of_primes < 1000 prime = prime(i) if prime == true number_of_primes++ end i++ end when try run program following feedback: sumofprimes.rb:32: syntax error, unexpected keyword_end sumofprimes.rb:34: syntax error, unexpected keyword_end what gives? direction appreciated. ruby doesn't have ++ operator, need += 1 number_of_primes += 1

oop - Composition vs Aggregation -

let have car class , paint class(which consists of different colors). in terms of object oriented design can relation between these 2 classes composition or aggregation. first thought composition , thought aggregation since if car class destroyed paint can exist independently. thinking right on here? i depends on context of model. paint class represent? "a paint job specific car"? if so, part-of car , considered composition. if paint independent concept, , instance can applied multiple cars, car has-a paint instance, , considered aggregation.

rally - RallyRestAPI Create Build with ChangeSets -

i creating rally build records part of teamcity rally integration havving issues associating build changeset. i find set of related changesets match particular criteria , have them in array of string. create jsonarray object, add these "_ref" strings jsonprimatives array, add array create json object , add rally. however, happens build created result has empty changeset array. i have tried including changesets in createrequest , doing updaterequest in both cases response success, there no errors or warnings reported , changeset array returned null , re-querying shows other data expected changeset array empty. here code. jsonobject obj = new jsonobject(); obj.addproperty("workspace", def.getworkspace().getref()); obj.addproperty("duration",1.05); obj.addproperty("message", "master 4683 success"); obj.addproperty("start", isoformat.format(new date())); obj.addproperty("status","success"); obj.a

javascript - Modify UI of Log4Javascript -

Image
i have log4javascript setup displays log follows: however, rid off stuff, , instead ui below: how can done? using inpageappender i'm not sure if there's config option, this jsfiddle might started : html there's delayed log.debug here check hiding of toolbars doesn't break logging. <script src="http://log4javascript.org/js/log4javascript.js"></script> <script type="text/javascript"> var log = log4javascript.getlogger("main"); var appender = new log4javascript.inpageappender(); log.addappender(appender); log.debug("this debugging message log4javascript in-page page"); settimeout(function() { log.debug("this debugging message log4javascript in-page page"); }, 2000); </script> js this code waits until log4javascript load event has fired, , hides toolbars. function removeswitchescontainers() { var iframes = document.queryselectorall(&q

Why Blueimp's JQuery File Upload add all prev. selected files even if options [replaceFileInput: false] and [maxNumberOfFiles: 1] are set on init? -

i have normal form input fields , 1 file input field. use blueimp's jquery file upload plugin upload file. seems work, if select file , after click upload button. if reselect files upload, saves prehistory of selections , after upload sends xhrs server. i want upload 1 selected file, not selected files (in file open dialog). here js module handle upload: $(function () { $('#upload_form').fileupload({ datatype: 'json', autoupload: false, fileinput: '#filechose_button', replacefileinput: false, maxnumberoffiles: 1, multipart: true, add: function (e, data) { $('#upload_button').click(function () { $('#upload_button').attr('disabled', true); ... data.submit(); ... }); }, done: function (e, data) { ... // uploaded }, progressall: functio