Posts

Showing posts from June, 2013

Remove link in supersub category PHP Mysql -

i have problem active link i've created. want make sub category doesn't have link, supersub have link each supersub category. the example like: 1. painting (category), 1.1 hobe (sub category), 1.1.1 sealer, 1.1.2 wall paint (supersub category) the table contain: id_kategori, kategori, id_parent this code: <?php include "config.php"; function punya_child($id_kategori = null) { $result = mysql_query('select count(id_kategori) jumlah_child category id_parent = \''.$id_kategori.'\''); $data = mysql_fetch_assoc($result); if($data['jumlah_child'] > 0) return true; return false; } function hirarki($id_kategori = null) { if($id_kategori === null) { $result_top_level = mysql_query('select * category id_parent null'); if(mysql_num_rows($result_top_level) > 0) { echo '<ul class="category">'; while($row_top_level = mysql_fetch_assoc($res

php - Softdelete with Yii and relations -

i have simple db multiple tables , relationships, ie: article - category user - group etc... i have implemented softdelete behavior there active column , if set 0, considered deleted. question simple. how specify in few places possible want load articles belong active categories. i have specified relationships , default scopes (with active = 1) condition. however, when findall(), returns articles have active = 1, if category belongs active = 0.... thank you implementation far: in base class public function defaultscope() { return array('condition' => 'active = 1'); } in model: 'category' => array(self::belongs_to, 'category', 'categoryid'), 'query': $data = article::model()->findall(); my solution so decided, doing in framework is: inneficient too work not moves business logic away database - important save work later on when working on interfaces/webservices , other customizations shou

modeling - Event-B, formal modelling : How to affect all the elements of a set to a relation -

i'm having quite lot of troubles event-b.. i'd make relation group of client client number each i have relation of type : cli(person) = nat1 (person finite set) and in event have subset of person where group <: person and i'd affect cli relation i'd write intuitively : ! x . x : group | cli(x) = numcli am modelling right way? there method affectation i'd get? i'm little bit guessing want achieve: cli maps person number: variables cli invariants cli : person +-> nat1 you want event (let's call ev ) assigns group of persons (called group ) same number: ev = group, numcli group <: person numcli : nat1 cli := cli <+ (group**{numcli}) end group ** {numcli} set of pairs (a relation) first element element of group , second numcli . operator <+ (relational override) removes elements cli first element if 1 of right operand , adds right operand. i.e. mappings of group in cli replaced or add

fabricjs - Can't load SVG from URL -

i want load different shapes in fabricjs based canvas using loadsvgfromurl(), can't. documentation not complete on this. want complete example. can load string, string creates spaces creates problems when rendering. here code: var canvas = new fabric.canvas('canvas'); fabric.loadsvgfromurl('blueflower.svg', function (objects) { var svg = fabric.util.groupsvgelements(objects, options); canvas.add(svg).centerobject(svg).renderall(); svg.setcoords(); }); i have done example on jsfiddle, create 2 objects , load svg image url, can take alook. example: http://jsfiddle.net/tornado1979/0fbefh52/4/ the snippet load svg this: var site_url = 'http://fabricjs.com/assets/1.svg'; fabric.loadsvgfromurl(site_url, function(objects) { var group = new fabric.pathgroup(objects, { left: 165, top: 100, width: 295, height: 211 }); canv

mysql - select from 3 tables with null values -

i have 3 tables users columns user name, user id groups columns group name,group id users_group columns user id, group id the user group contains relation between users , groups. i want select users , groups user names , group names togother. want users dont have group return value of group name null how create such sql in mysql you need left join as select u.username, g.group_name users u left join users_group ug on ug.user_id = u.user_id left join groups g on g.group_id = ug.group_id

is it possible to include Scripts and Styles in same Bundle ?(asp.net mvc5) -

attempting use css , js files same virtualpath bundle name 1 - possible ? (tried:but failed. cant define same virtual path name both script , style) 2 - it possible builtup scriptandstylebundle included mixed bundle ? just because wantto use same name both css , js. //in bundleconfig.cs bundles.add(new scriptbundle("~/bundles/domenu") .include("~/plugins/domenu/files/js/domenu.js") ); bundles.add(new stylebundle("~/bundles/domenu") .include("~/plugins/domenu/files/css/domenu.css") ); //in _partiallayoutmenu.cs @scripts.render("~/bundles/domenu") @styles.render("~/bundles/domenu") result is: <!--menu layout--> <script src="/plugins/domenu/files/css/domenu.css"></script> <link href="/plugins/domenu/files/css/domenu.css" rel="stylesheet"/> <!--/menu layout--> any clue ? or want such use

Deallocating 2D array in C -

for whatever reason getting following error when trying free 2d array created: error in `./a.out': free(): invalid next size (fast): 0x0000000001759310 *** aborted (core dumped) i printed out contents of array , correct , able access of elements. however, yet able free it. error occurs when going through freeing loop, i.e. freeing double *. appreciate help. thanks! here code: /*allocation*/ double **block_mat = (double **) malloc (sizeof(double *) * num_blocks); int i; (i = 0; <num_blocks; i++){ block_mat[i] = (double *) malloc (sizeof(double) * s); } /*freeing*/ (i = 0; < num_blocks; i++){ free(block_mat[i]); } free(block_mat); edit: error found! under-allocated memory...so when printed out arrays looked fine... allocated arrays of sizes s, used s^2 instead. thank everyone! you allocate space s doubles each block_mat[i] . later, access block_mat[i][block_index] = 0; block_index++; but never check block_index goes out of bounds, d

Swift struct is nil when referenced from a function -

i set struct this: struct person { var name: string var age: int init(name:string, age:int) { self.name = name self.age = age } } if in viewdidload , happens expected. override func viewdidload() { super.viewdidload() let person = person(name: "sally", age: 20) self.titlelabel.text = person.name } however, if put same code in function , , call function elsewhere func setup() { let person = person(name: "wally", age: 12) self.titlelabel.text = person.name } the app crashes on line label set, message: "fatal error: unexpectedly found nil while unwrapping optional value" what missing here?

cordova - How can I use launchmyapp with Meteor for the verify-email link? -

i'm using meteoric package run ionic on meteor app. i'd use https://github.com/eddyverbruggen/custom-url-scheme (nl.x-services.plugins.launchmyapp plugin) in app. using it, isn't working right. i'm trying use plugin deep link url app. right i'm trying work verify-email link. click link , takes me app, wants me login first. the link being sent looks this. myappname://verify-email/longtokenidhere1212332 if click app launch, ask user login credentials instead of verifying email address. update 1: i have working. added handleopenurl global function below meteor.startup(function() { handleopenurl = function handleopenurl(url) { var token = url.replace("myappname://verify-email/", ""); console.log("token: " + token); router.go('/verify-email/', {"paramtoken": token}); } }); now see token print console. but when routes route not found page. how can print current url conso

Dictionary now gives error 'not convertible to BooleanLiteralConvertible' since updating to Swift 1.2 -

i'm getting head around swift - came swift 1.2 (breaking working code)! i have function based on code sample nshipster - cgimagesourcecreatethumbnailatindex . my working code is: import imageio func processimage(jpgimagepath: string, thumbsize: cgsize) { if let path = nsbundle.mainbundle().pathforresource(jpgimagepath, oftype: "") { if let imageurl = nsurl(fileurlwithpath: path) { if let imagesource = cgimagesourcecreatewithurl(imageurl, nil) { let maxsize = max(thumbsize.width, thumbsize.height) / 2.0 let options = [ kcgimagesourcethumbnailmaxpixelsize: maxsize, kcgimagesourcecreatethumbnailfromimageifabsent: true ] let scaledimage = uiimage(cgimage: cgimagesourcecreatethumbnailatindex(imagesource, 0, options)) // other stuff } } } } since swift 1.2, compiler provides 2 errors relating op

Filepath with Spaces as Java Argument -

what i'm trying is, r.exec("xdg-open "+args[1]+"/qrcode.png"); but doesn't work expected if args[1] contains white spaces. know in case of shell script can resolved using "$path" . need solution java. try wrapping path in quotes: r.exec("xdg-open \""+args[1]+"/qrcode.png\"");

c# - Ignoring exceptions handled by other assembly -

Image
i have application smoke testing several key services. want these tests written , self discovering. end, have created attribute each method in style of [testmethod] mstest. have created object find these methods , execute them within try-catch. if method throws exception report failure, otherwise success. this unit test familiar , intention. test like... [mytestattribute] public void testingtimesahead() { var d = datetime.maxvalue.adddays(1); } the magic happens in test object, has action property , run method... public action testaction { get; private set; } public override itestresult runtest() { try { this.testaction.invoke(); return new basetestresult() { result = testresultstatus.success }; } catch(exception ex) { return new basetestresult() { result = testresultstatus.failure, failureexception = ex}; } } when ran in isolation above test, being wrapped action, caus

sql - MYSQL: View statement produces incorrect SUM totals -

i have 3 tables. table product prices, invoiced products, , ordered products. trying create view joins these. want output product prices total of invoiced products , total of ordered products. products_price id season_id product_id product_price 1 1 1 3.99 2 1 2 6.99 3 1 3 5.99 4 1 4 5.99 .... invoices_products id season_id invoice_id product_id piece_qty 1 1 1 1 1600 2 1 2 2 3200 3 1 3 2 200 4 1 4 1 120 .... orders_products id season_id order_id product_id piece_qty 1 1 1 1 160 2 1 2 1 40 3 1 2 2 20 4 1 3 2 10 .... here few queries view statements i've tried far. this query gives me want. view's o

ruby - Rendering a partial with locals -

i've rendered partial loads users latest post in 1 of tab panels. <div role="tabpanel" class="tab-pane" id="updates_panel"> <%= render :partial => "pages/update_panel", :locals => { :post => @user.latest_post } %> </div> at first method latest_post display users "last or latest post". def latest_post posts.order(:created_at => :desc).first end but realized need display post in descending order , cant seem right. create method latest_posts , def latest_posts posts.order(:created_at => :desc) end def latest_post latest_posts.first end and use in partal, <%= render :partial => "pages/update_panel", :locals => { :post => @user.latest_post, :posts => @user.latest_posts } %>

c# - @Html.DisplayFor does not show property of strongly typed ListObject which is a property of model -

i having model classa below : public class classa{ public list<classb> bs {get;set} } while classb : public class classb { public datetime? date{get;set;} } i trying iterate on class in following manner in view @model classa ... @foreach(var b in @model.bs) { var _index = 0; @html.displayfor(x => x.bs.elementat(_index).date) _index++; } but getting blank text in view though there data. want print data after iterating on list.since,displayfor default takes model can't use bs in displayfor helper directly. please provide sample code how achieve desired result. var _index = 0; @foreach(var b in @model.bs) { @html.displayfor(x => @model.bs.elementat(_index).date) _index++; }

httpsurlconnection - How do the Java classes CookieHandler and CookieManager work? -

the way can code programmatically login url using cookiehandler.setdefault(new cookiemanager); . fine, want understand how cookie being maintained between each new httpsurlconnection . can please show how make code below log gmail account without having use cookiehandler.setdefault(new cookiemanager); ? thanks. **notes: - substitute own email , password. - cookiehandler.setdefault(new cookiemanager); commented out in code below. public class gmailapp { private list<string> cookies; private httpsurlconnection conn; public static void main(string[] args) throws exception { string url = "https://accounts.google.com/serviceloginauth"; string gmail = "https://mail.google.com/mail/"; gmailapp http = new gmailapp(); // cookiehandler.setdefault(new cookiemanager()); string page = http.getpagecontent(url); string postparams = http.getformparams(page, "myemail@gmail.com", "my

Why did the Java designer restrict the use of non-static variable in static context? -

i know non-static variables cannot referenced static context. want know why java designer made restriction. i have checked stack overflow, , there many similar questions , answers, want know exact reason. so non-static variable means object required variable have value. example if have car class , have non-static variable price wouldn't make sense price can referenced car.price . if asked "what price of car?". tell me varies. logical different cars different prices. if make car bmw price different car honda . why have static variable? if have true cars tax on them. want know without having car, description of car is. doesn't mean can't changed means same instances of class.

javascript - Toggle a div in Angular -

how can make toggle in angular.js div open , close when clicked on same div again. perfoms action opens div whenever click again on it, div needs close again. <a ng-href ng-click="openaccordionrow(champion.clean)"> zerg </a> and opens: <div ng-show="isaccordionopen(champion.clean)"> info </div> js: $scope.activerows = ""; $scope.isaccordionopen = function(row) { if ($scope.activerows === row) { return true; } else { return false; } } $scope.openaccordionrow = function(row) { $scope.activerows = row; } problem here same clicked div doesn't close when pressing on again. currently code doesn't have attempts collapse row. change code this. html : <a ng-href ng-click="toggleaccordionrow(champion.clean)"> zerg </a> javascript : $scope.activerows = ""; $scope.isaccordionopen = function(row) { if ($scope.activerows === r

matplotlib - How to adjust the distance between y-axis label in python -

Image
i have code make chart following below: %pylab inline import numpy np import matplotlib import matplotlib.pyplot plt matplotlib.font_manager import fontproperties matplotlib.use('tkagg') plt.style.use('ggplot') dataframe.t.plot(kind='barh', stacked=true) plt.xticks(np.arange(0, 1.1, 0.1), [str(x) x in np.arange(0, 1.1, 0.1)]) plt.xlim([0, 1]) plt.xlabel("pecentage of interets") plt.ylabel("users") plt.legend(loc=9, bbox_to_anchor=(0.5, -0.2), ncol=7) plt.savefig('personint.jpg', format='eps', dpi=1000, bbox_inches='tight') the results of code this: in here, want ask how can adjust distance between y-axis label in code, such space between user1 , user2 , because distance each user in chart close each other. you need add more vertical space figure, try changing figure size @ beginning of code with: plt.rcparams["figure.figsize"] = (8, 10) the vertical space can change dynamically numbe

mysql - Foreign Key Constraints on an Intersection Table -

Image
i trying import data excel document mysql management studio, , when attempting so, data fails import on specific intersection table, has following data: the table inserting called tyearleagues, , error receive states that: an ole db record available. source: "microsoft sql server native client 11.0" hresult: 0x80004005 description: "the insert statement conflicted foreign key constraint "tyearleagues_tyears_fk". conflict occurred in database "dbsql2", table "dbo.tyears", column "intyearid"." the intersection table set so: create table tyearleagues ( intyearid integer not null ,intleagueid integer not null ,constraint tyearleagues_pk primary key (intyearid, intleagueid) ) and foreign key constraint so: alter table tyearleagues add constraint tyearleagues_tyears_fk foreign key ( intyearid ) references tyears( intyearid ) whereas understand issue in normal t

jquery - Mustache Render Ignoring all {{ }} -

i'm using following basic introduction example here: https://github.com/janl/mustache.js/ i'm using following code: var tmp_view = { title: "joe", calc: function(){ return 2+5; } }; var tmp_output = mustache.render("{{title}} spends {{calc}}", tmp_view); however, in browser i'm getting is: var tmp_output = mustache.render(" spends ", tmp_view); which renders "spends" edit: think have better understanding of why happening i'm not sure how resolve it. i using spark server , have following get("/foobar", (req, res) -> new modelandview("", "foobar.mustache"), new mustachetemplateengine()); in .mustache file make json request , inside json request want render template. you should try redefine delimiter in mustache. based on mustache documentation : set delimiter tags start equals sign , change tag delimiters {{ , }} custom strings.

For loops, with replacement in R -

i have dataframe factors. dat <- c("low", "high", "middle", "middle", "low", "low") dat <- factor(dat, levels = c("low", "middle", "high") lvl <- unique(sort(dat)) x <- seq(1,3,1) i want iterate through each factor , replace factors numeric variables if equals ith level. for(i in 1:3){ if(dat == lvl[i]) { dat <- x[i] } } i keep getting error: the condition has length > 1 , first element used . there must simple solution? edit clarity: i'm not trying replace vector corresponding level. i'm trying replace entry term in sequence (1,2,3 in case) corresponds level. you use ifelse particular task can use as.numeric. dat <- as.numeric(dat)

javascript - Mustache Dynamically set variable -

i need in using javascript variable set dynamically mustache template variable. here problem. json looks this jsondata = { "recipemodules" : { "enchiladas" : [ { "title" : "chicken enchiladas", "thumbnailurl" : "http:www.google.com/image", "recipelink" : "location recipe", "credit" : "some credit" }, { "title" : "chicken enchiladas", "thumbnailurl" : "http:www.google.com/image", "recipelink" : "location recipe", "credit" : "some credit" } ], "roastchicken" : [ { "title" : "chicken enchiladas", "thumbnailurl" : "http:www.google.com/image", "recipelink" : "loca

Supply a list of default values if list is empty in Haskell? -

i'm parsing command line arguments determine value want program return but if supply no values, want add bunch of default values list. kind of python's xs = parsed_list or [1,2,3] using guards: xs | null parsed_list = [1,2,3] | otherwise = parser_list using if : (as @mephy suggested) xs = if null parsed_list [1,2,3] else parsed_list using pattern matching: (see @jtobin's answer) using foldr (not recommended): xs = foldr (\_ _ -> parsed_list) [1,2,3] parsed_list using custom operator: ifempty :: [a] -> [a] -> [a] ifempty [] def = def ifempty ys _ = ys xs = parsed_list `ifempty` [1,2,3]

angularjs - ChartJS not rendering when div hidden -

Image
i have angular application tabs. tabs show , hide div content using ng-show directive. each div contains inside canvas showing chartjs charts. when swipe tab another, find charts not rendered until y relaod page or make request function in order reload charts querying server, eventhough data loaded $promise. here, charts correctly rendered... but when change tab without forcing reload (the data loaded), happens... this html <section style="overflow-y:hidden" class="bg-white scroller-v" ng-init="askfortoggle()"> <div class="tab-nav clearfix"> <ul class="side-padding-3x"> <li data-ng-class="activesubmenu('actividades')"> <a class="size-12x" data-ng-click="show('actividades')">actividades</a> </li> <li data-ng-class="activesubmenu('paginas')"> <a class="

Cordova Build Error for Android -

i have been running through cordova tutorial installation , creating first app. after spending last few hours trying figure out have pretty reached dead end. i'm running ubuntu , trying build on android 4.0.0. i have of files listed in error below already. in addition error 3 consecutive popups non-existent files say: "cannot find file '/home/prawg/workspace/hello/list'" "cannot find file '/home/prawg/workspace/hello/targets'" "cannot find file '/home/prawg/workspace/hello/--compact'" here error: [error: please install android target: "android-22". hint: open sdk manager running: /usr/local/bin/android require: "sdk platform" android-22 "android sdk platform-tools (latest) "android sdk build-tools" (latest)] error building 1 of platforms: error: /home/prawg/workspace/hello/platforms/android/cordova/build: command failed exi

ruby on rails - callback before_save seems not working -

i need execute method name before record saved in database, seems not working class guest < activerecord::base before_save :name has_and_belongs_to_many :checkins validates_presence_of :firstname validates_presence_of :lastname validates_format_of :firstname, with: /^[a-za-z\s]+$/ validates_format_of :lastname, with: /^[a-za-z\s]+$/ def name self.firstname.titleize + " " + self.lastname.titleize end end console => guest(id: integer, firstname: string, lastname: string, age: integer, sex: string, photo: string, address: text, mobile: integer, email: string, birthdate: date, created_at: datetime, updated_at: datetime) 1.9.3-p547 :008 > f=guest.new => #<guest id: nil, firstname: nil, lastname: nil, age: nil, sex: nil, photo: nil, address: nil, mobile: nil, email: nil, birthdate: nil, created_at: nil, updated_at: nil> 1.9.3-p547 :009 > f.firstname=" fernando " => " fernando " 1.9.3-p547 :010 > f

c# - Mapping and metadata information could not be found for EntityType /Custom model -

Image
i'm trying create custom model registration , want save form info database. worked when used user model user model auto generated model , don't want rewrite every time decide make changes. when did custom register model inherit user model getting error when try register new user. here register model: using system; using system.collections.generic; using system.componentmodel.dataannotations; using system.componentmodel.dataannotations.schema; using system.linq; using system.web; using creckjackmvc; namespace creckjackmvc.models { public class register : user { [key, databasegenerated(databasegeneratedoption.identity)]//important auto user increment new public decimal cj_user_id { get; protected set; } [required(errormessage = "please provide full name", allowemptystrings = false)] new public string cj_user_name { get; set; } [required(errormessage = "please provide email", allowemptystrings = false)] [regularexpression(@

ios - HealthKit Auth in Swift -

i've been building basic app collect fitness , other data health kit in swift, however, i'm having issue getting authorization occur class healthmanager { let healthkitstore:hkhealthstore = hkhealthstore() func authorizehealthkit(completion: ((success:bool, error:nserror!) -> void)!) { // 1. set types want read hk store let healthkittypestoread = set(arrayliteral:[ hkobjecttype.characteristictypeforidentifier(hkcharacteristictypeidentifierdateofbirth), hkobjecttype.characteristictypeforidentifier(hkcharacteristictypeidentifierbloodtype), hkobjecttype.characteristictypeforidentifier(hkcharacteristictypeidentifierbiologicalsex), hkobjecttype.quantitytypeforidentifier(hkquantitytypeidentifierbodymass), hkobjecttype.quantitytypeforidentifier(hkquantitytypeidentifierheight), hkobjecttype.workouttype() ]) // 2. set types want write hk store let healthkittypestowrite = set(arrayliteral:[ hkobjecttype.quantitytypeforidentifier(hkquantity

java - How to iterate over a custom type and find specific one? -

i have arraylist of class olive: arraylist<olive> olives = new arraylist<olive>(); olives.add(new kalamata()); olives.add(new ligurian()); olives.add(new kalamata()); olives.add(new ligurian()); inside kalamata , ligurian classes, have set names: this.name = "ligurian"; this.name = "kalamata"; how can iterate on olive type arraylist? want find name variable = "ligurian" , return ligurian.getorigin() use streams api: olive olive = olives.stream() .filter(o -> o.name.equals("ligurian")) .findany().get(); string origin = olive.getorigin(); if you're using java 7 can use loop, shame ok: olive found; for(olive olive : olives) { if(olive.name.equals("ligurian")) { found = olive; break; } } string origin = found.getorigin();

Count number of lines under each header in a text file using bash shell script -

i can in python or other high level language. interested in doing bash. here file format: head-xyz item1 item2 item3 head-abc item8 item5 item6 item9 what print following output: head-xyz: 3 head-abc: 4 header have specific pattern similar example gave above. items have specific patterns in example above. interested in count of items under each header. you can use awk : awk '/head/{h=$0}{c[h]++}end{for(i in c)print i, c[i]-1}' input.file

javascript - Print the result of a function in an alert box -

so have function, lets call calculate(). pulls data forms, , adds if items checked or filled in , adds together. for sake of laziness looks this <button onclick=calculate()>calculate total</button> <script type="text/javascript"> function calculate(); { var number1 = 2; var number2 = 3 var sumall = number1 + number2; //print result in "sum" paragraph, keep 2 decimals document.getelementbyid("sum").innerhtml = sumall.tofixed(2); } </script> what want sounded easy, cannot figure out. want print result in alert box. newb? if want simple alert box: window.alert(sumall.tofixed(2)); or alert(sumall.tofixed(2)); to print out in console debugging: console.log(sumall.tofixed(2));

sublimetext3 - Proper syntax highlighting in Sublime 3 for a file written in several languages -

i editing e.g. shell scripts here-documents in other languages (awk, python, r, javascript, name it). sublime 3 guesses overall syntax doesn't included here-document. how can prod sublime in requisite direction, e.g. placing special comments in code before , after here-docs? #!/bin/bash echo "this test" awk '/test/' - <<eof **this** used test in markdown. line isn't included in _output_. eof i've been looking way since posting question, , looks 1 has roll new theme support mixed languages. there 1 plugin though may fit requirements after re-development: https://github.com/projectcleverweb/multilang it more 2 years old (early 2013), , has not seen development since then. remains seen if else picks project. the official forum has this: https://www.sublimetext.com/forum/viewtopic.php?f=2&t=14215&p=53963&#p53963 , this: https://www.sublimetext.com/forum/viewtopic.php?f=2&t=10843&p=42743 either way, chang

Xpath. How to specify a node between two nodes? -

there may 2 possible structures: 1. <c>tttt</c> <a>aaaa</a> <b>bbbb</b> <c>cccc</c> <d>dddd</d> <c>cccc</c> 2. <c>tttt</c> <a>aaaa</a> <b>bbbb</b> <d>dddd</d> <c>cccc</c> how can select node <c> after <b> in first case , if second case, set null? you can use following-sibling axis purpose : //b/following-sibling::*[1][self::c] brief explanation : b/following-sibling::*[1] : direct sibling following <b> [self::c] : check if sibling <c> element

jquery - Having multiple timers Work separately using javascript -

so here question i trying create timer, , timer created every client created, 1 div (this small chunk of actual code, problem timer) <div class="timer"> <input src="/images/playbutton.png" type="image" class="btnplay" /> <div class="clock"> <span class="min">00</span> <span class="s">:</span> <span class="sec">00</span> </div> and here javascript behind timer makes work $j('.btnplay').click(function () { var clock = $j(this).parent().children('.clock'); function pad(val) { return val > 9 ? val : "0" + val; } timerobject = (function starttimer() { clock.children('.sec').text(pad(++sec % 60)); clock.children('.min').text(pad(parseint(sec / 60, 10))); }); //the 1000(milliseconds) means execute function every 1 second

cassandra - What tools are available to tune chunk_length_kb? -

how should know whether need tweak chunk_length_kb table? tools have @ hand find better chunk_length_kb ? that's 1 of least tuned variables - best way tune based on benchmarking actual data (as different data behave in different ways). defaults sane, though - may see few percent improvement moving either or down, it's unlikely major.

c++ - Makefile with directories -

Image
my makefile fine. however, want have folder named "makefile" , folder named "main", first contain makefiles , second contain files meant main() of my project, k-d geraf. for now, header files lie in same folder. folder contains makefile folder , main folder. here makefile (have tried many combinations, last attempt): objs = main_par_auto.o source = ../main/main_par_auto.cpp header = ../division_euclidean_space.h ../find_diameter.h ../find_k_max.h ../householder.h ../io.h ../mean_variance.h ../point.h ../random_generator.h ../random_kd_forest.h ../tree.h ../auto_random_kd_forest.h out = geraf cxx = g++ flags = -pthread -std=c++0x -drkd_par -o3 -wall all: $(objs) $(cxx) $(objs) -o $(out) $(flags) # create/compile individual files >>separately<< main_par_auto.o: main_par_auto.cpp $(cxx) -c ../main/main_par_auto.cpp $(flags) .phony : # clean house clean: rm -f $(objs) and getting err

angularjs ui-router passing dynamic data from form field into resolve -

i trying use resolve in order ensure data has been loaded prior view state displaying on screen. resolve dependent on selection user have made in previous state. as such, need perform request parameter. the problem have no idea how set parameter within app. have tried .get('https://.../questions', {params: {gender: $scope.user.gender}}) .get('https://.../questions', {params: {gender: user.gender}}) .get('https://.../questions', {params: {gender: vm.user.gender}}) the thing works is: .get(' https://.../questions ', {params: {gender: 'male'}}) bigger code snippet below give context. .state('questionnaire', { url: '/questionnaire', templateurl: 'templates/questionnaire.html', controller: "questionnairecontroller vm", resolve: { practice: function($http){ return $http .get('https://.../...') .then (function (data) { return data;

ios - Cordova/Ionic Facebook getLoginStatus not working -

i developing app in ionic/cordova login on facebook. before showing "login-page" check if user connected. the following getloginstatus check works expected in ios simulator. when testing on actual device, getloginstatus callback not fired. facebookconnectplugin.getloginstatus( function (response) { if (response.status == "connected") { set_tokens(response); $location.path('/tab/person/me/events'); } }, function (response) { alert(json.stringify(response)) } ); already set facebook-app public , verified app-id. can give reason described behaviour? i have following implementation facebook login using facebookconnect plugin. facebookconnectplugin.getloginstatus( function(response){ if(response.status == "connected"){ //do something, example share or redirect }else{ facebookconnectplugin.log

javascript - Phonegap / Android - Phone call recognition -

i want make app, looks, @ moment of incoming phone call, database related number. so wanted ask, if there possibility kind of interrupt or event , tells program in background, there incoming phone call ? i seeking solutions android , cordova thanks! i haven't seen plugins implementing kind of feature yet. implementing shouldn't hard since java code available on gabe sechan's awesome answer . also there phonecall trap plugin offers scaffold build plugin on catches event of incoming call.

html - move div down below fixed header -

i have searched , can't seem find answer looking for. i want know how move div down below fixed header. @import url(http://fonts.googleapis.com/css?family=oswald); body { width: 100%; margin: auto; } .container { width: 75%; margin: 0 auto; } .header { background: #6396bc; width: 100%; top: 0; position: fixed; } .logo { float: left; font-family: "oswald", sans-serif; font-size: 15px; margin-left: 15% } { text-decoration: none; color: white; } li { list-style: none; float: left; margin-left: 15px; padding-top: 15px; font-family: "oswald", sans-serif } .nav { float: right; margin-right: 15% } <!doctype html> <html> <head> <title>team zeus | home</title> <link rel="stylesheet" href="../stylesheets/styles.css"> </head> <

R sorting using simple codes -

can me below problem? dataset sample: ticketid creation_date location person a1 01-02-2015 john b1 03-02-2015 b jack c1 03-02-2015 c mint a1 03-02-2015 d manu d1 03-02-2015 somu e1 03-02-2015 john b1 11-02-2015 b jack a1 11-02-2015 c mint b1 14-02-2015 f john b1 27-02-2015 e john problem: 1.remove duplicates of ticketid filtered in such way ->creationdate less 7 days of first occurence date. eg: ticket id,"a1", there 3 creation dates namely, "01-02-2015,03-02-2015,11-02-2015", wanted new column has "repeat flag" , flag first occurence in case being 01-02-2015 yes. because second occurence within 7 days of first incident. 2.by above logic, ->i want filter location(ticketid,creationdate) ->i want filter person(ticketid,creationdate) code: t.first <- eg1[match(unique(eg1$ticketid), eg1$ticketid),] how save output in same excel she

debian - Accessing nginx on a virtual machine from another computer -

i following tutorial on using chef. teacher uses vagrant set virtual machine, vagrant file contains this: config.vm.network :hostonly, "33.33.33.10" i didn't want use vagrant, created vm scratch , implemented other parts of vagrant file manually. i'm not quite sure does. goes onto updating hosts file in /etc/hosts include: 33.33.33.10 kayak.test then can access nginx server using "kayak.test" in browser on computer. can access server using private ip address "192.168.169.129" in browser, added name hosts file , can not access in same way. host file looks this: 127.0.0.1 localhost 127.0.1.1 jack.www.jack.co.uk jack 192.168.169.129 jack.test ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters but cannot access jack.test in browser of other computer. need same functionality has? thanks, jack. probably issue related avahi if have on system. rfc2206 explicitly defin

Memory Allocation in STL C++ -

i little confused memory reallocation in stl c++. example, know if declare vector , , keep pushing elements it, vector @ point need reallocation of memory space , copy existing elements it. linked lists no reallocation needed, because elements not stored consecutively in stack , each element uses pointer point next element. my question is, what's situation other stl in c++ ? example, string , map , unordered_map ? need reallocation ? (disclaimer: concrete data structures specified here may not required standard, useful remember link rules concrete) std::string ~= std::vector ; it's dynamic array, if keep pushing elements @ end, @ time reallocate elements. std::list : each element new linked list node, no reallocation ever takes place, wherever may insert new element. std::deque : it's typically made of several pages of elements; when page full, new 1 allocated , added list of pages; reason, no reallocation of elements ever takes place, , elements ne

How to control the flow of methods that don't return promise in protractor test -

i've got spec i'm grabbing screenshot requires dynamic path created. makedir not return promise, fires @ same time (after) savescreenshot . what's best way ensure makedir called first? getpath().then(function(path) { makedir(baseurl + '/' + path); savescreenshot(baseurl + '/' + path + '/' + filename); }) you should able chain then() , second operation in there. getpath().then(function(path) { makedir(baseurl + '/' + path); var screenshotpath = baseurl + '/' + path + '/' + filename; return screenshotpath; }).then(function(screenshotpath) { savescreenshot(screenshotpath); });

php - Composer not composing - saying file not found -

i'm using excellent phpwkhtmltopdf library , want update latest version , need use composer. file structure: vendor --mikehaertl --php-shellcommand --php-tmpfile autoload.php composer.json file: { "name": "mikehaertl/phpwkhtmltopdf", "description": "a slim php wrapper around wkhtmltopdf easy use , clean oop interface", "keywords": ["pdf", "wkhtmltopdf", "wkhtmltoimage" ], "homepage": "http://mikehaertl.github.com/phpwkhtmltopdf/", "type": "library", "license": "mit", "authors": [ { "name": "michael haertl", "email": "haertl.mike@gmail.com" } ], "require": { "php": ">=5.0.0", "mikehaertl/php-tmpfile": "1.0.*", "mikehaertl/php-shellcommand": "1.0.*" }, "autoloa

html - Google style drop down - Content bigger than parent -

this full code: https://jsfiddle.net/dv6gxtoh/2/ i want dropdown box expand , full width of it's content (so doesn't have drop things down line) don't want stretch main dropdown button same width. the best example can give bit this: http://i.stack.imgur.com/w3ym8.png this css using: * { margin: 0; padding: 0; } .click-nav ul { position:relative; display: inline-block; } .click-nav ul li { position: relative; list-style:none; cursor:pointer; display:inline-block; } .click-nav ul li ul { position:absolute; left:0; right:0; } .click-nav ul .clicker { position:relative; color:black; } .click-nav ul .clicker:hover, .click-nav ul .active { background:#196f9a; } .click-nav ul li { display:block; padding:8px 10px; background:#fff; color:#333; text-decoration:none; } .click-nav ul li a:hover { background:#f2f2f2; } /* fallbacks */ .click-nav .no-js ul { display:none; } .click-nav .no-j

vb.net - Connecting Bing map in VB using web browser -

i have written code allows user click map button takes them bing maps problem when using google maps instead address automatically populate search field , complete search me, have had switch bing maps because google maps freeze , tell me unsupported. know have add in addition code allow bing automatically search information has gather fields linked to. private sub btnmap_click(sender object, e eventargs) handles btnmap.click form2.show() ' search google maps exchange dim postcode string = postcodetextbox.text dim address string = addresstextbox.text try dim queryaddress new stringbuilder queryaddress.append("http://www.bing.com/maps/?") if postcodetextbox.text <> string.empty queryaddress.append(postcode + "," & "+") end if if addresstextbox.text <> string.empty queryaddress.append(address + "," & "+") end i