Posts

Showing posts from August, 2011

Add a Polymer paper-dropdown-menu to a page from javascript? -

i'm trying add paper-dropdown-menu page javascript. however, when way, ends malformed on page - list items display default , not collapse list. this basic structure of paper-dropdown-menu, looks need create 3 elements nested within each other , append target div... <paper-dropdown-menu label="type"> <paper-menu class="dropdown-content"> <paper-item>test</paper-item> </paper-menu> </paper-dropdown-menu> to end, wrote far: index.html <paper-button id="addlist" on-tap="_addlist">add list</paper-button> <div id="listgoeshere"></div> app.js app._addlist() = function(e) { // creating dropdown container var eldropdown = document.createelement('paper-dropdown-menu'); eldropdown.label = 'type'; // creating paper-menu go inside paper-dropdown-menu var elmenu = document.createelement('paper-menu'); elmenu.id = 'projecttyp

ios - Decrypt AES-256-CBC String (need IV, string/data format?) -

i've been going around in circles apple's cccrypto docs, frameworks , other answers , not making headway. i think need figure out how iv encrypted string receive. i receive json payload contains string. string encrypted in aes-256-cbc. (from laravel php instance think uses openssl). string itself, decrypted, json object. i have pre-defined key. the string receive looks like: ejahdkawwkajashwlkwakajsne8ehahdhsiwkdkdhwniehhehellwhwlllllhshnnwhwhabwiiwhwhwh= (but lot longer). i'm trying use answer here: issue using cccrypt (commoncrypt) in swift but a) unsure if i'm converting string data , b) how iv (initialization vector) string receive. using answer "success" when try pass nsjsonserailizer never got result (it fails) data out - think it's garbage. edit: i mis-understood original problem - receiving base64 encoded string needed decode json (which went fine). using linked answer , importing commoncrypto thought i'd able usable

html - Div on Div displaced -

Image
i'm trying write div on div , i'm stuck trying title right on line of div. know how this? you may interested in looking position of en element. for example, using middle box 'middle' div, , displaced div title; .outer { margin: 0 auto; height: 400px; width: 80%; border: 5px solid red; position: relative; } .middle { height: 200px; width: 80%; border: 5px solid blue; /*centering blue div middle of red box*/ position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .displaced { font-size: 30px; /*needed put green div onto line*/ position: absolute; left:50%; transform: translate(-50%, -50%); border: 2px solid green; } <div class="outer"> <div class="middle"> <div class="displaced"> on line </div> </div> </div> for more information please read w3c documents re

Create session with Devise in web API on ruby on rails -

i'm trying make login system project using devise, chose him, because project have access , http api. for can register user using following method of registration class: def create if userservice.create_user(params[:username], params[:email]) @user = user.new(user_params) if @user.save render json: @user, status: :created return end render json: @user.errors, status: :unprocessable_entity return end render json: "exit", status: :unprocessable_entity end and model of user note has things devise adds: class user < activerecord::base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable has_many :schedules end my problem in session class because can not find include devise::internalhelpers : class api::sessionscontroller < devise::sessionscontroller prepend_before_filter :require_no_authentication, only: [:create] include devise::internalhelpers b

excel - How to ignore cells with dates when adding entire rows -

Image
i have inventory tracking sheet, subtracts inventory count on items row, ignoring cells text on them. i want ignore cells dates on them entering things 01/14/2016 throws whole thing off because counts them number. this current code "=sum(c5-sumif(i5:bz5, "<> *ord", i5:bz5))" so every time have order input 3 rowcells, example: i5 = "order 45", j5 = "01/16/2016", k5 = "5", k5 actual piece count subtracted inventory in c5 picture reference

python - Functions with strings -

i working pyhton on codecademy , stucked in 1 part. goal this: "define function called reverse takes string 'text' , returns string in reverse. may not use reversed or [::-1] this." did 1 , not working this: t = raw_input("enter: ") def reverse(t): x = [] in range(len(t)): x.append(t[len(t) - - 1]) print ''.join(x) but when working. t = raw_input("enter: ") x = [] in range(len(t)): x.append(t[len(t) - - 1]) print ''.join(x) what wrong first one? the first not work because, you're not calling reverse function on t . def reverse(t): x = [] in range(len(t)): x.append(t[len(t)-a-1]) return ''.join(x) t = raw_input("enter: ") print(reverse(t)) in example you're obtaining input, doing nothing it.

java - Why isn't my JOptionPane.showMessageDialog working? -

i'm beginner programmer , wrote school class. somehow joptionpane.showmessagedialog under displaypay() won't work!!! expect message box pop up, instead after enter amount of hours each day, nothing happens! doesn't skip part, whole program pauses! confused! instead if use system.out.println(), works fine. also don't want system.out.println displaypay(), have use showmessagedialog. package payroll.program; import java.util.scanner; import javax.swing.joptionpane; //imports class employee { int hourlypay; int totalhours = 0; string name; //variables void getname() { scanner scan = new scanner(system.in); system.out.println("what employee's name?"); name = scan.next(); //gets name } void calculatepay() { int[] hours = new int[5]; //creates array hours scanner scan = new scanner(system.in); system.out.println("how " + name + " paid per hour?"); hourlypay = scan.nextint(); //gets hourly pay

elasticsearch - Unable to see data in Kibana 4 on Ubuntu -

Image
i trying visualize data file using kibana the format of file follows timestamp;elapsed;label;responsecode;responsemessage;threadname;success;failuremessage;bytes;grpthreads;allthreads;latency;samplecount;errorcount;hostname 2016-01-16 02:27:17,565;912;http request;200;ok;thread group 1-5;true;;78854;10;10;384;1;0;sundeep-latitude-e6440 timestamp;elapsed;label;responsecode;responsemessage;threadname;success;failuremessage;bytes;grpthreads;allthreads;latency;samplecount;errorcount;hostname 2016-01-16 02:27:17,565;912;http request;200;ok;thread group 1-5;true;;78854;10;10;384;1;0;sundeep-latitude-e6440 to map above data, logstash config follows: input { file { path => [ "/home/sundeep/data/test.csv"] start_position => "beginning" sincedb_path => "/dev/null" } } filter { if ([message] =~ "responsecode") { drop { } } else { csv { separator => ";" columns => ["tim

android - Assigning different tasks to different list items -

i have list item , has 3 items in it. want following: when clicked 1 of them, redirected google, , when clicked other, go facebook , on. in code, when click of 3 list items, go same address:google. how can assign different links different list items? here code. public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // listimizde kaç tane eleman olduğunu bulmak için bunu kullanıyoruz listview listview = (listview) findviewbyid(r.id.linklist); string[] links = new string[] { "http://www.facebook.com", "http://www.twitter.com", "http://www.hurriyet.com.tr" }; // arrayadapter, bu listviewin nasıl görüneceğini belirtir. ilk argument // this, yani bu list // 2. argument list viewin şekli, yani simple dropdown şeklinde olsun, // 3. argument de links arrayadapter<string&g

r - Use of apply instead of loops for a matrix -

i have matrix (all_parameters) 150 columns , 100.000 rows. value each data element in matrix "1". replace values "0" if following conditions true: col name either 10, 14, 27 row name starts "t1_" i have following loop works fine: t1_missing = c(10,14,27) for(i in 1:ncol(all_parameters)) { if (any(t1_missing == as.integer(colnames(all_parameters)[i]))) { for(j in 1:nrow(all_parameters)) { if(grepl("^t1_", rownames(all_parameters)[j])) { all_parameters[j,i] <- 0 } } } } the problem execution of loops takes extraordinary long time. tried use apply function not able make work. can please show me how solved using apply function (or else superior , faster on for-loop). thanks help! would simple vectorized operation: all_parameters[ grepl("^t1_", rownames(all_parameters) ), t1_missing] <- 0 further conditions on rows added either & (which might make conditions more restri

php - Get the current url in a mysql query -

how can full curent url wether https or https in mysql query below ? and `url` = 'http://.$_server['http_host'].$_server['request_uri'];' as above part not work complete string , want add @ end , : $query = $this->db->query("select * " . db_prefix . "customer_online `customer_id` != '0' , date_added > date_sub(current_timestamp, interval 1 hour) "); public function getregisteredusersonline(){ $url = "http".(!empty($_server['https'])?"s":"")."//". $_server['http_host'].$_server['request_uri']; $query = $this->db->prepare("select count(*) `num` " . db_prefix . "customer_online customer_id != '0' , `date_added` > date_sub(current_timestamp, interval 1 hour) , `url` = ?"); $query->execute( array( $url ) ); $count = $query->fetch(2); return $count['num']; }

python 3.x - Multiple if conditions comparing to one -

searched around bit , can't find exact problem way want fix it. what best way shorten if statement when having many conditions vs 1 check in python 3? example: if "a" in word or "b" in word or "c" in word etc...: *do this* what more correct/shorter way this? not want loop through. (i.e. in whatever check if in whatever) i've seen other examples like: if {"a", "b", "c", etc...} in {word}: *do this* or if ("a" or "b" or "c" etc....) in word: *do this* none of these work. please help! you may use any built-in function. any(iterable) return true if element of iterable true. if iterable empty, return false . any(s in word s in {'a', 'b', 'c'})

python - PIL Tkinter Canvas EPS to PNG conversion output file contains issues -

Image
so have created following save function turtle graphics program allow user save canvas .png file own file name: def savefirst(): cnv = getscreen().getcanvas() ps = cnv.postscript(colormode = 'color') hen = filedialog.asksaveasfilename() print(hen) im = image.open(io.bytesio(ps.encode('utf-8'))) im = im.resize((2560, 1600), image.antialias) quality_val = 95 sharp = imageenhance.sharpness(im) sharp.enhance(2.0).save(hen + '.png', 'png') however, if user set background different color, in output file (.png) the background color does not appear . also, the output image gets rough around curves. below mean, according screenshot of canvas comparing saved output: screen shot of canvas itself: saved output: how fix these issues, preferably somehow using python imaging library? if not possible, is there other way me save canvas jpeg comes out flawless (just screenshot, i.e. colors , no distortions)? appreciat

bit manipulation - C Bit Operation Logic (bitAnd) -

background: stumbled across bitwise operators in c here , , trying learn more them. searched around exercises , came across this . however, i'm having trouble understanding first 1 "bitand." the code reads: /* * bitand - x&y using ~ , | * example: bitand(6, 5) = 4 * legal ops: ~ | * max ops: 8 * rating: 1 */ int bitand(int x, int y) { /* nor equivelent of , */ return ~(~x | ~y); } question: now, thought pipe ( | ) means "or." so, why need ~x , ~y? can't like: int bitand(int x, int y) { int or = x | y; //something 1 number or other int , = ~or; // not or same , return and; } i wrote , ran second code sample myself (i have main function run it). -8 answer, values 6 , 5, should 4. if have "or" (the pipe operator) , "and" opposite or, why need use "~" on each value before calculate ~and? some information/thoughts: understand "~" flips bits in value. "or&q

line breaks - Any HTML entity would remove space? -

due change line lead space between characters. i'm using wbr stop creating space between charaters, this: <p><wbr ></wbr>这里有一段很长,<wbr ></wbr>很长的文字;这里<wbr ></wbr>有一段很长,很长<wbr ></wbr>的文字;这里有一<wbr ></wbr>段很长,很长的文<wbr ></wbr>å­—;</p> i wonder if there better solution? maybe... there html entity remove front space? html entities used represent reserved characters angle brackets. one objective of web development separate style structure presentation. that's why problem must solved javascript, not html. to it, select element dom , use replace method. replace instances of whitespace following var wbr = document.getelementsbytagname("wbr"); wbr.innerhtml = wbr.innerhtml.replace(/\s/g, ''); to replace leading , trailing whitespace this wbr.innerhtml = wbr.innerhtml.trim();

c# - Two tables one context to save changes -

i have defined 2 tables , initialized necessary data entries in db tables. here userscontext public class userscontext : dbcontext { public userscontext() : base("defaultconnection") { } public dbset<userprofile> userprofiles { get; set; } public dbset<userwork> userworks { get; set; } } after page page redirection call savechanges() instance method of userscontext , don't see changes made in table data @ all. still see data present in variables defined during page redirection in debug view though. my current problem this after user logs in site, check login flag, true, redirect him comment page. flag of user test on true, , login method becomes [httppost] [allowanonymous] [validateantiforgerytoken] public actionresult login(loginmodel model, string returnurl) { if (modelstate.isvalid && websecurity.login(model.username, model.password, persistcookie: model.rememberme))

jquery - How can I make this Image fade-in-fade-out loop continuously within bxslider? -

i've followed tutorial build simple image fader: http://www.mustbebuilt.co.uk/jquery-introduction/building-a-simple-image-fader/ but reason mine not loop infinitely bxslider... after last/third image fades, stops. if add 1 more image (a 4th), it's fine. if remove bxslider call, works. ideas why? here's test page: image fader test page the html: <ul class="rotating-images"> <li><img src="img/girl1.jpg"></li> <li><img src="img/girl2.jpg"></li> <li><img src="img/girl3.jpg"></li> </ul> the js: $(document).ready(function(){ $('.bxslider').bxslider(); }); var fadeduration=2000; var displaytime=4000; var currentindex=1; var nextindex=1; $(document).ready(function() { $('ul.rotating-images li').css({opacity: 0.0}); $("'ul.rotating-images li:nth-child(&qu

c# - Is there a way to do fine grained access control in ASPNET 5 MVC 6 -

the new authorize attribute in aspnet 5 seems cover simple apps course access control fine. how 1 go using 10+ controllers crud operations? correct add policies calls, since there no way pass required claims policies? seems list impossible manage , clutter configureservice method. you can write policies require claims , values; services.addauthorization(options => { options.addpolicy("requireread", policy => policy.requireclaim("documentpermission", "read")); } it depends how model claim values. if have claim value of, example, "crud" indicate user has create, read, update , delete particular claim you're going have write own requirement , handler.

Re-using Android's default click animation -

i've set expandablelistview clickable childs change color when they're clicked on. i'd make instead of instantly changing color, changes animation. i noticed default animation clicking elv (or type of list, suppose) pretty cool (at least in version of os): expands kind of grey color covering entire item instant before going original color. idea using animation change color of clicked child, obvious difference: wouldn't go it's original color. complicated?, if not how can done? if has information animating child color change please let me know well.

emacs - yasnippet does not load automatically when .html file is loaded -

yasnipped has been installed on emacs using elpa/melpa package system. i can confirm it's in ~/.emacs.d/elpa/yasnippet-20160104.129 when load .html file there's no yasnippet menu, expected, please advise. did not add .emacs i think solution might cause problems when comes updating elpa yasnippet package. not idea rename package directories. there couple of things should try first. when have opened html file, try running m-x yas-minor-mode if works, need add call yas-minor-mode in startup hook html-mode. alternatively, can try executing m-x yas-global-mode if works, need put call (yas-global-mode) in init.el file if not work, check value of variables yas-snippets-dirs , yas-installed-snippets-dirs . former normal yas variable lists directories search snippets. latter variable should contain path top level snippets directory in elpa package. former contain "~/.emacs.d/snippets" yas-installed-snippets-dires if yas-installed

python - Flask SQLAlchemy Many to Many Delete Element -

my flask site has suggestions , users. class suggestion(db.model): id = db.column(db.integer, primary_key=true) user_nickname = db.column(db.integer, db.foreignkey('user.nickname')) voters = db.relationship('user', secondary=votes, lazy='dynamic') class user(db.model): id = db.column(db.integer, primary_key = true) suggestions = db.relationship('suggestion', backref='user', lazy='dynamic') votes = db.relationship('suggestion', secondary=votes, lazy='dynamic') i have set many many relationship between 2 such. votes = db.table('votes', db.column('user_id', db.integer, db.foreignkey('user.id')), db.column('suggestion_id', db.integer, db.foreignkey('suggestion.id')) ) when try delete suggestion inside views.py error. the view: @app.route('/_delete_suggestion', methods=['get', 'post']) def delete_suggestion():

elasticsearch - Pod stuck in "Terminating" state -

i had cause restart fluentd-elasticsearch pod nodes. out of 7 nodes pods deleted 1 of them deleted , came "running". there way purge pod in k8s? fluentd-elasticsearch pods static pods created via placing pod manifest files ( fluentd-es.yaml ) in directory watched kubelet. corresponding pod (a.k.a. mirror pod ) same name , namespace in api server created automatically purpose of introspection -- reflects status of static pod. kubernetes treats static pod (the pod manifest file) in directory source of truth; operations (deletion/update, etc) on mirror pod not have effect on static pod. you encouraged move away static pods , use daemonset , except few particular use cases (e.g., standalone kubelets). system add-on pods such fluentd-elasticsearch converted daemonset eventually.

swift - Closing iAD Banner causes the current scene to change -

i implemented iad , shows banner on bottom of screen. call function, showsad() in menu class , gamescene class show banner. gamescene gameplay happens. if click on iad banner in gamescene , automatically switches scene menu reason. online resources, code used show iad banner , in gameviewcontorller : class gameviewcontroller: uiviewcontroller, adbannerviewdelegate { var sh = uiscreen.mainscreen().bounds.height let transition = sktransition.fadewithduration(1) var uiiad: adbannerview = adbannerview() override func viewwilllayoutsubviews() { super.viewwilllayoutsubviews() nsnotificationcenter.defaultcenter().addobserver(self, selector: "hidebannerad", name: "hideadsid", object: nil) nsnotificationcenter.defaultcenter().addobserver(self, selector: "showbannerad", name: "showadsid", object: nil) self.uiiad.hidden = true self.uiiad.alpha = 0 } override func viewwillappear(animated: bool) { let bv

php - How to connect (route) Angular with Slim Framework API? -

i cannot populate json data in controller service. i bit stuck how connect them. service works fine when called generating json. controller works when used repository. omitted code in order save space. the problem lies in controller, don't know what. appreciate enlightenment. angular controller (root/app/user.controller.js) (function() { angular .module('app') .controller('usercontroller', usercontroller); function usercontroller($http) { var = this; $http({ method: 'get', url: '/api/users' }).success(function(data) { that.users = data; }); } })(); php service (root/api/index.php) <?php require 'vendor/autoload.php'; $app = new \slim\app; $app->get('/users', 'getusers'); $app->run(); function getusers() { $sql = "select * users order id"; try { $db = getconnection();

jquery - form not flagging errors on eachstep & running php code when submitted -

when fields correctit gives msg doesn't run thephp code associated isset how flag errors when next btn clicked before displaying next step/form <div class="idealsteps-container"> <nav class="idealsteps-nav"></nav> <form class="idealforms" novalidate autocomplete="off" action="/" method="post"> <div class="idealsteps-wrap"> <!-- step 1 --> <section class="idealsteps-step"> <div class="field"> <label class="main">book name:</label> <input name="bookname" type="text" > <span class="error"></span> </div> <div class="field buttons"> <label class="main">&nbsp;</label> <button type="button" class="next">next &raquo;</button> </div> </section> <!-- step 2--> <section c

python - Unirest for Java -

i have python script, post data server url below. want achieve using unirest java. how add parameter/header values unirest post request in java python script: url = 'http://??????????????????/savetimeseriesdata' params = {'clientid': 'admin', 'tenantid': '075841cb-d7fa-4890-84ea-fdd7d7c65b65', 'destinationid': 'timeseries','content-type': 'application/json','content':json.dumps(htlt_data.__dict__)} try: response= requests.post(url, params=params, proxies=proxies) print response except exception x: print x the server endpoint code : @requestmapping(value = "/savetimeseriesdata", method = requestmethod.post) public @responsebody string savemachinedata( @requestheader(value = "authorization", required = false) string authorization, @requestparam("clientid") string clientid, @requestparam(&

javascript - formatting a json object -

im trying use json store values page , access these values/variables later in php file. thing i'm new json , javascript in general , im struggling hours find solution problem might stupidly simple guys have experience in this: have this: var invoice_data = { "client":[ { "client-name" : "", "client-address" : "", "client-address-2" : "", "client-city-state" : "", "client-country" : "" } ], "shoppingcart":[ { "1" : {"item-name":"", "qty":"", "price":"", "discount":"", "subtotal":""} } ], }; so inheritance thing im not getting. i've created "client" object im creating "shoppingcart", thing when user orders more item there should created sub-object store it's details too.so im assumi

ios - How do I change build settings of an Xcode project that is a git submodule -

i have xcode project ios app uses project, rest kit, git submodule. i want effect change in build settings of restkit, reason, when build debug build @ no other time. don't want modify build settings because may 1 app need make change for. , change made appear changed file in git.

php - htaccess RewriteRule doesn't work properly if no trailing slash -

i trying redirect 1 subdirectory using rewriterule in main directory's .htaccess file. for example: http://website.com/subdir should rewrite http://website.com/another_dir/destination_dir user should still see http://website.com/subdir in address bar. this works if user ends url trailing slash. example: http://website.com/subdir/ (generates 200 however, if slash omitted, 301 redirect generated , see undesired destination directory. example, http://website/subdir redirects user http://website/another_dir/destination_dir here pertinent parts of .htaccess: # url rewriting: rewriteengine on rewritebase / ... # redirect subdirectories: rewriterule ^subdir(.*)$ another_dir/destination_dir$1 [pt,nc,qsa,l] any assistance appreciated! you can adjust regex in rewrite rule optionally match slash. rewriterule ^subdir(/?.*)$ another_dir/destination_dir$1 [pt,nc,qsa,l] note /? after subdir . says there may or may not slash after subdir, regex match either w

How to take for loop output to separate array in Java? -

i need take following code output separate array use calculation. in example output is, z count is= 1 y count is= 3 x count is= 2. i need take 1, 3, 2 separate array. how it? new java. import java.util.arraylist; import java.util.hashmap; import java.util.map; public class forarrays { public static void main(string[] args) { arraylist<string> name = new arraylist<string>(); hashmap<string, integer> termfreqmap = new hashmap<string, integer>(); arraylist<string> words = new arraylist<string>(); hashmap<string, integer> wordfreqmap = new hashmap<string, integer>(); name.add("x"); name.add("y x"); name.add("y z y"); // count words (int j = 0; j < name.siz

ios - Subclassing PFUser does not effect the data stored -

i using swift. this question talks parse service. i've read ways using both @nsmanaged , dynamic key-words, decided example implement them both. issue here in user object of data manager, i'm noticing additional information not being stored in database. application store additional information in user table, such first , last name. here's example: import parse public class user : pfuser { @nsmanaged public var firstname: string! dynamic public var lastname: string! override public class func initialize() { struct static { static var oncetoken : dispatch_once_t = 0 } dispatch_once(&static.oncetoken) { self.registersubclass() } } init(email: string, password: string) { super.init(); self.username = email; self.email = email; self.password = password; self.firstname = "myfirstname"; self.lastname = "mylastname";

php - pull from session user info -

ok have user login uses email address , password when login want pull there session data like username , else there record i use <?php if(isset($_session['email'])) { echo $_session['email']; } ?> it works , pulls there email address how there username? tried changing email username , nothing shows my login setup /* login functions */ function login_user($email, $password, $remember) { $sql = "select user_pwd, uid users user_email = '" . escape($email) . "' , active = 1"; $result = query($sql); if (row_count($result) == 1) { $row = fetch_array($result); $db_password = $row['user_pwd']; if (password_verify($password, $db_password)) { if ($remember == "on") { setcookie("email", $email, time() + 86400,&

Android set image from URI on ImageView -

updated more code i trying grab picture taken , set imageview programmatically. the picture button pressed, picture_button.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { takephoto(mtextureview); } }); it runs takephoto method: public void takephoto(view view) { try { mimagefile = createimagefile(); final imageview latest_picture = (imageview) findviewbyid(r.id.latest_picture); final relativelayout latest_picture_container = (relativelayout) findviewbyid(r.id.latest_picture_container); final string mimagefilelocationnew = mimagefilelocation.replacefirst("^/", ""); toast.maketext(getapplicationcontext(), "" + mimagefile, toast.length_short).show(); uri uri = uri.fromfile(mimagefile); toast.maketext(getapplicationcontext(), ""+uri, toast.length_long).show(); latest_picture.setimageuri(uri); latest_picture_containe

c# - How can I put these points (x,y) in order? -

i have a* algorithm implemented, find way between 2 coordinates, , works (pretty much). after that, need show circle, going step step through path problem is, order coordinates added list, (then) show them, based on x, y; and, sometimes, has change directions, like: left, left, left, up, up, up, left, left, down, down, left, up, up, up. i have tried order them x, y, ascending , descending , vice versa, but, because of direction changes, not work circle go step step. so, had idea, not sure, on how it: first: create list, , set ids each point. second: make initial point path made, id 0 third: add other coords: private async void showanimation(int size) { int idofmap = 0; int xplus = 1; int yplus = 1; mapa = new mapa(); list<mapa> resultmap = new list<mapa>(); foreach (mapa camino in mapa.mapacamino) { if (camino.x == initialstore_x && camino.y == initialstore_y) {

How to make JsonArray cache in android -

i need store jsonarray retrived server store in cache.i tried several method;but not creating cache file.my code given below public class makecache { public void vehiclecache(){ string json_url = "http://domainname.com/api/vehicle"; jsonarrayrequest jsonobjectrequest=new jsonarrayrequest(json_url,new response.listener<jsonarray>(){ @override public void onresponse(jsonarray response) { log.d("vehicles", response.tostring()); try { objectoutput out = new objectoutputstream(new fileoutputstream(new file(g.context.getcachedir(), "") + "lpavehicle.srl")); out.writeobject(response); out.close(); }catch (ioexception ex){ log.d("file",ex.getmessage()); } } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { volleylog

c++ - A function that returns a pointer to a class -

suppose have class called myclass, i'm writing function should return object of type myclass. object exists before calling function. do: myclass function() { return myclassinstance; } but remembered pointers , references , think doing create new copy of myclassinstance , return it, waste of memory. thought, why not this: myclass * function() { return &myclassinstance; } so result accessed as, myclass * object; object = function(); object->"class member"... is correct? you surely can that. run ok. has no problems aspect of syntax. need take care there more 1 pointers pointing object. may bring hidden problems.

javascript - What is difference between these two statements? -

this question has answer here: javascript closure inside loops – simple practical example 31 answers var tr = document.getelementsbytagname('tr'); tr[0].onmouseover = function(){ tr[0].style.backgroundcolor = '#ccc'; } tr[1].onmouseover = function(){ tr[1].style.backgroundcolor = '#ccc'; } tr[2].onmouseover = function(){ tr[2].style.backgroundcolor = '#ccc'; } the first right, when use for loop in following code snippet, " uncaught typeerror: cannot read property 'style' of undefined ". var tr = document.getelementsbytagname('tr'); for(var i=0;i<tr.length;i++){ tr[i].onmouseover = function(){ tr[i].style.backgroundcolor = '#ccc'; } } yo

android - Creating Pie chart / progressbar like arc in andorid -

Image
i working on project want show pie chart image added. have searched google , other posts in stackoverflow, not find solution. solution appreciated. note: suggestions of third-party library welcome. please not suggest mpandroidchart think query can implemented using simpler method. you can use library https://github.com/philjay/mpandroidchart achieve this. add below in xml: <com.github.mikephil.charting.charts.piechart android:id="@+id/chart" android:layout_width="match_parent" android:layout_height="match_parent" /> in java code: piechart chart = (piechart) findviewbyid(r.id.chart); example code: https://github.com/philjay/mpandroidchart/blob/master/mpchartexample/src/com/xxmassdeveloper/mpchartexample/piechartactivity.java there lot of variances available. another library consider is: https://github.com/lecho/hellocharts-android

java - junit.framework.AssertionFailedError: Import failed: File accessed outside allowed roots -

a junit test runs fine on local os x, there error "allowed roots" in jenkins. i've tried chmod -r 777 *, did not help. question: there flag can pass junit explicitly specify allowed roots? 1) testexcludes1(com.twitter.intellij.pants.integration.osspantsscalaexamplesintegrationtest) junit.framework.assertionfailederror: import failed: file accessed outside allowed roots: file:///export/hdb3/jenkins/workspace/intellij_plugin_ci_trigger@2/.cache/pants/pants; allowed roots: [/export/hdb3/jenkins/workspace/intellij_plugin_ci_trigger@2/.pants.d/intellij/plugins-sandbox/test, /tmp/unittest_excludes1_569/testexcludes10, /var/lib/jenkins, /export/hdb3/jenkins/workspace/intellij_plugin_ci_trigger@2/.pants.d/resources/services, /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91.x86_64/jre, /tmp] turns out virtualfile system access issue intellij. answer found @ https://youtrack.jetbrains.com/issue/idea-129297#

javascript - Using jQuery noty within CodeIgniter view for flashdata (page reload) -

i have been searching ages no avail. trying use jquery noty in order give failure notifications (instead of standard bootstrap notifications have been using). cannot life of me how supposed work. want notification appear based on there being error in flashdata... i still in learning stages of javascript / jquery dumb newbie mistake, appreciate assistance can rendered! controller: elseif ($usr_result['status'] == false) { $this->session->set_flashdata('flasherror', 'user not active, please contact administrator'); redirect('account/login'); } view: <?if($this->session->flashdata('flasherror')):?> <script type="text/javascript"> $.noty.defaults.killer = true; noty({ text: '<?=$this->session->flashdata('flasherror')?>', layout: 'top', type: 'error', closebutton: ['true']});

asp.net - un able to get the value of template field text box in a custom method in update event in grid view -

i trying value of txtcustomername textbox (template field) in code behind, when run code,i getting null reference exception aspx code <asp:templatefield headertext="customer name" > <itemtemplate> <asp:label id="lblcusomername" runat="server" text='<%#databinder.eval(container.dataitem, "customername") %>'></asp:label> </itemtemplate> <edititemtemplate> <asp:textbox id="txtcustomername" runat="server" text='<%#eval("customername")%>'></asp:textbox> </edititemtemplate> </asp:templatefield> protected voi

delphi - Convolve function: Apply different radius in Gaussian filter -

there convolve function in swissdelphicenter.ch , set kernel , resulting image blurred, there no parameter apply more blur unless call function multiple times (not desired coz of performance issue). how apply more blur image radius parameter in photoshop gaussian filter? i using kernel apply gaussian filter: 1    2    1 2    4    2 1    2    1 you can make larger gaussian kernel - 5x5, 7x7 etc. performance decrease proportional size^2. kernel size faster use approach fft-based convolution. edit fft-based convolution: have data array a, array kernel values k (same length, zero-padded). conv(a, k) = backfft (fft(a) * fft(k)) to make convolution, 1 can find fourier transform of data find fourier transform of kernel multiply them element-by-element (note numbers complex) make inverse fourier transform of product real part of look @ fast convolution algorithms section in wiki , part 13.1 of numerical recipes (almost practical manual) if interesting in f

Drupal 7 Search API, Elasticsearch Connector, Aggregation/Facets -

Image
i using search api , elasticsearch connector in drupal 7 site. have hosted elasticsearch in aws. searching works without issues. add facetapi filters in drupal.org search result page. it seems facetapi removed elasticsearch , added support aggregation. https://www.elastic.co/guide/en/elasticsearch/reference/2.1/breaking_20_removed_features.html#_facets_have_been_removed https://www.elastic.co/guide/en/elasticsearch/reference/1.3/search-aggregations.html but aggregation not supported. https://www.drupal.org/node/2643822 https://www.drupal.org/node/2503343 any suggestion or idea how can achieve this? there other way or missing here? yeah. use https://www.drupal.org/project/elasticsearch_connector and use elasticsearch version 1.x. elasticsearch 2.x in dev.

ios - How to switch custom in-app keyboards -

Image
recently i learned make custom in-app keyboards . want able swap between multiple custom keyboards. however, resetting textfield.inputview property not seem work. i recreated simplified version of problem in following project. uiview s represent actual custom keyboards. import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var textfield: uitextfield! override func viewdidload() { super.viewdidload() let blueinputview = uiview(frame: cgrect(x: 0, y: 0, width: 0, height: 300)) blueinputview.backgroundcolor = uicolor.bluecolor() textfield.inputview = blueinputview textfield.becomefirstresponder() } @ibaction func changeinputviewbuttontapped(sender: uibutton) { let yellowinputview = uiview(frame: cgrect(x: 0, y: 0, width: 0, height: 300)) yellowinputview.backgroundcolor = uicolor.yellowcolor() // doesn't cause view switch textfield.inputview = yellowinputview }

c# - How to stream reads in Couchbase -

i want stream set of documents query in couchbase using single query. problem return a couple of million of documents , want them gradually couchbase, light processing , write result file stream, saving me loading whole result set memory. know if possible in couchbase? edit: sorry, forgot i'm trying in c# currently, way directly use paging on query retrieve results in chunks. comes obvious downside of result set (potentially) changing between page retrievals, if have other process continues change data in background. in c# (typing memory, apologies if doesn't compile straightaway): var pagesize = 100; var pageindex = 0 iqueryresult<dynamic> result = null; { var query = string.format("select mybucket.* mybucket limit {0} offset {1}", pagesize, pageindex); result = await bucket.queryasync<dynamic>(query); pageindex += result.rows != null ? result.rows.count : 0; } while(result.success && result.rows.count > 0); you

jquery - How to hide and toggle content -

how can hide content without disturbing rest of content in jquery? need toggle also? .css{visibility:hidden} doesn't me toggle. you can toggle element p or particular class or id. <script> $(document).ready(function(){ $("button").click(function(){ $("your_element_neme").toggle(); }); }); </script>

android - Apache httpClient.execute() NoSuchMethodError - project builds ok, but this happens at runtime? -

Image
a few days ago moved eclipse project 1 folder , set dependencies again. the project builds , app runs until gets piece of code: httpresponse httpresponse = httpclient.execute(httppost); where error: caused by: java.lang.nosuchmethoderror: org.apache.http.impl.client.defaulthttpclient.execute in libs folder have these jars: httpclient-4.3.5.jar httpcore-4.3.2.jar httpmime-4.3.5.jar and here how order , export looks like: and libraries tab edit: thing tried downloading lastest httpcore, httpclient , httpmime , replacing jars in libs folder and added them add external jars in libraries tab of configure build path i resolved problem downgrading versions 4.1 or httpcore, httpclient , httpmime.

Powershell / PowerCLI - Need more efficient method of inserting dynamic information into SQL -

i've used stackoverflow years, today first time i've felt need ask question. know if following code made more efficient, because i'm writing multiple copies of script, entering different sql tables. what does: querys vmware, outputs $data truncates sql table inserts $data dbo.t_vm_guest_details inserts dbo.t_vm_guest_details dbo.t_vm_guest_details_history ideas efficiency: just above foreach ($line in $data), possible include "foreach column in $data" dynamically build 'standard' sql insert query, based on count of columns, names & values. or there easier way insert $data sql table elsewhere , i'm making difficult myself? keeping sql table column names same powershell output should help? the following block fills $data list of vms (powercli): $data = @() $allvms = get-vm | select * $entry = @() foreach ($vm in $allvms) {