Posts

Showing posts from January, 2015

python - In TensorFlow is there any way to just initialize uninitialised variables? -

the standard way of initializing variables in tensorflow is init = tf.initialize_all_variables() sess = tf.session() sess.run(init) after running learning while create new set of variables once initialize them resets existing variables. @ moment way around save variable need , reapply them after tf.initalize_all_variables call. works bit ugly , clunky. cannot find in docs... does know of way initialize uninitialized variables? there no elegant* way enumerate uninitialized variables in graph. however, if have access new variable objects—let's call them v_6 , v_7 , , v_8 —you can selectively initialize them using tf.initialize_variables() : init_new_vars_op = tf.initialize_variables([v_6, v_7, v_8]) sess.run(init_new_vars_op) * a process of trial , error used identify uninitialized variables, follows: uninitialized_vars = [] var in tf.all_variables(): try: sess.run(var) except tf.errors.failedpreconditionerror: uninitialized_vars.a

amazon web services - Monitoring Datomic in CloudWatch without CloudFormation -

i'm trying monitor datomic transactor in cloudwatch. according documentation (section "using s3 log storage , cloudwatch metrics other storages") should able setting couple config variables , making sure instance launched appropriate iam policy. i set appropriate configs in transactor.properties file pass transactor when starts: aws-cloudwatch-region=us-east-1 aws-cloudwatch-dimension-value=transactor-staging and set instance iam role called datomic policy contains: { "version": "2012-10-17", "statement": [{"resource":"*", "effect":"allow", "action": ["cloudwatch:putmetricdata", "cloudwatch:putmetricdatabatch"], "condition":{"bool":{"aws:securetransport":"true"}}}]} but when in cloudwatch can't find metrics associated datomic or transactor. when run transactor don't see error messages

Rails + Show Dynamic content with backbone.js -

i'm making api call using backbone model returns json list of posts. each post dynamic can be 1. liked or unliked 2. commented or not commented 3. shared public or private or a group now in backbone template while displaying posts, i'm doing if else conditions display dynamic content. <% if(jsonresponse["like"] == true){ *> <a href="/posts/1/like">like</a> <%} else %> <a href="/posts/1/like">unlike</a> <% } %> <% if(jsonresponse.target == 'public'){ *> <a href="#">public</a> <%} else if(jsonresponse.target == 'private'){%> <a href="#">private</a> <% } else if(jsonresponse.target == 'groups'){%> <a href="#"><%= post.target.shared[0].displayname %></a> <% } %> is how should display dynamic content? checking conditions in template right way it? i know

is there any way for multiple where statement in Haskell -

i tried write 3-4 statement in 1 function error , couldnt , tried : foo x= | x == foo1 = 5 | x == foo2 =3 | x == foo3 =1 | otherwise =2 foo1= samplefunct1 x foo2= samplefunct2 x foo3= samplefunct3 x i know code bit useless wrote give example mean. is there can me ? in advance. remove = after foo x , indent code like foo x | x == foo1 = 5 | x == foo2 =3 | x == foo3 =1 | otherwise =2 foo1 = samplefunct1 x foo2 = samplefunct2 x foo3 = samplefunct3 x and you're fine.

c# - Should I use additional container in my MVVM project? -

Image
source sample project: https://github.com/antwanreno/navi i did project in wpf mvvm. has 3 sub-projects: wpf app, viewmodels (pcl) , domain (pcl). wpf single window single frame , 2 pages . present code, recommend clone/fork prepared sample in repo. here code wpf client: app.xaml.cs namespace naviwpfapp { using system.windows; using naviwpfapp.views; using naviwpfapp.views.pages; public partial class app : application { public static navigationservice navigation; protected override void onstartup(startupeventargs e) { base.onstartup(e); mainwindow mainwindow = new mainwindow(); mainwindow.show(); navigation = new navigationservice(mainwindow.myframe); navigation.navigate<firstpage>(); } } } app.xaml it's just: <application x:class="naviwpfapp.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/p

ios - Duplicate definition of category 'my_framework' on interface 'NSObject' -

i in process of updating app , common library (dynamic framework). once static library xcode subproject, dynamic framework contains swift code. when writing app's code, i'm seeing compiler warnings. @ time, they're warnings. in app's mainviewcontroller include file that's written in swift. , has import of app-swift.h. inside of autogenerated app-swift.h, there section: #if defined(__has_feature) && __has_feature(modules) @import uikit; @import my_framework; #endif inside of 'my_framework' have category method on various files, e.g. nsobject+my_framework.h now, i'm getting compiler warning mainviewcontroller.m saying "duplicate definition of category 'my_framework' on interface 'nsobject'". drop down supplies locations of both definitions. 1 location actual category header file inside of framework. compiler 'sees' location via being included through pch file. other location links directly app

ios - What's happen if control UI by performSelectorInBackground? -

i read informations ui interface update on mainthread. i need asynchronous update uibutton s, use performselectorinbackground , it's work fine on simulator , device (ipad4). [self performselectorinbackground:@selector(toggletoupperwhensingleshift) withobject:nil]; - (void)toggletoupperwhensingleshift{ shiftstateindicator = 1; (uiview *apad in self.subviews) { if ( [apad iskindofclass:[uibutton class]] ) { uibutton *abutpad = (uibutton *)apad; nsmutablestring *currenttitle = [nsmutablestring stringwithstring:[abutpad titleforstate:uicontrolstatenormal]]; nsstring *firstchar = [currenttitle substringtoindex:1]; [currenttitle replacecharactersinrange:nsmakerange(0, 1) withstring:[firstchar uppercasestring]]; [abutpad settitle:currenttitle forstate:uicontrolstatenormal]; [abutpad settitle:currenttitle forstate:uicontrolstatehighlighted]; currenttitle = [nsmutablestring stringw

nlp - replace conjunctions from a txt file by end of line java -

hey need code replace occurrence of conjunctions in txt file end of line. have list of conjunctions saved in txt file.i want both input file taken , conjunctions file stored in array form.then using loop wanted compare both arrays .but gives many errors.is there better way same? tried doing, shows error in loop import java.util.list; import java.util.scanner; import java.util.logging.level; import java.util.logging.logger; import javax.swing.jfilechooser; public class toarray { private static object arrays; public static void main(string args[]) throws filenotfoundexception { string filename,path; system.out.println("select input file"); jfilechooser chooser = new jfilechooser(); chooser.showopendialog(null); file file1 = chooser.getselectedfile(); chooser.showopendialog(null); filename = file1.getname(); path= file1.getpath();

knockout.js - jquery mobile a link can not work while using knockoutjs data-bind -

i write link jquery mobile like: < href="#detail" /> it work first time. then modify use ko bind,like: < href="#detail" data-bind="click:newadvice"> it can not chagepage, not know why?who can me? try set link data-bind click: <a data-bind="click: showhomepage" data-role="button">homepage</a> this javascript: self.showhomepage= function () { $.mobile.changepage("#homepage", { transition: "slide" }); return false; }; and html homepage is: <div data-role="page" id="dashboard"> ... </div>

c# - How to bind a collection to a ListView in WPF -

i have program searches directory files matching criteria. search process takes long time, have call asynchronously. when search algorithm finds file, triggers event. mainwindow instance listens event , needs update gui. how can bind these "added" files listview ? figured use observablecollection<fileinfo> instance, can't figure out how bind it. i've stripped out of irrelevant controls , code. here 2 relevant files. mainwindow.xaml: <window x:class="example.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="cr search" height="395" width="525"> <grid> <listview x:name="results"> <listview.view> <gridview> <gridviewcolumn header="filename"/> <gr

.net - Where's the ValueType stored when CLR initialize the data structure to store them -

i know value type instances stored in stack , reference type instances stored in heap. but, after clr ensure assemblies define type have loaded, create data structures store type object, reference type object stored in heap, where's value type objects stored? the type objects different types reference types, i.e. type class, stored on heap. note value types stored on stack if local variables in method. if members of class, stored on heap part of instance of class.

words - Replace new lines with a comma delimiter with Notepad++? -

i have notepad++ question. how can take below words in notepad++ (which on different lines) apples apricots pear avocados bananas and turn them paragraph comma @ end of each one? this: apples, apricots, pear, avocados, bananas open find , replace dialog (press ctrl + h ). then select regular expression in 'search mode' section @ bottom. in find what field enter this: [\r\n]+ in replace with : ,  there space after comma. this replace lines like apples apricots pear avocados bananas where there empty lines. if lines have trailing blank spaces should remove first. simplest way achieve is edit -> blank operations -> trim trailing space or textfx -> textfx edit -> trim trailing spaces be sure set search mode "regular expression".

php - Delete All Between ( and ) -

i want replace between ( , ) . , works preg_replace(). $return = preg_replace("/\([^)]+\)/", "", $return); if $return "hello name frank (nicer guy)" the string "hello name frank" but in case between parentheses next parentheses not work. example: before: "hello name frank (nicer (guy) thank you)" after "hello name frank thank you)" it stops after first ")". possible deletes parentheses inside parentheses? match beginning first ( , backtrack last occurrence of ) : \(.*\) note: * must greedy work. make sure ungreedy modifier u not set (default). if strings can contain multiple occurrences of independent parenthesized substrings, i.e. "hello (my name is) frank (nicer (guy) thank you)" , need recursive pattern . the example \(((?>[^()]+)|(?r))*\) there works quite well.

python - Serialization optimization using Marshmallow, other solutions -

this seems should straightforward, alas: i have following sqlalchemy query object: all = db.session.query(label('sid', distinct(clinical.patient_sid))).all() with desired serialize output [{'sid': 1}, {'sid': 2},...] to this, trying use following simple marshmallow schema: class testschema(schema): sid = fields.int() however, when schema = testschema() result = schema.dump(record) print result pprint(result.data) i get: marshalresult(data={}, errors={}) {} for output. however, when select 1 row query, e.g., one_record = db.session.query(label('sid', distinct(clinical.patient_sid))).first() i desired results: marshalresult(data={u'sid': 1}, errors={}) {u'sid': 1} i know query .all() returning data, since when print list of tuples: [(1l,), (2l,), (3l,), ...] i assuming marshmallow can handle list of tuples, since, in documentation marshaling.py under serialize method, says: "takes raw data (a

ios - dropbox linkFromController detect cancel -

i upgraded dropbox framework in app , have use linkfromcontroller. there way detect if user tap on cancel button or if dropbox auth popup visible or not? thanks, max you can use following delegate filter loading url. find url load in cancel button , use complete task. - (bool)webview:(uiwebview*)webview shouldstartloadwithrequest:(nsurlrequest*)request navigationtype:(uiwebviewnavigationtype)navigationtype { nsstring *url = [[request url] absolutestring]; if([url isequaltostring:@"cancel url"]){ //do want return no; } }

android - Vertical scrolling in calendar -

i trying create calender android 4.x devices in dates should displayed in cell , month name @ top. ever user scroll , down should change month (in short implement functionality of changing month up/down scrolling). i have seen same type of calendar control in htc devices. any 1 has idea how implement this? i think use viewpager in case, in fact, vertical scrolling. should try using directionalviewpager - written jakewharton

c# - How to change the background color of Status Bar in WP8 silverlight? -

Image
is there way change background color of status bar in windows phone 8 silverlight application? it quite easy that, i'm not sure if reflected in emulator (better try on real device). open xaml of page want change status bar , change these properties way want them be: shell:systemtray.isvisible="true" shell:systemtray.backgroundcolor="#2440b2" shell:systemtray.foregroundcolor="white" the *.isvisible property ensures status bar visible, *.backgroundcolor setting correct background of status bar , *.foregroundcolor changes color of text , icons.

Can not reference class in java -

class myclass { int value; } public myclass test(){ myclass mc; mymethod(mc, 100); if (mc!=null) { mc = mc.value; return mc; } return mc; } public int mymethod(myclass mc, int a) { mc.value = + 10; return mc; } i want make mc reference. if objective-c similar this: public myclass test(){ myclass *mc; mymethod(&mc, 100); } please me. answer appreciate. thank in advanced. in java use reference variables instead of pointers. see this , this class myclass { int value; /*all methods have belong class*/ public myclass test() { /*myclass mc; don't need pass assign value value assigned data members of object(reference variable) calls function*/ myclass mc = mymethod(100); return mc; } public myclass mymethod(int a) { value = + 10; return this; //this 'this' return current object } }

passing array from bash script to R Vector with a single argument -

i trying pass argument r script stored vector. have this: script.sh mylist="1,1,1,1,2,2,2,2" rscript ./script.r $mylist script.r args <- commandargs(trailingonly = true) myvector <- args[1] myvector[1] myvector[5] the output i'm hoping is "1" "2" but instead i'm getting [1] "1,1,1,1,2,2,2,2" [1] na thanks in advance. it's because mylist single string, not vector of strings/numbers. try: myvector <- unlist(strsplit(args[1],","))

javascript - How to make onClick do the same thing as Hover on <li> tag -

i have css image gallery 3 tabs , images displayed while hovering on thumbnails in each tab. check snippet or webpage http://www.abavela.com/en/charter-sailing-yacht-bavaria-36-1.htm problem when click on thumbnail browser loads jpg , displayed in gallery hover event does. problematic on touch screens. onclick event "li" tag same thing hover event. i guess can not done css alone need javascript code. tried active, focus, target in css , bunch of options in javascript no real success. any welcomed. a { color: #000; } a:hover { text-decoration: none; } a:visited { color: #000; } .photo { width: 744px; position: relative; height: 534px; float: left; /* [disabled]margin-bottom: -10px; */ } .photo ul.topic { padding: 0; margin: 0; list-style: none; width: 744px; height: 30px; position: relative; z-index: 10; } .photo ul.topic li { display: block; width: 247px; height: 30px; float: left; } .photo

How to add search functionality in Android? -

i want use search function in android application in trying access data web services , have used custom arrayadapter , have added action , meta tag in manifest not able use in activity. little bit confused, please help. my code: @override public boolean onoptionsitemselected(menuitem item) { // handle item selection switch (item.getitemid()) { case r.id.search: intent intent = getintent(); if (intent.action_search.equals(intent.getaction())) { string query = intent.getstringextra(searchmanager.query); domysearch(query); //how function or right approach? } break; thanks time.

css - Bootstrap Full page columns -

i want have 2 columns fills every time full page size unattached given content. the problem solutions work until began scroll page. example html,body { height: 100%; min-height: 100%; } .left-content { background: red; } .right-content { background: green; } .container-fluid { height: 100%; } .row { height: 100%; } [class^="col-"] { height: 100%; } <link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/> <div class="container-fluid"> <div class="row"> <div class="col-sm-6 left-content"> left column </div> <div class="col-sm-6 right-content"> right column </div> </div> </div> anyone have solution problem?! how adding col-xs-6 accommodates small screens well: html,body { height: 100%; min-height: 100%

gis - Assign new ol.View.Extent with coordnation points -

i'm new gis concepts might noob question. i'm using openlayers 3 map. want restrict panning specific area. the code came across should don't know values assign minx, miny, maxx, , maxy variables. var view = new ol.view({ center: new ol.proj.transform([-116.284636, 43.619528], 'epsg:4326', 'epsg:3857'), zoom: 11, extent: [minx, miny, maxx, maxy] }); i've gotten coordinates click evt.coordinate variable don't know how correlate parameters of extent. left top '0' => "-12972739.566503541" '1' => "5427487.630417225" right top '0' => "-12913118.684441104" '1' => "5426723.260134374" bottom right '0' => "-12908838.210857134" '1' => "5364962.141279951" bottom left '0' => "-12983440.750463465" '1' => "53677

ruby on rails 3 - removed commits appearing on github commit history -

i understand following command removes previous commits github (^ = ntimes) git push -f origin head^^:master i wanted remove last 2 commits, when make more local changes, git add . git commit -m "example" git push origin master the commits removed appear again? what mean when running git status i your branch ahead of 'origin/master' 2 commits. so 2 previous commits there anything need stop happening thanks answer if runs problem, or if better way let know. anyway ran git reset --soft head^^1 which undone last 2 commits guess, left me date. able run usual git add . git commit -m "message" git push origin master and previous commits not included

css - javascript how to select elements and style it -

may know how build css style parser/evaluator in javascript below: .book { width: calc(200px + 400px); } .book h1 { font-size: 10em; } div.book { color: blue; } .book.green { background: green; } .book[name="hello"] { color: pink; } .book[data-name="hi"], .other-book { color: red; } .book > { text-decoration: none; } .book a:nth-child(2) { color: purple; } document.getelementsbyclassname('box') returns collection. should specify specific index inside square brackets this document.getelementsbyclassname('box')[0].style.width = '100px'; this has difference between classes , ids . there can multiple elements same class name, ids unique. same formula as document.getelementbyid does not work classes, because of difference mentioned above. although, best done through css.

stl - How to implement "dereference and post-increment" for input iterator in C++? -

requirements inputiterator include *i++ equivalent expression being value_type x = *i; ++i; return x; how can 1 declare such operator without implementing standard post-increment i++ returning non-void value (which inputiterators not required do)? you may use proxy post increment: #include <iostream> class input_iterator { private: class post_increment_proxy { public: post_increment_proxy(int value) : value(value) {} int operator * () const { return value; } private: int value; }; public: post_increment_proxy operator ++ (int) { post_increment_proxy result{value}; ++value; return result; } private: int value = 0; }; int main() { input_iterator i; std::cout << *i++ << '\n'; std::cout << *i++ << '\n'; std::cout << *i++ << '\n'; }

node.js - Adding item to cart with BigCommerce Stencil -

this question specific bigcommerce stencil. possible use 'cart-item-add' hook outside of product context? right when user adds product 'product card' sent cart. i'd change behaviour. i able working utils.api.cart.itemadd() the issue add cart form action. in product card needed use {{add_to_cart_url}}" instead of {{product.cart_url}}

sql server - SQL - slow only on first run...can't tell if my changes make it faster or not -

i have sql script made of 3 queries runs on first run inside of sql management studio (about 90 seconds). subsequent runs after take 0-5 seconds. obviously, it's caching it. declare , use few keys , variables @ top, , want know if script modifications making difference in performance, can't if it's faster second time. what can t-sql make not use cached version? ask because want play sql make faster, can't tell if i'm making difference because first time of running script slow. dbcc dropcleanbuffers answer not run in production environment. removes buffer cache , result in slow down cause down time in busy environment. do not confuse dbcc freeproccache , should never run in production. clears out of cached query plans , cause them have go through recompilation. however, can specify plan handle 1 @ time.

python - Flask-Login. Where do I store users for the user_loader function to find them? -

according flask's documentation: user_loader(callback): sets callback reloading user session. function set should take user id (a unicode) , return user object, or none if user not exist. from funciton supposed load user object? user data stored in session, isn't user object, json blob of info user. without storing user objects in global dictionary or something, have no idea how function supposed take user_id , return associate user except creating new user id, , mapping previous data it. i should mention not using database (and if same problem present itself--databases can't store user objects, store data users) because using authentication credentials stored in ldap server. here code: class user(object): def __init__(self, user_id, password, active=true, authenticated=false, anonymous=false): self.user_id = user_id.upper() self.password = password self.active = active self.authenticated = a

knockout.js - Using Arrays inside knockout observable -

i have observable arrays bound html fields on ui. however, changes fields on ui not reflected in viewmodel because per knockout documentation, observablearray tracks objects in array, not state of objects. the code looks below: var rewardmissionmodel = function () { var self = this; self.achievementid = ko.observable(); self.rewardasset = ko.observable(); self.rewards = ko.observablearray([new reward("points", "qty", "", "item", "")]); self.isdirty = false; //add reward self.addreward = function () { //var self = this; var temprewardtype = "points"; self.rewards.push(new reward(temprewardtype, "qty", "", "item", "", 0)); }; //remove reward self.removereward = function (reward) { if (self.rewards().length > 1) self.rewards.remove(reward); }; //---------------------------------------

html - Dynamically change background image using javascript -

i'm looking being able change background of webpage dynamically generated image @ runtime. i'm using javascript , canvas element create backgrounds, i'm storing in array user can toggle between them; images jpegs // canvas computations snipped var img = c.todataurl("image/jpeg"); this.modifiedanimationarray[0] = new image(); this.modifiedanimationarray[0].src = img; however, have noticed javascript manipulate background follows: document.body.style.backgroundimage = "url('whatever.jpg')"; it wants image url, created non-dynamically. there way force document.body.style.backgroundimage accept image created on-the-fly rather loading 1 off domain? todataurl give data url can used in place of regular url. instead of doing say document.body.style.backgroundimage = 'url(someimage.jpg)'; just replace url, in case someimage.jpg , url got todataurl document.body.style.backgroundimage = 'url('+canvas.todataurl(&

deployment - django with gunicron and nginx -

i have developed django application , deploying on freebsd server using gunicron , nginx. have added guncorn in projects settings files under installedapps. , placed gunicorn.conf.py in root as: import os def numcpus(): if not hasattr(os, "sysconf"): raise runtimeerror("no sysconf detected.") return os.sysconf("sc_nprocessors_onln") user = root workers = numcpus() * 2 + 1 bind = "127.0.0.1:8000" pidfile = "/tmp/gunicorn-srv.pid" backlog = 2048 logfile = "/data/logs/gunicorn_srv.log" loglevel = "info" then in nginx.conf updated server tag with: listen 80; server_name localhost; access_log /var/log/nginx/nginx-access.log; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://127.0.0.1:8000; #root /usr/local/www/nginx; #index index.html index.htm; } location /media/ { root /da

What Does 'new' Do In C#? -

here's example of i'm talking about. class car() { int speed = 50; } now imagine in other file, do car truck; how different from car truck = new car(); i've been using c# little on year, still don't this. it's been on , off type of thing. car truck; doesn't do anything. you're saying line of code may or may not have object of type car , , you'll want refer truck . car truck = new car(); declares you've want refer car name truck (just before), also give name actual car object instantiating in place. to continue car analogy (somewhat flawed) concept: car truck; parking spot, car truck = new car(); parking spot built new car in.

osx - Postgres : Change current user to root -

complete database newbie here. installed postgres on laptop run local apps , stuff. fact postgres setup using myname instead of root quite hinderance. way cant replace root ? i open psql this: psql -h localhost myname=# \l list of databases name | owner | encoding | collate | ctype | access privileges --------------+--------------+----------+-------------+-------------+------------------------------- myname | myname | utf8 | en_us.utf-8 | en_us.utf-8 | pixelmanager | myname | utf8 | en_us.utf-8 | en_us.utf-8 | postgres | myname | utf8 | en_us.utf-8 | en_us.utf-8 | template0 | myname | utf8 | en_us.utf-8 | en_us.utf-8 | =c/myname + | | | | | myname=ctc/myname template1 | myname | utf8 | en_us.utf-8 | en_us.utf-8 | =c/myname + | | | |

c# - How do I test for results in a Braintree Customer search? -

var searchreq = new customersearchrequest().email.is(lk.email); var customers = gateway.customer.search(searchreq); var customer = customers.firstitem; when no results, firstitem throws argumentoutofrange exception. can see private field called ids has count 0 "maximumcount" 0. maximumcount dependable? full disclosure: work @ braintree. if have further questions, feel free contact support . the word 'dependable' ambiguous, short answer yes . maximumcount intended return count of entire result set search. result sets of on 100 included in sdk integration tests library . note braintree api has a limit of 10,000 results returned customer search. transaction searches return maximum of 20,000 results; other searches return maximum of 10,000 results.

c++ - Achieving an SFINAE-like effect in an if-else block -

i able write like template <typename t> void foo() { // ... if (is_nice<t>::value) { bar_which_is_defined_only_for_nice_types<t>(); } } however, when try compile (g++ 4.9.3, no optimization) complaint bar_which_is_defined_only_for_nice_types . how can achieve desired effect without resorting 2 definitions of foo() ? you can tag dispatch based on is_nice<t> #include <type_traits> template<typename t> struct is_nice : std::false_type {}; template<> struct is_nice<int> : std::true_type {}; template<typename t> void do_nice_things(std::true_type) { bar_which_is_defined_only_for_nice_types<t>(); } template<typename t> void do_nice_things(std::false_type) { } template <typename t> void foo() { do_nice_things<t>(is_nice<t>{}); }

Android Multipart image upload to Azure -

is there way way upload image android device azure bucket ? try let me know whether work or not public httpresponse request(string filepath, string url) { httpclient httpclient = new defaulthttpclient(); httpclient.getparams() .setparameter(coreprotocolpnames.protocol_version, httpversion.http_1_1); httppost httppost = new httppost(url); multipartentity mpentity = new multipartentity(); file file = new file(filepath); contentbody cbfile = new filebody(file, "image/png"); mpentity.addpart(parameter_signature, cbfile); try { httppost.setentity(mpentity); system.out.println("executing request " + httppost.getrequestline()); httpresponse response; response = httpclient.execute(httppost); httpclient.getconnectionmanager().shutdown(); return response; } catch (exception e) { e.printstacktrace(); } ret

c - epoll and send lag -

i'm using linux 64 bit linux scv 3.2.0-39-generic #62-ubuntu smp thu feb 28 00:28:53 utc 2013 x86_64 x86_64 x86_64 gnu/linux , have 2 processes using sockets run on same physical host. one process ( a ) sends on tcp/ip socket (would local socket given host same) following pieces of data: 276 bytes 16 bytes this done in 0.000023 seconds form process a . data being sent calling 2 times send socket api. another process ( b ), receives data via epoll using epoll_wait(efd, events, 10, 5) . data received follows (time taken clock_gettime(clock_realtime, &cur_ts); , matters relative difference): read data socket buffer @ 8051.177743 (276) call epoll 8051.177763 again read data socket buffer 8051.216250 (16) making receiving process lag of 0.038507 seconds. if sending process a takes less ms , on receiving side epoll receive data adds additional lag of approximately 0.038 s. is expected? doing wrong? or how can improve situation? thanks is

java...based on Collections -

import java.util.arraylist; import java.util.*; class employee1 implements comparable<employee1> { int empno; string name; employee1(int i,string j) { empno=i; name=j; } public int compareto(employee1 e1) { employee1 e2=this; integer i1=e1.empno; integer i2=e2.empno; return i1.compareto(i2); } } public class employee { public static void display(arraylist<employee1> i) { for(employee1 o:i){ system.out.println(o.empno); } } public static void main(string[] args) { arraylist<employee1> ob=new arraylist<employee1>(); employee1 e1=new employee1(1001,"a"); employee1 e2=new employee1(1002,"b"); ob.add(e2); ob.add(e1); collections.sort(ob); display(ob); } } the output should 1001 1002 instead output 1002 1001 . first passed e2 object empno list , e1 empno of 100

How to run commands like sudo grails in ubuntu? -

i'm new ubuntu , i'm trying run grails sudo permission like: sudo grails but i'm getting: sudo: grails: command not found what should do? if executing command inside bin grails folder, need do: sudo ./grails

bash - How to collect the files with specific keyword in their file names within a directory -

i have directory number of files. requirement is, have search file-names(not file data) based on particular keyword , print filename. for example abc directory. below files aexp/inc/arp.txt aexp/opc/arp.txt aexp/inc/pqw.txt i want files contains keyword inc . expected output: aexp/inc/arp.txt aexp/inc/pqw.txt i tried logic, not working properly #!/bin/sh file in abc/* if [[ $file =~ /inc/i ]] echo success; else echo fail; fi done please me right answer. bash script, perl, regex, fine. on linux use "find". on ubuntu shell, looks like: find . -name "*inc*" -print

java - Passing Messages Between Fibers Quasar -

i using quasar fiber listen , process messages on queueobjectchannel . not sure object supposed use message queue between fibers. problem having don't understand supposed passed queueobjectchannel constructor. according javadoc constructor supposed take queueobjectchannel(co.paralleluniverse.strands.queues.basicqueue<message> queue, channels.overflowpolicy policy, boolean singleproducer, boolean singleconsumer) seems counterintuitive because trying build implements basicqueue . am supposed implement interface? is understanding of inter fiber communication off? usually 1 wants (and should) use channels api, not backing queues. example different queue implementations can work and/or optimal data types, threads and/or fibers, specific buffer configuration, when there's single consumer etc. as explained here use static channels.new*channel methods passing in properties need , you'll channel backed queue tailor-suited use case.

ios - UICollectionView Fast Scroll wrong behavior -

Image
i have collectionview fixed cells size, without flowlayout classes. when scroll quickly, cell falls down under previous sometimes!!! any ideas? i once encountered problem , asked once.not answered yet anybody.the workaround did making collectionview height adjust such cell visible properly.made height of uicollectionview +2 pixel height of cell.

Plugin implementation issue with jQuery -

i've been having problem implementing plugin supposed "simple". plugin @ address : http://lab.smashup.it/flip/ i tried testing out simple short code , checked code page plugin displayed make sure doing right, apparently nothing happens , i'm not getting errors feedback don't know direction go towards. here code test ran with: <!doctype html> <html> <head> <meta charset="utf-8"> <title>test#0935</title> <script src="http://www.google.com/jsapi"></script> <script type="text/javascript"> // load jquery google.load("jquery", "1"); </script> <script src="js/jquery-ui-1.7.2.custom.min.js"></script> <script src="js/jquery.flip.min.js"></script> <script type="text/javascript"> $("a&q

ios - Multipeer Connectivity session from Connecting to NotConnected -

i developed simple concept project test multipeer connectivity framework on both os x , ios platform. find each other every time, cannot connected. session state changed connecting notconnected. i have tried on different macbook , ios device, on ios simulators, , same behavior. my source code has been uploaded https://gist.github.com/hcwang/1a62d7a2def4d271d950 . thanks kindly help.

c# - Importing project to xamarin error -

the app dev company hired sent me folder containing of source code app (developed in xamarin). opened .sln file in visual studio (after installing xamarin) find not compile. gives errors "; expected" "unexpected character '$'" "invalid token ')'". these errors seem indicate might missing library or necessary file xamarin compile app. any thoughts? thanks

tomcat - How to load java native library in web container -

i'm migrating java application uses proprietary native library standalone web base, works fine when running @ command line or in eclipse throws unsatisfiedlinkerror when calling native methods inside web container. i have managed load other different native libraries in web application, , neither system.load nor system.loadlibrary throws error. added logs in application after loading each library verify this. i have though issue web container tried use jetty , tomcat, i'm getting same error in both. currently using: - java 1.8.0_72 - jetty 9.3.6 - tomcat 8.0.30 - debian 8 - gcc 4.9.2 to illustrate bit more have 2 native libraries in same directory , both .so files have same permissions. 1 of them throws error while other works, if remove .so file 1 failing got: java.lang.unsatisfiedlinkerror: no proprietary-lib in java.library.path looks there in library web container doesn't like, be?

python - Grouping by many columns in Pandas -

i have dataset looks follows col1 col2 col3 count b 1 50 b 1 50 c 20 1 d 17 2 e 5 70 e 15 20 suppose called data. data.groupby(by=['col1', 'col2', 'col3'], as_index=false, sort=false).sum() , should give me this: col1 col2 col3 count b 1 100 c 20 1 d 17 2 e 5 70 e 15 20 however, returns empty dataset, have columns want no rows. caveat by parameter getting calculated dynamically, instead of fixed (thats because columns might change, although count there). any ideas on why failing, , how fix it? edit: further searching revealed pandas' groupby removes rows have null @ column. problem me because every single column might null. hence, actual question is: reasonable way deal nulls , still use groupby? would love corrected here, i'm not sure if there clean way handle missing data. no

jqGrid - form editing issues -

in inline editing, before editing made, creates internally array ( savedrow ) , fill values of fields being editable, can access values. i'd know if in form editing has similar this, because need access values of fields before editing completed validation before fields "saved" in database. someone me? edited : i'm posting here part of code (the code of 1 field), , i'm trying validate in both way (inline editing , form editing). inline editing i'm validating using dataevents , there i'm using savedrow access data not stored yet. when try edit using form editing because of the use of savedrow, shows me error: savedrow not defined . in case of field editrules fits want do, don't know if occurs in of fields. { name: 'ac_fd', index: 'ac_fd', width: 50, editable: true, formatter: 'number', editrules: { number:true, required:true, minvalue: 0.1, maxvalue: 1.0 }, formatoptions: { decimalplaces: 1, decimalseparato

javascript - React how to update another component's state? -

i pretty new react, trying make components work. have objecta:react.createclass({ proptypes: { ... }, getinitialstate: function() { return { mystate: null } }, updatemystate: function(value) { this.setstate({ mystate: value }) } render: function() { return (<div classname="my-class">'hello' +{this.state.mystate}</div>); } }); objectb:react.createclass({ proptypes: { ... }, render: function() { return (<div classname="my-class"><objecta / > </div>); } }); i'd update objecta's state objectb. how in objectb call objecta's updatemystate method? thanks! the basic idea of react unidirectional data flow. means data shared downw

tomcat6 - net.sf.hibernate.util.JDBCExceptionReporter - Connection org.postgresql.jdbc3g.Jdbc3gConnection is closed -

i facing problem on 1 of production environments. happens quite not @ same segments of application, it's pretty random. the application deployed on environment similar others deployed on different machines, wich used same technologies , close settings, error occurs on 1 it's being difficult trying find out problem. i must these errors have started appear recently, since several update changes: application migrated windows linux postgressql 8.2 9.2 tomcat 5 tomcat 6 all these changes have been done on rest of deployed applications have not experienced problem @ all. the technologies used applications are: hibernate 2.1.6 postgresql 9.2 tomcat 6.0.35 the configuration in context.xml is: <resource name="jdbc/psa" auth="container" type="javax.sql.datasource" driverclassname="org.postgresql.driver" url="jdbc:postgresql://localhost:5432/psa?compatible=7.4" username="xxx" passwor