Posts

Showing posts from January, 2014

android - ViewPager's Fragments disappear -

i'm using drawerlayout viewpagerindicator , last won't work correctly drawerlayout . once open application, viewpager displayed correctly once change fragments in drawerlayout viewpager's fragments disappear. here's fragmentmanager: fragmentmanager fragmentmanager = getsupportfragmentmanager(); switch (arg2) { case 0: contentfragment = new lebanon(); break; } fragmentmanager.begintransaction() .replace(r.id.content_frame, contentfragment).commit(); the second fragment , fourth in viewpager there , didn't disappear, while first, third , fifth disappear. what's wrong in code? here's fragment: @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { viewta = inflater.inflate(r.layout.simple_tabs, container, false); samsunglb = com.androidarabia.lebanon.samsunglb.newinstance(); htclb = com.androidarabia.lebanon.htclb.newinstance(); lglb = com....

ruby on rails - Error installing sqlite3 gem rvm opensuse premission denied -

new linux. installing ruby 2.0 , rails 4.0 through rvm. got working on laptop linux ubuntu having problem on work computer linux opensuse. installed rvm, ruby , rails. created rails app when run bundle install this: **errno::eacces: permission denied - /home/alf/.rvm/gems/ruby-2.0.0-p247/gems/sqlite3-1.3.8/api_changes.rdoc error occurred while installing sqlite3 (1.3.8), , bundler cannot continue. make sure `gem install sqlite3 -v '1.3.8'` succeeds before bundling.** also got when running bundle install: **gem::installer::extensionbuilderror: error: failed build gem native extension. /home/alf/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb checking sqlite3.h... no sqlite3.h missing. try 'port install sqlite3 +universal' or 'yum install sqlite-devel' , check shared library search path (the location sqlite3 shared library located). *** extconf.rb failed *** not create makefile due reason, lack of necessary libraries and/or headers. check mkmf.lo...

PRIMARY KEY definition in Cassandra 1.2 using CQL 3 -

i newbie in cassandra , following this cassandra tutorial on youtube. in tutorial, author creating 2 tables shown below: create table children(childid varchar, firstname varchar, lastname varchar, country varchar, state varchar, zip varchar, primary key(child)) compact storage; create table naughtyornicelist(standingbycountry varchar, state varchar, zip varchar, childid varchar, primary key(standingbycountry, state, zip, childid)); i facing 2 problems now. first problem children table gets created when remove with compact storage . second problem while creating naughtyornicelist table, cassandra throwing following error : bad request: no definition found not part of primary key i gave following command cqlsh:northpole> create table naughtyornicelist(standingbycountry varchar, state varchar, zip varchar, childid varchar, primary key(standingbycountry, state, zip, childid)); bad request: no definition found not part of primary key cqlsh:northpole> i not able f...

javascript - load an image after clicking a button -

i have <button> rel="example.jpg" . want button load image in #area div, after clicking on it, not page load. use code , done: $(document).ready(function(){ $("button").click(function(){ var imgurl = $(this).attr('rel'); $("#area").html("<img src='" + imgurl + "' alt='description' />"); }); }); <button rel="example.jpg">click me</button> <div id="area"></div> here jsfiddle. now found rel not valid <button> . i'm interested know other solutions this, such using jquery .data() html <button data-rel="example.jpg">click me</button> jquery $("button").click(function () { var imgurl = $(this).data('rel'); $("#area").html("<img src='" + imgurl + "' alt='description' />"); });

Getting Exclamation Mark Image in the place of FusionCharts -

Image
i'm using fusioncharts in webpage. i'm rendering same portlet fusioncharts twice in page. i'm getting big exclamation mark (!) in grey circle in place of charts. , happens sometimes, i'm not sure how replicate scenario or why happens. has faced similar issue? note: div id fusioncharts different in page. same div id not whats causing this. if can give me solution, great. screenshot: unfortunately, cannot share code base in forum. i'm sure there nothing wrong in code because chart renders always. happens still problem. without code or sample can reproduce this, answer based on checking best practices ensure not have duplicate chart id ensure either re-render existing chart or update data - @ least ensure dispose unneeded charts if re-rendering ensure div chart being rendered "visible" during rendered process. if have many interactive activities charts - tab change, etc... ensure sync them chart events such rendered , disposed ...

java - How to share expensive resource across multiple spock test groovy using the spock framework -

i running set of spock test integration test cases using maven surefire plugin. aware share resource across fixture of spec in single file using @shared keyword. however, possible share across different spec file, possibly spec runner? or annotation not aware of? spock uses junit execution model, doesn't envisage sharing state between test classes. common solution manage shared state static singleton.

Haskell type-level projection -

is there way of defining type level projection without using type families? i so: {-# language typefamilies #-} type family project t :: * type instance project [r] = r , but ever use 1 instance of it. you can use multiparamtypeclass , functionaldependencies , though without knowing why you're using it's hard if sufficient. class project k | k -> instance project [r] r > :t undefined :: project string r => r undefined :: project string r => r :: char

php - Column count doesn't match value count at row 1 -

i'm getting annoyed @ why isn't working, see no issue why can't add database ! this table this insert form, $sql="insert reports (title, author, description, pubdate, tags, price) values ( '$_post[title]', '$_post[author]', '$_post[description]' '$_post[pub_date]' '$_post[tags]' '$_post[price]' )"; if (!mysqli_query($con,$sql)) { die('error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); i've removed connection details security, every time submit form keeps giving me error , don't know why, if has ideas let know :) try $sql="insert reports (title, author, description, pubdate, tags, price) values ( '$_post[title]', '$_post[author]', '$_post[description]', '$_post[pub_date]', '$_post[tags]', '$_post[price]' )"; if (!mysqli...

python - Why do I always have to manually press "Enter Key" after every run in SPYDER? -

Image
i using spyder ide python. i notice every time i select code snippet press "f9" as follows: i have console follows: with ... , have press "enter key" many times finish execution. i tired of doing so. how may make automatically finish everything? please update spyder 2.2.3 , it's more stable , it'll fix problem. go our downloads page , use our windows installer. notes : use #%% separate file sections evaluation (a la matlab cells), instead of selecting every time portion want send console. please install ipython ease task. ipython comes not command line interface graphical 1 embedded in spyder take advantage of multiple facilities (like multine inputs) in case let evaluate file portions more easily.

ruby on rails - dealing with phpsessid using mechanize -

am trying crawl website everytime need phpsessid request_headers cookie firebug or return 500 , tried generate phpsessid using securerandom.hex(13) won't works , solution fix ? = mechanize.new a.request_headers = { "accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "content-type" => "application/x-www-form-urlencoded; charset=utf-8", "host" => "www.website.com", "referer" => "http://www.website.com/equipment", "accept-encoding" => "gzip, deflate", "x-requested-with" => "xmlhttprequest", "pragma" => "no-cache", "cookie" => "__alti_visits=1; __papvisitorid=#{securerandom.hex(16)}; __alti_visits=2; phpsessid=#{securerandom.hex(13)}; skimiuml=2; __altima_newvisit_detect=1;" ...

javascript - Slideout from left push menu navigation -

so, want use menu button 'show/hide left push menu' working, reason when try , remove other buttons, stops working? i haven't included css don't think issue can include link css file if needed. html: <body class="cbp-spmenu-push"> <nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left" id="cbp-spmenu-s1"> <h3>menu</h3> <a href="#">celery seakale</a> <a href="#">dulse daikon</a> <a href="#">zucchini garlic</a> <a href="#">catsear azuki bean</a> <a href="#">dandelion bunya</a> <a href="#">rutabaga</a> </nav> <button id="showleft">show/hide left slide menu</button> <button id="showright">show/hide right slide menu</button> <button id="showtop">sho...

Python Threading with Event object -

i've seen lot of python scripts use threads in class , lot of them use threading.event() . example: class timerclass(threading.thread): def __init__(self): threading.thread.__init__(self) self.event = threading.event() def run(self): while not self.event.is_set(): print "something" self.event.wait(120) in while loop, why check condition if don't set self.event ? because else set it. you start thread in 1 part of application , continue whatever do: thread = timerclass() thread.start() # stuff the thread it's stuff, while stuff. if want terminate thread call: thread.event.set() and thread stop. so answer is: event, in case, not used controlling thread inside thread object itself. used controlling thread outside (from object holds reference thread).

matlab - segmentation of texture with k means -

i have texture pic , want segment using k-mean algorithm. wrote: clc;clear; i=imread('jyfmw.jpg'); [r c]=size(i) %figure %imshow(i) %imhist(i) r=double(i(:)); k=5; [idx,c]=kmeans(r,k); b=zeros(size(c)); b(find( c == 1 )) = 0; b(find( c == 2 )) = 50; b(find( c == 3)) = 100; b(find( c == 4 )) = 150; b(find( c == 5 )) = 200; s=reshape(b,r,c); figure imshow(s) but im not sure this,would please me? need have result like: http://upload7.ir/images/91105509914760477547.jpg for input image: http://upload7.ir/images/20702551133388585947.jpg

Drools how to make theorem prover using RETE? -

we need system prove theorem's : (a+b).(c+d) + e + c.(e+d) = a.c + a.d + b.c + b.d + e + c.e + c.d these may more complex how make program using drools ... tried making search tree using update modify methods not working out somehow. as other drools project: determine requirements define business rules in 1 short human readable simple sentence per rule determine facts be implement in drools

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away on running cron job magento -

i working on magento site , error: sqlstate[hy000]: general error: 2006 mysql server has gone away on running cron job magento i error sometimes. <?php class namespace_module_model_observer { public function importemails(varien_event_observer $observer) { echo "hi dear";exit(); /* connect gmail */ $hostname = '{imap.gmail.com:993/imap/ssl}inbox'; $username = 'myid@gmail.com'; $password = 'mypass'; /* try connect */ $inbox = imap_open($hostname,$username,$password) or die('cannot connect gmail: ' . imap_last_error()); /* grab emails */ $emails = imap_search($inbox,'all'); /* if emails returned, cycle through each... */ if($emails) { /* begin output var */ $output = ''; /* put newest emails on top */ rsort($emails); /* every email... */ foreach($emails $email_number) { /* information specific email */ ...

caching - Why does HTML5 offline re-cache the entire manifest, and only when the manifest file changes? -

i have been reading chapter on offline in dive html5, , has left me questions. it says every time make change 1 of resources in offline web application, you’ll need change cache manifest file itself. can simple changing single character. easiest way i’ve found accomplish include comment line revision number. change revision number in comment, web server return newly changed cache manifest file, browser notice contents of file have changed, , kick off process re-download resources listed in manifest. but let's take wikipedia example discussed in same article. whenever article edited, manifest file must changed reflect edit, , user has stored pages offline lose them because not explicitly mentioned in manifest. desirable behaviour? if yes, why not following: store files in offline cache until deleted explicitly, when manifest changes update files in cache when changed (e.g., when server not return 304 not modified) if 1 behaviour described in above 2 points, opt...

c# - Generic method in class -

my code: public class myclass { private wdmentities _context; public list<t> gettable<t>() { list<t> res = new list<t>(); _context = new dbentities(); if (typeof(t) == typeof(tables)) res = _context.tables.tolist();//error cannot implicitly convert type if (typeof(t) == typeof(columns)) res = _context.columns.tolist();//error cannot implicitly convert type return res; } } i have tables , columns types entitymodel but got compile error: cannot implicitly convert type how must change code make work? you can use cast method here. if (typeof(t) == typeof(tables)) res = _context.tables.cast<t>().tolist(); if (typeof(t) == typeof(columns)) res = _context.columns.cast<t>().tolist(); however not generic method. have change code when need return list of type. should find way items context using generic method. if that's not possible sug...

php - Check if a user logged in or not: Drupal -

i want check if user logged in or not in drupal. if user logged in, print something. otherwise nothing. checking follows: global $user; if($user->uid) { echo "logged in'; } else { echo "not logged in"; } but, in case, showing 'not logged in' either user logged in or not. tried echo $user->uid also. not printing anything. can issue??? there's no need use global variable here. use user_is_logged_in() function (available drupal 6+). if (user_is_logged_in()) { echo "logged in"; } else { echo "not logged in"; }

HTML/CSS Table Padding -

i'm having stupid issue using table, hardly ever use tables , i'm not sure why first image has huge space after it. tried setting width, using "-margin" & padding. cant find reduce size. <tr class="tblpadding"> <td>character:</td> <td class="tdchar"><img src="http://www.xronn.co.uk/pokearena/assets/img/charcter/2.gif"></td> <td><img src="http://www.xronn.co.uk/pokearena/assets/img/charcter/2.gif"></td> <td><img src="http://www.xronn.co.uk/pokearena/assets/img/charcter/2.gif"></td> </tr> best see fiddle show issue - http://jsfiddle.net/uh6j4/1/ because column cell has larger width because of input type text boxes, add colspan cell demo also, saw you've inconsistent table cells in example , make sure fix them according requirement. but far explanation goes, need use colspan on column co...

osx - Removing reference to NSWindowController from AppDelegate on windowWillClose causes crash -

i have following method in gamewindowcontroller (subclass of nswindowcontroller ): - (void)windowwillclose:(nsnotification *)notification { appdelegate *delegate = [nsapp delegate]; [delegate removegamewindowcontroller:self]; } the code removegamewindowcontroller in appdelegate is: - (void)removegamewindowcontroller:(gamewindowcontroller*)controller { [self.controllers removeobject:controller]; } self.controllers nsmutablearray gamewindowcontrollers . the above code seems have race condition. randomly crash exc_bad_access when close windows, every time if close windows @ once. my guess arc deallocating window controller before or removegamewindowcontroller: returns, leaving window dangling pointer controller. have tried adding controller.window.windowcontroller = nil; no avail. for reason, using (bool)windowshouldclose:(id)sender delegate method instead suggested in https://stackoverflow.com/a/11782844/344544 works, not acceptable solution not calle...

Validate range of dates with Regula -

is there way use @range validate range of dates in regula? (ditto @min , @max) or need use @custom? @range(min= and @range(max= do not seem accept of type date - numbers or strings. unfortunately @range accepts numbers. think can though: <input type="hidden" name="date" id="date" data-constraints=" @future(date='2000/1/1', format='ymd') @past(date='2010/1/1', format='ymd')" /> this ensures date after 2000/1/1 , before 2010/1/1 (i.e., in between). didn't document date parameter because don't think had implemented when wrote documentation. sorry; documentation bit behind because i'm working on rolling version 1.3 of regula out, have lot more goodies. i'll getting started on updating documentation soon!

r - How can I flatten two lists within a list without using data.table? -

i form 1 data.frame lists within list l1 <- list(a = c(1, 2, 3), b = c(5, 6, 7)) l2 <- list(a = c(11, 22, 33), b = c(15, 16, 17)) l3 <- list(l1, l2) l3 library(data.table) according 'data.table' manual : "'rbindlist' same do.call("rbind",l), faster" i achieve 'rbindlist' using r base package rbindlist need 'do.call' not! rbindlist(l3) do.call not want do.call(rbind, l3) identical(rbindlist(l3), do.call(rbind, l3)) i'd think calling as.data.frame each time costly. how about? as.data.frame(do.call(mapply, c(l3, fun=c, simplify=false))) mapply takes first elements of l3 , applies function fun , 2nd element , on... suppose you'd 2 lists ( l3[[1]] , l3[[2]] ), you'd do: mapply(fun=c, l3[[1]], l3[[2]], simplify=false) here simplify=false makes sure output not converted (or simplified) matrix. it'll list. general case, use do.call , pass our list other arguments function mapp...

html - How properly set background opacity in one line in style of body? -

how set background opacity next: <body style="background-image: url(images/background.jpg); background-color: white; background-position: center center; background-size: 100%; background-repeat: no-repeat"> i try with: background-opacity: 0.5; but fail. it should like: background-image: url(images/background.jpg) opacity: 0.5; even, opacity: .4; doesn't affect on image, affect on text , whole of body. solutions div doesn't accepted. my web page: http://shell.bshellz.net/~panzerdivision/ browsers: firefox & chrome using opacity property, changes opacity of element itself. to have transparent background-color use rgba() background color instead: background-color: rgba(255, 255, 255, .5); or in short-hand: background: rgba(255, 255, 255, .5) url(path/to/transparent/background.png) center center no-repeat; but if need have transparent background image, image should transparent itself. by way, here solution...

Dynamic CRM 'PERCEIVED_RIBBON_KEY' is undefined -

when opening popup add/edit entity, got js error in ie7 or +. 'perceived_ribbon_key' undefined any idea why issue raise on ie not on other browsers. is crm online? if ie7 no longer supported , shouldn't expect work, ie7 6 years old. browser compatibility introduced microsoft dynamics crm 2011 update rollup 12 or december 2012 service update

ConstraintException after EnforceConstraints in C# datasets -

based on pseudo-code below please tell me if can somethig or better reload dataset in case of constraint failure? thanks! var mydataset = new datatypeddataset(); // dataset has tables parentchild , foreightkey relationships try{ mydataset.enforceconstraints = false; loaddataset(medataset); // method fills schema data violates given schema constraints mydataset.enforceconstraints = true; } catch(constraintexception ce){ logconstraintexception(ce);//some logging mydataset.enforceconstraints = false; } // suppose have = {1}, b = { {a=2, 2}, {a=1,2}} try{ var arow = mydataset.tableb.first().arow; } catch(??/*what type of exception here?*/ exception) { // hm... pitty letsplayfailuretollerantscenario(mydataset.tableb.first(), mydataset.tablea); } var rows = mydataset.tablea.getbrows(); so after tests turned out technically possible. honest happier if task more strict in regards of data constraints, because finding error in under ...

adding html attributes without a value using .net -

i want add multiple attribute select in .net . have done this: if multiselect drpselect.attributes.add("multiple", "true") end if though strictly speaking html should multiple. for "boolean" html attributes (the ones should consist of name without value, required or multiple ) accepted alternative use name="name" , multiple="multiple" . in case should code drpselect.attributes.add("multiple", "multiple") see w3c : boolean attributes may legally take single value: name of attribute itself.

git - How to pull a branch from remote when you accidentally deleted local branch? -

i have 3 branches , have pushed 3 branches remote git [ aka bitbucket using bb]. deleted branch locally using git branch -d <branch-name> i did git push . want branches present in local system. since pushed branches can create local branch tracking remote with: git branch --track <local branch name> <remote branch name> your remote branch names origin/foo , can see list of them git branch -r https://www.kernel.org/pub/software/scm/git/docs/git-branch.html for adding remotes in 1 line can following: git branch -r | egrep -v "(head|master)" | sed -e "s/origin\///" | xargs -i % git branch --track % origin/% this gets list of remote branches except head , master. creates new local version same name track remote.

Why python does not raise NameError -

consider simple case: i = 10 if != id: print as id not defined here assuming nameerror: name 'id' not defined not raise any. but in case: id = 10 if != id: print it raised nameerror exception i . can explain me behaviour? id built-in function, defined. use name variable. here list of built-in functions .

ruby-1.9.3-p448/gems/acts_as_paranoid-0.3.1/lib/acts_as_paranoid.rb:42:in `alias_method' -

i trying use acts_as_paranoid gem, added in gemfile (gem 'acts_as_paranoid') bundle updated , installed installing acts_as_paranoid (0.3.1) when start server have following error, ideas? thank much! /users/jcr/.rvm/rubies/ruby-1.9.3-p448/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=argv.shift) /users/jcr/web/sss/bin/rails server -b 0.0.0.0 -p 3000 -e development /users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/acts_as_paranoid-0.3.1/lib/acts_as_paranoid.rb:42:in `alias_method': undefined method `validate_find_options' class `class' (nameerror) /users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/acts_as_paranoid-0.3.1/lib/acts_as_paranoid.rb:42:in `singletonclass' /users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/acts_as_paranoid-0.3.1/lib/acts_as_paranoid.rb:41:in `included' /users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/acts_as_paranoid-0.3.1/lib/acts_as_paranoid.rb:166:in `include' /users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/acts_as_paranoid-0.3.1/l...

wpf - Visual Studio 2010 XAML layout editor not WYSIWYG -

Image
when i'm creating wpf layouts in visual studio 2010 drag , drop controls toolbox onto default element, typically grid. when spacing shown in visual studio not match what's displayed @ runtime. example, here visual editor , runtime results, respectively, 2 layouts . . . . . . , . . . ... notice spacing altered. here's xaml generated 2 examples . . . <button content="projectpattern" height="23" horizontalalignment="left" margin="12,296,0,0" name="butprojpattern" verticalalignment="top" width="117" click="butprojpattern_click" /> <textblock height="22" horizontalalignment="left" margin="135,0,0,141" name="resultprojpattern" text="(result)" verticalalignment="bottom" width="41" /> <textblock height="23" horizontalalignment="left" margin="175,295,0,0...

c - Expected program to print the value of EOF -

in code: #include<stdio.h> int main() { int t; for(;scanf("%d",&t);printf("%d",t)); } the program runs expected when give general intergers input. working on windows when scanf cntrl+z argument t, not value of eof i.e -1 on standard output, previous argument stored in it. when press cntrl + d program terminates, why cntrl+d cause scanf return 0? and why on scanf cntrl+c compiler says: "process terminated status -107......" not understanding why happening? please help. scanf returns number of matched formatting specifiers, or eof if end of input reached before matching (or failing match) first specifier. when press ctrl+z, scanf reaches end of input , returns eof (because ctrl+z terminates input on windows). not terminate for loop because eof nonzero, previous value of t printed (as t not changed call). note t not receive value eof on end-of-input seem expect: scanf returns eof return value, not write poi...

php - Create web service for notification purpose? -

i have built ecommerce website in cakephp , mysql takes orders , stores them in db. i've been told need create web service sending notification desktop/via email alert of order given instantly , provide order details. need study on web services, soap, post etc. or can easier method? secure , fast response way of receiving such notification web application? in advance :) a webservice useful other way round. if third-party entity wishes access website service without accessing html pages, yes in case, creating webservice on end useful. i recommend instance see restful webservice interface stackoverflow/stackexchange understand concept: https://api.stackexchange.com/docs . in case, can't see how webservices involved. if need send emails website, can done directly php mail() function, or using mailer phpmailer . desktop notifications entirely different matter, because need client software. haven't dug pretty far in topic myself, here few pointers: a popula...

In a dos batch file, can IF "%a%"=="%b%" (goto :label1) else goto :label2, be rewritten to read only one label? -

i script continue next line if & b equal, without having goto :label1 . possible? write other way round: if not "%a%"=="%b%" goto label2 ::the label1 stuff so if , b equal, label2 goto won't run, , process label1 stuff

tomcat - Connection reset by peer: socket write error-Java AXIS2 Web-Service -

i deployed java axis2 based web-service using tomcat on machine. web-service trying access database (foxpro data .dbf) on same machine,during test no error occurred .i hosted database on machine,the web-service did error occurred on return statement (the error did not occur when web-service , database on same machine) code: file file = new file(pccomparisiondirectory+"\\temp"); file.delete(); system.out.println("file deleted"); fileout.flush(); system.out.println("file flushed"); fileout.close(); system.out.println("file closed"); appendtologfile("comparison sheet generated req: "+tcrfqno); system.out.println("log file"); connection.close(); system.out.println("connection closed"); return "cs_"+tcrfqno.touppercase()+".xlsm"; console: file deleted file flushed file closed log file...

flex - Get a Number from String with no default decimal separator -

i have textinput need return number . problem entered value localized logged in user , effects decimal separator . seem nan when try number polish user works great english users: input example: english: 23.5 polish: 23,5 is there workaround this? have following doesn't work: public function myvalue():number { var value:number = new number(stringutil.trim(text)); //nan polish return value; } i have tried following gives nan : private function myvalue(number:number, precision:number=2):number{ var numberformatter:numberformatter = getnumberformatter(precision); return new number(numberformatter.formatnumber(number)); } private function getnumberformatter(precision:number=2):numberformatter{ var iso:string = clientinfo.instance.language.isocode; var formattediso:string = iso.substr(0, 2)+'_'+iso.substr(2,2); var numberformatter:numberformatter = new numberformatter(formattediso); numberformatter.fractionaldigits = precision; ...

Javascript configuration object advice -

this isn't problem code, it's more of advice question. found below code on better practices javascript. if had code below, usage script pull labels , settings etc. carousel = function(){ var config = { css:{ classes:{ current:'current', scrollcontainer:'scroll' }, ids:{ maincontainer:'carousel' } } labels:{ previous:'back', next:'next', auto:'play' } settings:{ amount:5, skin:'blue', autoplay:false } }; function init(){ }; function scroll(){ }; function highlight(){ }; return {config:config,init:init} }(); you've detailed javascript design pattern called revealing module pattern - it's nice pattern grips allows write js in more oop fashion. to access properties simple traverse through object, example: carous...

javascript - How to evaluate var Array in nodejs, at client side? -

the statement - var x = [ "a", "b", "c"] when evaluated using #{x} converts x string "a, b, c". how evaluate x without converting string? note: i'm using bootstrap plug in demands array input. <input data-source='["a", "b", "c"]' > here trying substitute above array x . mentioned above, #{x} operation converts sting, rather deliver array data-source . use json.stringify() convert array json/string representation: var x = json.stringify( [ "a", "b", "c"] ); // yields '["a", "b", "c"]'

php - onClick with string in parameter -

hey i'm in middle of making event calendar. each event in calendar respresented button , when click want pass variables it. right let me pass $id , reason neither of 2 string variables ($description , $title) code onclick button , foreach loop information: $event_day = $day_num . '.' . $month . '.' . $year; foreach ($eventarray $currentevent) { $result = $string->convert_timestamp_to_string($currentevent['start_date']); if ($result === $event_day) { $id = $currentevent['id']; $title = $currentevent['title']; $description = $currentevent['description']; $pagecontent .= '<input type="button" class="event" onclick="showdialog('.$id. $description. $title.')" value="' . $title . '"/>'; } } here function that's supposed create dialog based on variables passed var showdialog = function(id, description, title)...

e commerce - How to Add new jar to ATG ear without assembling or build -

need add jar atg ear file without assembling or building ear. to add new jar existing assembled atg ear file add new jar file atglib folder , edit atg_bootstrap_ejb.jar manifest add class path entry. for exact steps please @ below link http://www.gingercart.com/home/developer-handy/add-jar-to-atg-ear-without-assembling

ruby - Can you append to specific elements in an array based on if statement conditions? -

i developer bootcamp student , having issue 1 of projects. using ruby code pig latin page. got passing tests until point needs accept multiple words: def pig_latina(word) # univeral variables vowels = ['a','e','i','o','u'] user_output = "" # adds 'way' if word starts vowel if vowels.include?(word[0]) user_output = word + 'way' # moves first consonants @ beginning of word before vowel end else word.split("").each_with_index |letter, index| if vowels.include?(letter) user_output = word[index..-1] + word[0..index-1] + 'ay' break end end end # takes words start 'qu' , moves of bus , adds 'ay' if word[0,2] == 'qu' user_output = word[2..-1] + 'quay' end # takes words contain 'qu' , moves of bus , adds 'ay' if word[1,2] == 'qu' user_output = word[3..-1] + word[0] + 'q...

mysql - how to get the count ONLY in a specific time period -

i need count of vehicles appear more 10times/ week showing between '2012-07-24' , '2012-09-02' , . tried : select distinct * anpr_in location='a35.1.ob.1' , date(time) between '2012-07-24'and '2012-09-02' group plate having count(plate)>10; but doesnt filter cars still appear out of period. the table looks like: plate location number time t971jur a3024.7.ib.1 96 2012-05-13 18:06:17 hn52ywe a3024.13.ob.1 94 2012-05-13 18:09:53 r179nbm a335.6.ob.1 90 2012-05-13 18:08:55 wv07eax a35.1.ib.1 91 2012-05-13 18:05:09 hf02nfh a334.14.ib.1 94 2012-05-13 18:06:43 hk11bhe a33.5.ib.2 96 2012-05-13 18:07:52 39341 a35.1.ob.1 0 2012-05-13 18:08:09 cp61pcz a35.1.ib.1 96 2012-05-13 18:07:04 lm06ukn a3024.8.ib.1 96 2012-05-13 18:06:44 3b001 a35.1.ob.1 0 201...

file - How does PHP copy() handle memory -

i need use php's copy() function copy files 1 location another. intentionally not using rename() . the files 500mb 1gb. seems takes 10-20 seconds move them after start php script (one file handled per execution). my server rejecting upload of these files because of max_execution_time , post_max_size , upload_max_filesize , memory_limit values, of set ridiculously high, server time out when trying upload. now i'm concerned server fail if copy() operation running while site dealing lot of traffic. so question is, php's copy() operate in way overload server's memory and/or execution time limits? i know php script takes lot of time complete, hope time period of low-memory "waiting time" php sits , lets server os move file... wouldn't think php need load file buffer or in order copy it, memory discussion on level topic bit out of understanding. can explain how php copy() uses memory, , if there risks associated memory overloads? ...

jsonschema - How to handle @Ref from XSD in JSON Schema -

given following basic example of text element references para element , para element references para element. i'm wondering if i'm correctly representing in json schema? <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="text"> <xs:complextype> <xs:sequence> <xs:element ref="para"/> </xs:sequence> </xs:complextype> </xs:element> <xs:element name="para"> <xs:complextype mixed="true"> <xs:choice minoccurs="0" maxoccurs="unbounded"> <xs:element ref="para"/> </xs:choice> <xs:attribute name="id" type="xs:id"/> </xs:complextype> </xs:element> </xs:schema> i think has done style { "$ref": "#/definitions/diskdevice" }, http://json-schema.org/example2.html . is co...

Excel VBA - Function optional parameter DATE type Fails -

i have function finds following monday date. when no optional date parameter passed goes default of zero. think i've included comments explain problem function nextmondayfromadateortoday(optional startdate date) date ' objective: if date param not supplied should set startdate today ' ??? problem: no arg provided startdate 0 = date value of 1/1/1900 ' ??? how add default optional paramater of date type? ' ??? or, how check if arg provided if parameter date type? if not (isdate(startdate)) startdate = date select case weekday(startdate) case 1: nextmondayfromadateortoday = startdate + 1 case 2: nextmondayfromadateortoday = startdate + 0 case 3: nextmondayfromadateortoday = startdate + 6 case 4: nextmondayfromadateortoday = startdate + 5 case 5: nextmondayfromadateortoday = startdate + 4 case 6: nextmondayfromadateortoday = startdate + 3 case 7: nextmondayfromadateortoday = startdate + 2 end select end function vba variables ...

Use triangle normals in OpenGL to get vertex normals -

i have list of vertices , arrangement triangles per-triangle normalized normal vectors. ideally, i'd little work possible in somehow converting (triangle,normal) pairs (vertex,vertex_normal) pairs can stick vao. there way opengl deal face normals directly? or have keep track of each face given vertex involved in (which more or less happens when calculate index buffers) , manually calculate averaged normal @ vertex? also, there way skip per-vertex normal calculation altogether , find way inform fragment shader of face-normal directly? edit: i'm using should portable es devices fixed-function stuff unusable i can't speak latest full-fat opengl specifications in es you're going have work yourself. although normal modal under old fixed pipeline else, attached each vertex. if opted flat shading model gl use colour @ first vertex on face across entire thing rather interpolating it. there's no way recreate behaviour under es. attributes per vertex ,...

Obtaining the quantity and proportion in SPSS 21 -

i have data in sav file code | quantity ------|---------- | 1 b | 4 c | 1 f | 3 b | 3 d | 12 d | 5 i need obtain quantity of codes have quantity <= 3 , obtain proportion in percentage respect total number , present result this <= 3 | percentage ------|---------- 4 | 57 % all of using spss syntax. i dont know how migrate question here, dont have reputation here add screen shoots that's allot. anyhow procedure of desire output given below. goto transform -> count values within cases dialogue box open, write name of new variable " new " in target variable: go define values new dialogue box open check radio button range, lowest through value: put in below box 3 , press add , press continue , press ok . new variable created name of " new ". go analyze -> descriptive statistics -> frequencies , new dialogue box open send " new " variable variable(s): press statistics ...

c# - Serialize complex dictionary with DataContractJsonSerializer -

with .net 4.5 version of datacontractjsonserializer , of datacontractjsonserializersettings.usesimpledictionaryformat can serialize dictionaries. example dictionary: var dic = new dictionary<string, object> { { "level", 3 }, { "location", "catacomb" } }; will converted nice json: { "level":3, "location":"catacomb" } but if have dictionary value: var dic = new dictionary<string, object> { { "level", 3 }, { "location", new dictionary<string, object> { { "name", "catacobms" } } } }; the resulted json looks bad: { "level":3, "location":[ { "__type":"keyvaluepairofstringanytype:#system.collections.generic", "key":"name", "value":"catacobms" } ] } is there way fix problem? ps:...

matlab - How to pass a symbolic equation to constraints when using fmincon -

i have following problem: when using fmincon need supply constraints. constrain .m file looks this: function [c,ceq]=podmienky_l(ql) global podml zl c=[podml+0.0001-zl] ceq=[]; zl constant while podml symbolic variable contains expression: (22.1*cos(ql(4)) (sin(ql(3)) (0.35*sin(ql(1)) when try run fmincon error: user function returned complex value when evaluated; but when replace variable podml (22.1*cos(ql(4)) (sin(ql(3)) (0.35*sin(ql(1)) works fine. the equation in podml supplied script , can wary use use , can attain hideous proportions, impractical me hardwrite constraints function. have ideas? thanks

Can i block appearing control center in ios7 on some views? -

i need disable control center on 1 key view in case use "swipe up" gesture navigation on view controller add following info.plist: <key>uistatusbarhidden</key> <true/> <key>uiviewcontrollerbasedstatusbarappearance</key> <false/> when "swipe up" avoid reveal control centre. gestures work application , shows grabber

c# - Loop through all buttons on a page and assign a new text value -

i've got page has several buttons on page have same text assigned them, , i'm working on localizing page different language based on user's browser culture. hoping programmatically cycle through them , relabel them on fly. i've tried, , causes asp page error: foreach (button s in page.controls) { if (s.text =="search") { s.text = "buscar"; } } you might want consider using resource files , rather looping through controls. example, resource files in place, can define button so: <asp:button id="btnsave" runat="server" meta:resourcekey="btnsave" text="english button" /> the idea have resx file each language , culture wish support, , each file contain same labels e.g. "btnsave" differing text values. i suggest resource files as, in long term, prove lot more flexible you.

css - KendoUI Grid column autosizing -

i'm trying create grid has have auto-sizing columns (within constraints) , width must never exceed width of parent div. i have 4 columns: col1 col2 col3 col4 ------------------------------------------ | long text | ... | ... | ... | | ... | ... | ... | ... | ------------------------------------------ the values in first column long i'm using styling: white-space: nowrap; text-overflow: ellipsis; text stays in 1 line. want col2 105-170px, col3 40-190px , col4 75-150px. keep small possible avoid huge white spaces appear. i know can achieved setting scrollable: true , don't need scrollbar , don't how sits there no use. after playing different options , hours of searching i've decided use little less elegant solution, i've achieved looking for. if faces similar problem, here did: when dom loads ( $(document).ready(...) or $(...) in jquery), call code remove right padding-right of .k-grid-heade...

Start new Activity with button with FLAG_ACTIVITY_SINGLE_TOP on Android -

basically im trying start new activity button. problem in mainactivity class im using: mpendingintent = pendingintent.getactivity(this, 0, new intent(this, getclass()).addflags(intent.flag_activity_single_top), 0); i think thats reason why when im trying start new activity still can see mainactivity because still on top of screen. tried use this: public void handleclick(view v){ //create intent start new activity. intent intent = new intent(); intent.setclass(this,page2activity.class); startactivity(intent); } but still can't see new activity opened. way how can start new activity on top of screen? thank you. what trying do? to start new activity b activity have do: intent = new intent(this, b.class); startactivity(i); you try set i.setflags(intent.flag_activity_new_task)

Google Maps Android API v2 application crash -

i'm trying sample code of android 'google maps android api v2' working. project built without errors. however, when try run app on everpad , app crashes immediately. the logcat output: 08-30 17:12:42.620: e/dalvikvm(4352): not find class 'com.dvp.android.gallery.gps', referenced method com.dvp.android.gallery.acceuil$5.onclick 08-30 17:12:47.670: e/inputdispatcher(3263): motion event has invalid action code 0xa 08-30 17:12:47.760: e/inputdispatcher(3263): motion event has invalid action code 0x9 08-30 17:12:47.760: e/inputdispatcher(3263): motion event has invalid action code 0x7 08-30 17:12:47.850: e/androidruntime(4352): fatal exception: main 08-30 17:12:47.850: e/androidruntime(4352): java.lang.noclassdeffounderror: com.dvp.android.gallery.gps 08-30 17:12:47.850: e/androidruntime(4352): @ com.dvp.android.gallery.acceuil$5.onclick(acceuil.java:57) the manifest : <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:and...

jquery - Passing back error data to .load() -

i'm calling php function delete file, using .load: gallerystatus2$.load('deletepage.php', {pagename : $(e.target).val()}, function(responsetxt,statustxt,xhr) { if(statustxt=="success") alert("external content loaded successfully!"); if(statustxt=="error") alert("error: "+xhr.status+": "+xhr.statustext); }); /* deletepage.php */ <?php $filename = $_post['pagename'] . 'xml'; // comes in without suffix $filepath = $_server['document_root'] . "/users/user_" . $_session['user']['id'] . "/xmls/" . $_post['filename']; if(!unlink ($filepath)) { echo ("<br />delete of $filepath failed"); } else { echo ("<br />deletepage.php: delete of $filepath suc...

how do you reload a module in python version 3.3.2 -

whenever try reload python module in python version 3.3.2 error code >>> import bigmeesh >>> bob=bigmeesh.testmod() baby happy >>> imp.reload(bigmeesh) traceback (most recent call last): file "<pyshell#2>", line 1, in <module> imp.reload(bigmeesh) nameerror: name 'imp' not defined i tried researching , still got no answers. you have import imp before can use it, other module: >>> import bigmeesh >>> import imp >>> imp.reload(bigmeesh) note the documentation says: note: new programs should use importlib rather module. however, in 3.3, importlib doesn't have simple reload function; you'd have build out of importlib.machinery . so, 3.3, stick imp . in 3.4 , later have importlib.reload , use instead. it's worth noting reload not want. example, if expecting bob change instance of new version of bigmeesh.testmod() , won't. but, on other hand, if ...