Posts

Showing posts from March, 2013

matlab - Using meshgrid to interpolate image's physical coordinates -

i new matlab , simulating physical phenomena requires physical coordinates of image. example can use following give dimensions of image. a = phantom(80,250) a(81:250,:) = []; for physical system, need spacing 2 between each pixel , object go 0:2:280 in x , 0:2:410 in y. trying use meshgrid see if case starting [x,y] = meshgrid(1:1:100, 1:1:300); [xm,ym] = meshgrid(1:.5:300, 1:.5:450); m = interp2(x,y,a,xm,ym,'nearest'); this not give me want how think can potentially achieve solution. my basic problem have image size (80,250) , need sample/scale can correlate point on top right location (280mm,410mm) sample of 2mm between each pixel. right approach or should use function? first of all, image not 80 x 250. sure go checkout documentation . what hoping after step? determines whether appropriate way go this. but based on code , last statement, want x range 0 - 280 , y range 0 - 410. xrange = linspace(0, 280, size(a, 2)); yrange = linspace(0, 410, siz

c# - Html DropDownListFor issue -

i have problem dropdownlistfor , want dropdownlist 1,2,3,4,5 etc. on view. in model class: public class pagemodel { [displayname("quantity")] public int quantity { get; set; } } i have created quantity class public class quantity { public int selection { get; set; } } a htmllist class public static class htmllists { public static ienumerable<quantity> selections = new list<quantity> { new quantity { selection = 1 }, new quantity { selection = 2 } }; on view: @html.labelfor(m => m.quantity): <td>@html.dropdownlistfor(m => m.quantity, new selectlist(htmllist.selections, "selection")) it giving me error @ htmllist.selections : the name 'htmllist' not exists in current context edit: my error issue fixed @using yournamespaceofstaticclass but have folliwing problem: instead

android - How to prevent duplicate product action in Enhanced Ecommerce -

i have implemented enhanced ecommerce in android app. first user views product list(impression), product detail(action_detail),add cart(add cart). if user deleted cart , adds same product cart again, addtocart action have multiple duplicate hits. there way protect or prevent such duplicate action hits same user or during same session rather

atlassian sourcetree - How to view file contents as it was in a commit - Like `git show` -

briefly: what's sourcetree equivalent of: git show 946a759:file.h more thorougly: file.h did not change in commit 946a759, want see contents of file @ time of commit. i know could change log view - working copy view show all of files, find file in list, right-click on , choose "log selected", find commit (or next oldest one) but that's cumbersome process i don't want change log view's setup show files it's difficult find random file in huge long list of files. so i'd in log view master branch selected in left sidebar, find particular commit in tree, , equivalent of git show rev:anyfileiwant. i'd fine typing in path file. i can't seem find way this?

Efficient way to concatenate uncertain strings in Objective-C -

i want concatenate strings variables if variables not nil. if nil, don't want include them. following code works clunky , grows proportionately more complex additional variables. can recommend more elegant way this? nsstring *city = self.address.city== nil ? @"" : self.address.city; nsstring *state = self.address.state== nil ? @"" : self.address.state; nsstring *zip = self.address.zip== nil ? @"" : self.address.zip; nsstring *bestcity; if (city.length>0&&state.length>0&&zip.length>0) { bestcity = [nsstring stringwithformat: @"%@ %@ %@", city, state,zip]; } else if (city.length>0&&state.length>0) { bestname = [nsstring stringwithformat: @"%@ %@", city,state]; } else if (city.length>0&&zip.length>0) { bestcity = [nsstring stringwithformat: @"%@ %@", city,zip]; } else if (city.length>0&&zip.length>0) { bestcity = [nsstring stringwithf

javascript - jquery event binding not working with more than one dynamic object -

on drop-down menu change of dynamically added object through ajax, either add or remove class. if 1 object exists code works, reason more 1 stop working. $('.product_options_container').on('change', '.product_preset_dropdown', function() { var conceptname = $(this).closest('.product_option_hidden').children('.product_preset_dropdown').find(":selected").text(); if(conceptname != 'custom'){ $(this).closest('.product_option_hidden').children('.product_encapsulation').addclass("hidden"); } else if(conceptname == 'custom'){ $(this).closest('.product_option_hidden').children('.product_encapsulation').removeclass("hidden"); } }); markup // div container ajax loaded <div id="dynamicinputs" class="dynamicinputs"></div> // ajax file loaded <div class='product_option_hidden'> <div c

Why Java ArrayList's remove() method implementation does not decrease the size of internal array data? -

this question has answer here: does capacity of arraylist decrease when remove elements? 6 answers for add() method, implementation such elementdata\[\] array's size grows needed. however, looking @ remove() method, not shrink size elements removed. i tested using simple code , elementdata[] starts out 10 , grows. however, when delete elements using remove() method, size of elementdata[] stays @ point finished adding elements. int testsize = 10000000; arraylist<integer> alist = new arraylist<integer>(); // size of elementdata[] 10 for(int = 0; < testsize; i++) { alist.add(i); } // size of elementdata[] 13845150 for(int = alist.size()-1; >= 0; i--) { alist.remove(i); } // size of elementdata[] remains @ 13845150 isn't wasting memory? first should note size of array cannot changed, once created. changing size of

Why isn't my ruby class converting to json? -

i confused why simple ruby object not converting json. >irb > require 'json' class user attr_accessor :name, :age def initialize(name, age) @name = name @age = age end end u1 = user.new("a", 1) u2 = user.new("b", 2) puts u1.to_json "\"#<user:0x000001010e9f78>\"" what missing? i want store these objects array collection, , convert entire collection json. users = [] users << user.new("a", 1) users << user.new("b", 2) users.to_json note: not using rails, plain old ruby! i want json array of user objects. [ {"name": "john", "age": 22}, {"name": "john1", "age": 23} {"name": "john2", "age": 24} ] by default, classes cannot made json strings. must have to_json method in class, can make inherit class (type class user < jsonable ): class jsonable def to_json

excel - Populating row headers with numbers till a certain criteria -

i'm trying create macro populate worksheet's row headers labeling them box numbers like: box 1 box 2 box 3 ... , on. the number of boxes in sheet. if number written there 8, possible populate other sheet's rows box 1 box 8? am making sense? thanks. if need fancier asked for, may need resort vba. if not, following works: create new excel file 2 sheets. on 2nd worksheet, in cell a1, enter number 10 on 1st worksheet, in cell a1, enter formula: =if(column()<=sheet2!$a$1,"box " & column(), "") on 1st worksheet, select a1. press ctrl-shft-right (this select entire row) press ctrl-r (this fill formula right) this works because column() returns current column number (a1, a2, a3 return 3. b1, b2, b3 return 2). a simple comparison between value in sheet2 , current column() value gives 1, 2, 3... whatever entered sheet2.

java - Call Runtime.getRuntime.exec(commands) twice on the same Process object -

i have 2 different commands (on external exe file) represented 2 string array command1 , command2 . want run 2 sequentially within same thread. specific, first command executed 10 minutes. if takes longer time, terminate , run second command. here doing. public class myrunnable implements runnable { private process proc; private string[] command1; private string[] command2; public myrunnable (string[] command1, string[] command2) { this.command1 = command1; this.command2 = command2; } public void run() { try { proc = runtime.getruntime().exec(command1); streamgobbler errorgobbler = new streamgobbler(proc.geterrorstream(), "error"); streamgobbler outputgobbler = new streamgobbler(proc.getinputstream(), "output"); errorgobbler.start(); outputgobbler.start(); exitcode = proc.waitfor(10, timeunit.minutes); if (exitcode)

sql - How to merge the records from two queries each with unique fields having numeric data and avoiding doubling of numeric data -

i have 2 sql queries. similar, identical exception of 1 clause in each. each query sums sale_amount field , aliases different name 1 sales , 1 adjustments. need merge records both based on contract(c).id , transaction(t).line_id. problem i'm having when there matching ids , both queries matching have data in respective dollar-based field, dollar amount second query's field(sales) doubles. i've seen other posts this, seem resolve problem using left join. need retain data in both tables, regardless of match well(outer join). below 2 individual queries. // query 1 select c.id t.line_id t.date u.name a.name sum(t.sale_amount) adjustments invoice join contract c on c.contract_no = i.contract_no join transaction t on t.invoice_no = i.invoice_no join unit u on u.unit_no = t.unit_no join agency on a.agency_no = i.agency_no t.unit_no in (44) , i.hard_invoice = 'y' , t.code in ('new', 'edit') , t.adjustment

javascript - Works in Console but not in .js file -

i trying add width , height attributes images; jquery used works in console not in linked .js file. have tried , doesn't work. $(document).ready(function () { $('.media-box-image').each(function () { var $width = $('.media-box-image').width(); var $height = $('.media-box-image').height(); var $this = $(this).find('img'); $this.attr('width', $width); $this.attr('height', $height); }); }); i tried didn't work $(document).ready(function () { $('.media-box-image').each().on('load', function () { var $width = $('.media-box-image').width(); var $height = $('.media-box-image').height(); var $this = $(this).find('img'); $this.attr('width', $width); $this.attr('height', $height); }); }); i checked console seems fine. else can do? when document ready callback execute

sql - MariaDB BEFORE INSERT TRIGGER for UUID -

i'm using mariadb 5.5.29 on windows 64 platform. created table: create table dm_countries ( country_uuid binary(16) not null, c_name varchar(255) not null unique, c_localname varchar(255) default null, c_countrycode varchar(255) default null, primary key (country_uuid) ) engine=innodb; now want make sure, uuid (which ment primary key) automatically inserted if not provided. therefore, created trigger: delimiter | create trigger trig_bi_dm_countries before insert on dm_countries each row begin if new.country_uuid null set new.country_uuid = uuid(); end if; end| delimiter ; to make sure commited (even if schema changes should not need it): commit; now, when try insert new row this: insert dm_countries (c_name, c_localname, c_countrycode) values ('großbritannien', 'great britain', 'uk'); i expected trigger put new uuid in place , successful insert table. happens this: error code: 1364. field 

Can't Connect mySQL database using LAN (C# Winform application) -

i'm building winform application c# lang , mysql database. there's 3 computer work with. 1st computer connected lan network (static ip address), creates hotspot connect*fy app, , mysql database server 2nd computer connect 1st computer wirelesslan, connect connect*fy app 3rd computer connect 1st computer lan cable (static ip address) i can connect 1st , 2nd computer. when try 3rd computer showing message "unable connect specified mysql host" connection strings used string user = "koas"; string password = "poipoi"; string database = "bke_nota_db"; string host = "10.20.10.129"; mysqlconnection conn = new mysqlconnection("server=" + host + ";database=" + database + ";username=" + user + ";password=" + password +

apache - Checkin error on subversion server installed on AWS EC2 -

i installed subversion server on aws ec2. of works fine. i'm able checkout unable checkin file on command line. svn: e000013: not begin transaction. error in logs are: [wed jan 20 22:02:25.679636 2016] [:error] [pid 28816] [client 96.242.58.29:53390] can't open file '/var/www/svn/repos/db/txn-current-lock': permission denied [500, #13] this syntax subversion.conf cat /etc/httpd/conf.d/subversion.conf loadmodule dav_svn_module modules/mod_dav_svn.so loadmodule authz_svn_module modules/mod_authz_svn.so <location /svn> dav svn svnparentpath /var/www/svn <limitexcept propfind options report> svnlistparentpath on authtype basic authname "subversion repositories" authuserfile /etc/svn-auth-conf require valid-user </limitexcept> repo permissions this: ls -lrt /var/www/ total 0 drwxrwxrwx. 2 root root 6 sep 17 09:07 cgi-bin drwxrwxrwx. 3 root root 28 jan 20 20:17 html drwsrwsr-x. 3 apache a

c++ - Converting strings to pointers -

i'm trying convert pointer string, , string pointer (lexical casting) using following code. conversion pointer string works fine, not other way round. why happen? there other way can convert string pointer? i'm not worried errors caused incorrect format of string. string i'm trying convert pointer generated converting pointer string. here's code: //tb_converttostring.cpp #include<iostream> #include<cstdio> #include<sstream> #include<string> //functions convert data types , strings template <typename t> std::string tostring ( t number ) { std::stringstream ss; ss << number; return ss.str(); }; template <typename t> t fromstring ( const std::string &text ) { std::stringstream ss(text); t result; ss >> result; return result; } //------------------------------------------------- using namespace std; int main() { int =10; int* p1 = &a; // works-----------

javascript - Parse json array getting certain index -

i'm new jquery , javascript, using ajax upload image , wish image url, tried getting it, keep getting error time. can me out this? thanks! error received: uncaught typeerror: cannot read property 'length' of undefined here result after calling url: {"status_code":200,"status_txt":"ok","data":{"img_name":"nffwv.jpg","img_url":"http:\/\/sl.uploads.im\/nffwv.jpg","img_view":"http:\/\/uploads.im\/nffwv.jpg","img_width":"3840","img_height":"2160","img_attr":"width=\"3840\" height=\"2160\"","img_size":"3.1 mb","img_bytes":3226508,"thumb_url":"http:\/\/sl.uploads.im\/t\/nffwv.jpg","thumb_width":360,"thumb_height":203,"source":"base64 image string","resized":"0","delete_key":

javascript - Trying to get response.name or id -

on page, people can press share button , post on facebook. use code: window.fbasyncinit = function() { fb.init( { "appid" : "<?php echo $fbid; ?>", "status" : true, "cookie" : true, "xfbml" : true, "oauth" : true }); on click function showstreampublish starts: function showstreampublish() { fb.ui( { method: 'feed', name: 'text', caption: 'text', link: 'link', picture:'pic', description: 'ni', user_message_prompt: 'share it!' }, function(response) { if (response && response.post_id) { fb.api('/me', function(response) {alert(response.name); }); ... where use following code wanna show username of p

C++ - Cross-platform newline character in string -

when newline in string necessary, use \n character int main() { string str = "hello world\n"; } does \n crossplatform? or need use macro adapting it's value platform? especially when str going written file or stdout. as long read/write text streams, or files in text mode, '\n' translated correct sequence platform. http://en.cppreference.com/w/c/io

Powershell split string on multiple conditions -

i have csv file extracting first , last name column, seperate them in own columns. so given string: 'john doe - generic- random' i use split(" ") extract first , last name $string = 'john doe - generic- random' $firstname = $string.split(" ")[0] $lastname = $string.split(" ")[1] first issue i found issue after last name, string not have space. example $string = 'john doe-generic-random' how last name doe out rest. how can apply split 2 conditions of " " , "-" 2nd issue some strings have first name. example... $string = 'john - generic - random how can assign last name $null if case? looks working... $string = 'john doe - generic- random' $firstname = $string -split {$_ -eq " " -or $_ -eq "-"} $firstname[0] $lastname = $string -split {$_ -eq " " -or $_ -eq "-"} $firstname[1] if there no last name, blank in column last

android - Does onSaveInstanceState always save my Member variables in Fragment? -

i switch fragment when ondestroyedview() called,member variables kept, , when ondestroy() called, restore them bundle, because onsaveinstancestate called before ondestroy().but face problem member variables reset initial values,i have lots of documents don't know why happen? does onsaveinstancestate save member variables in fragment? no. onsaveinstancestate() saves whatever put in bundle passed in parameter. values out of bundle in oncreate() or other fragment lifecycle methods.

Extra whitespace in XML file read from Oracle database - why? -

i experimenting python , oracle xml db. have table xmltype column , id column in oracle 11g database. storage model xml column object relational. need whole xml file, , longer 4000 characters, use query clob: select t.representation.getclobval() myxmldocs t id=:documentid when run query output includes whitespace, newlines , tabs between xml elements not there in xml docs inserted. effect of kind of formatting, output looks this: <a>\n \t<b></b>\n \t\t<c>some text</c>\n \t\t<c>some more text</c>\n \t<b></b>\n ... and on. quite pretty , readable, why getting it? messes other libraries using choke on whitespaces. if remove getclobval() python client not clob object , don't know it. this appears consistent; problem using sqlplus command line client, , creating other tables using different xml schemas, , querying them. in previous version of prototype had xmltype column use clob storage model , didn't have probl

listview - Change Activity Button State from Adapter -

i have listview in activity, , have change deletebutton state (visible - gone), when user checks/unchecks checkboxes on of listview's items. i tried doing this: holder.cb_row_adminnotescheck .setoncheckedchangelistener(new oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { int getposition = (integer) buttonview.gettag(); mnoteslist.get(getposition).setselected(ischecked); if (ischecked) { map.put(getposition, true); } else { map.remove(getposition); } setdeletebuttonvisibility(); } }); .. private void setdeletebuttonvisibility() { layoutinflater inflater = (layoutinflater) activity

java - Reference a Recyclerview that was in a fragment in Appcompat activity? -

hey have recyclerview , recyclerview adapter shown below. however, recyclerview adapter inflated inside activity extends fragment. time want use in activity extends appcompatactivity, how do that? @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view view=inflater.inflate(r.layout.fragment_dashboard,container,false); mrecyclerview=(recyclerview)view.findviewbyid(r.id.id); mrecyclerview.setlayoutmanager(new linearlayoutmanager(this)); madapterdashboard=new adapterdashboard(this); mrecyclerview.setadapter(madapterdashboard); return view; just use same code inside oncreate() method of activity // initialize recycler view mrecyclerview = (recyclerview) findviewbyid(r.id.id); mrecyclerview.setlayoutmanager(new linearlayoutmanager(this)); madapterdashboard=new adapterdashboard(this); mrecyclerview.setadapter(madapterdashboard);

javascript - Requested unknown parameter '0' for row 1 -

"datatables warning: table id=datatables-example- requested unknown parameter '0' row 1." i know there lot of similar answers available on google, of them uses json , well, don't. know parameter '0' referring event id, can enlighten me on change? i have class named "trialevent", servlet named "eventretrieveservlet" , session bean. the below codes in jsp. <form method="get" action="eventretrieveservlet"> <div class="panel-body"> <div class="table-responsive"> <table class="table table-striped table-bordered table-hover" id="datatables-example"> <thead> <tr> <th>event ref.</th>

javascript - Server overload ... with requests? How do I efficiently program server-client wise -

so, have server mysql database in it, , client (browser) retrieves data server , displays user. i'm struggling on whether should let client data needs mysql server (using php), , let client querying, adding, updating data javascript or other related library, , send server server update data; or whether should let client send requests (query, add, update, etc) server relevant parameters server handle user's data with, say, mysql commands. i think first way relief server because work done clients' computer, , not server, hard me learn or make library querying , stuff can otherwise done mysql commands find easier work @ moment. and think second way easier me, because can use php , mysql perform whatever server needs client, makes me think load server many repetitive work each client if there many clients. which method better? at moment, i'm client , server run on same computer, there won't load of commands server need run, want know method canonical , e

javascript - How to set up a custom template on Chartjs? -

Image
i working line chart chartjs , the angular extension plugin. i having difficulties trying edit tooltip according docs need create custom template in order achieve need here have far as see there tooltip not displaying need, need display this: $amount (total) so in case should be: $150 (1) got ? see code $scope.labels = object.keys(data); $scope.seriesconv = ["amount"]; $scope.dataconv = $scope.seriesconv.map(function(serie) { return $scope.labels.map(function(label) { $scope.trafficsource = object.keys(data[label])[0]; $scope.chartoptions = { tooltiptemplate: "<%= '$' + value %>", }; return data[label][$scope.trafficsource].conversions.amount; }); }); and html <canvas id="line" class="chart chart-line" height="100" chart-options="chartoptions" chart-data=&qu

Spring SimpleJDBCInsert : insert query getting blocked when the column value extends the column length -

when try insert record in table using simplejdbcinsert , make value of column greater column length, query not execute, without throwing exception, , blocking further code-flow. when check mysql fullprocesslist, after code reaches insert statmemt, database on query fired, shows in sleep i rectified issue truncating column value schema's column length in application. sample code example: public class blogdaoimpl implements blogdao { private simplejdbctemplate simplejdbctemplate; private simplejdbcinsert insertblog; public void setdatasource(datasource datasource) { this.simplejdbctemplate = new simplejdbctemplate(datasource); this.insertblog = new simplejdbcinsert(datasource) .withtablename("blog"); .usinggeneratedkeycolumns("id"); } public void create(string name, integer age, long salary) { map parameters = new hashmap();

shell - Does Bash have private stack frames for recursive function calls? -

consider following code: recursion_test() { local_var=$1 echo "local variable before nested call: $local_var" if [[ $local_var == "yellow" ]]; return fi recursion_test "yellow" echo "local variable changed nested call: $local_var" } output: local variable before nested call: red local variable before nested call: yellow local variable changed nested call: yellow in other programming languages such java each method invocation has separate private stack frame on local variables kept. nested invocation of method can't modify variables in parent invocation. in bash invocations share same stack frame? there way have separate local variables different invocations? if not, there workaround write recursive functions 1 invocation not affect other? you want local builtin. try local local_var=$1 in example. note: still have careful local isn't private in c stack variable. it's more

numpy.test error in virtualenv with ERROR: test_multiarray.TestNewBufferProtocol.test_relaxed_strides -

in ubuntu system,i install numpy in virtualenv python 2.7. after install it, using numpy.test: python -c "import numpy; numpy.test()" there errors this: error: test_multiarray.testnewbufferprotocol.test_relaxed_strides traceback (most recent call last): file "/home/zjd/wangliangguo/theano-env/local/lib/python2.7/site- packages/nose/case.py", line 197, in runtest self.test(*self.arg) file "/home/zjd/wangliangguo/theano-env/local/lib/python2.7/site-packages/numpy/core/tests/test_multiarray.py", line 5366, in test_relaxed_strides fd.write(c.data) typeerror: 'buffer' not have buffer interface i had same error python 2.7.3. upgrading python 2.7.11 fixed me. i'm on ubuntu 12.04 lts, , default apt-get repositories didn't have python 2.7.11, followed these instructions: https://superuser.com/a/942296

javascript - API Thumbnail Image returns TypeError: cannot read "url" of undefined -

Image
i'm using nyt api in order grab thumbnail/image of article. i'm getting cannot read property "url" of undefined error of images. here's screenshot terminal. since said "url" undefined, decided check (in function) whether image source returned undefined : var prefix = "http:\/\/static01.nyt.com\/"; var src = prefix + data.multimedia[2].url; if(!src || src == undefined) { src = "img/img-nyt.png"; } else { imgsource = src; } console.log(imgsource); but i'm not sure why still return undefined because if is, image source should changed img-nyt.png . here's sample json request: "results": [ { "multimedia":[ { "url":"http:\/\/static01.nyt.com\/images\/2016\/01\/20\/us\/20michigan-web\/20michigan-web-thumbstandard.jpg", "height":75, "width":75, }, {

How to install ruby-augeas gem? (ubuntu 10.04) -

root@ubuntu10:~# gem install ruby-augeas fetching: ruby-augeas-0.5.0.gem (100%) building native extensions. take while... error: error installing ruby-augeas: error: failed build gem native extension. /usr/local/rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb *** extconf.rb failed *** not create makefile due reason, lack of necessary libraries and/or headers. check mkmf.log file more details. may need configuration options. provided configuration options: --with-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/rvm/rubies/ruby-1.9.3-p327/bin/ruby --with-augeas-config --without-augeas-config --with-pkg-config --without-pkg-config extconf.rb:27:in `<main>': augeas-devel not installed (runtimeerror) gem files remain installed in /usr/local/rvm/gems/ruby-1.9.3-p32

bitmap - how to allow users to choose photos only from gallery not from photos app? -

here code intent intent = new intent(intent.action_pick, android.provider.mediastore.images.media.external_content_uri); intent.settype("image/*"); intent.putextra(intent.extra_local_only, true); mcontext.startactivityforresult( intent.createchooser(intent, "select file"), open_gallery_request); dismiss(); app crashes if choose images photos stored in cloud fixed issue checking file path if user choose image cloud toast message download image but there way restrict users choose image gallery in advance are looking this intent intent = new intent(); intent.settype("image/*"); intent.setaction(intent.action_get_content); intent.putextra(intent.extra_local_only, true); startactivityforresult(intent.createchooser(intent, "complete action using"), photo_picker_id);

ios - Set HTTP Body to AFNetworking instead of using native request -

ive been trying afnetworking work did native request, have been using afnetworking uploading post or get.but never uploaded image correct. uploaded server damaged , i've explained issue in reference : uploading image server reached damaged using afnetworking i've tried use native nsurlconnection.sendsynchronousrequest http body , has been uploaded , not damaged. , code work need in afnetworking because supports ios 8 + , more reasons. let baseurl = "" let selectedimage = self.userimage.image let imagedata = nsdata(data: uiimagejpegrepresentation(selectedimage!, 0.5)!) let request = nsmutableurlrequest() request.url = nsurl(string: baseurl) request.httpmethod = "post" request.addvalue("image/jpeg", forhttpheaderfield: "content-type") let body = nsmutabledata(data: imagedata) request.httpbody = body { let responsedata = try nsurlconnection.sendsy

php - mysqli fetch array error Couldn't fetch mysqli -

i trying input , display data on same page through mysqli but shows error " couldn't fetch mysqli on line " , not unable display records . <?php $db=mysqli_connect("localhost","root","","abc") or die("not connected".mysqli_error()); $database=mysqli_select_db($db,'abc') or die("database not found".mysqli_error()); if(isset($_post['submit'])){ $roll=$_post['roll']; $name=$_post['name']; $ins=mysqli_query($db,"insert abc1 (roll,name)values('$roll','$name')"); } mysqli_close($db); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</titl

avr - How to layout arduino code files with external unit tests -

i have 3 code files arduino project: main.ino <-- main sketch helper.cpp <-- helper functions, no avr code helper_test.cpp <-- unit test helpers arduino attempt include helper_test.cpp, , confused inclusion of unit test library header files (which happen google test). if unit test contains c main function skip in main.ino , try use that. i know there dedicated arduino unit test frameworks, these regular c++ unit tests math functions don't touch avr-related code. how can lay these files out or make arduino won't try include helper_test.cpp include helper.cpp? you need create 2 separate projects. 1 project contain production code. have these files: main.ino <-- main sketch helper.cpp <-- header helper functions helper.cpp <-- implementation helper functions and other files necessary create arduino app. build when want create app itself. other project standard executable run unit tests: main_test.cpp <-- main helper_test.cpp

javascript - Bootstrap-Table loading data -

i got difficulties in bootstrap table data loading: currently in .js , defined this: var data = '[{"id": 0,"name": "item 0","price": "$0"}, {"id": 1,"name": "item 1","price": "$1"},{"id": 2,"name": "item 2","price": "$2"}]'; i used 2 methods of loading data table: json parse above data blabla=json.parse(data); $('#table').bootstraptable('load',blabla); this feature working fine use data: var blabla=json.parse(data); $('#table').bootstraptable({ data: blabla }); could enlighten me, why 2nd option couldnt view data table? , how should syntax 2nd option if wrong. thanks!

r - Regex to match strings that are all punctuation but not strings with punctuation containing other characters -

i have messy text responses i'm trying cleanup little. i'm using r , want match responses punctuation removal. is there regexp can use match these: !@#$ . ********** but not these: hello. !asdf **********1 i had tried x[grepl("^[[:punct:]+]", x)] which matches punctuation @ first character punctuation character simply use negation.. x[!grepl("\\w", x)] or x[!grepl("[a-za-z]", x)] your regex x[grepl("^[[:punct:]+]", x)] should check punctuation exists @ start.

c# - Custom serverRuntime in deployed WCF site is not working -

i have issue in deploying wcf service max values server runtime in iis not work displaying error http error 500.19 - internal server error requested page cannot accessed because related configuration data page invalid. at following line <modules runallmanagedmodulesforallrequests="true" /> <serverruntime maxrequestentityallowed="4294967295" uploadreadaheadsize="2147483647" /> <directorybrowse enabled="true" /> how can unlock iis serverruntime in wcf deployed project

c# - Excel get_range -

how can use excel get_range put following data range value. i believe should able use get_range this, i'm not sure how. columns c1 = name, c5 = value, c10 = value i assumed wanted these in column headings. if not, change cell reference in get_range(). following it: using excel = microsoft.office.interop.excel; excel.range targetrange = targetsheet.get_range("a1"); targetrange.value = name; excel.range targetrange = targetsheet.get_range("e1"); targetrange.value = value; excel.range targetrange = targetsheet.get_range("j1"); targetrange.value = value; if don't have content between a1 , j1 want keep, can put values object[,] , set value of a1:j1 in 1 go, little faster.

camera - After capture a picture appear in full screen android -

i desire created camera app.for begining created sample apps.i research in github wanna camera snapchat.can prefer idea how can begining ? in sample apps can take picture preview pictures not good.my picture should appear in full screen in device snapchat. thanks. i had make custom camera plug cordova , helped me lot: https://github.com/performanceactive/phonegap-custom-camera-plugin/tree/master/platforms/android/src/com/performanceactive/plugins/camera check customcameraactivity , customcamerapreview, show how customize camera, control preview size, aspect ratio , surface change. check function in customcamerapreview.java: private size optimimalpreviewsize(int targetwidth, int targetheight) { list<size> sizes = camera.getparameters().getsupportedpreviewsizes(); float targetaspectratio = (float) targetwidth / targetheight; list<size> sizeswithmatchingaspectratios = filterbyaspectratio(targetaspectratio, sizes); if (siz

linux - Perl oneliner to match exact word in a path on many different values with special characters -

how match $target_name value find /tmp -type l -exec ls -l output? $ find /tmp -type l -exec ls -l 2>/dev/null {} + lrwxrwxrwx 1 root root 24 mar 18 12:41 /tmp/test/link -> /usr/admin/collect_tests lrwxrwxrwx 1 root root 43 mar 18 12:41 /tmp/test/link1 -> /usr/admin/collect_tests/upload.cm@.www.com lrwxrwxrwx 1 root root 68 mar 18 12:41 /tmp/test/link2 -> /usr/admin/collect_tests/upload.cm@.www.com/upload_shema@@@.data.com lrwxrwxrwx 1 root root 100 mar 18 12:42 /tmp/test/link3 -> /usr/admin/collect_tests/upload.cm@.www.com/upload_shema@@@.data.com/list.files.emails.dummy*printed lrwxrwxrwx 1 root root 92 mar 18 12:42 /tmp/test/link4 -> /usr/admin/collect_tests/upload.cm@.www.com/upload_shema@@@.data.com/list.files@emails.dummy examples of values target_name=upload.cm@.www.com target_name=upload_shema@@@.data.com target_name=list.files.emails.dummy*printed target: print: "link name" , "path" (last field ) if $target_name

ios - If I bring up a UIActionSheet, how do I make one of the options segue to a new view? -

i have no idea how this. created uiactionsheet , comes when tap button, want, upon option being selected app segue new view controller. you call in uiactionsheetdelegate method (when user taps button) [self performseguewithidentifyer:@"segue_id"];

c# - ASP MVC 5 and Web Api 2 can't view page on complete links -

i have 2 controllers, 1 mvc , 1 web api 2. latter seems work correctly, first can't display html pages when write full address. this simple routeconfig.cs routes.maproute( name: "default", url: "{controller}/{action}", defaults: new { controller = "base", action = "main" } ); ) let's take default example, controller base , action main , code straightforward public actionresult main() { return view(); } http://localhost/miapps --> work , display content of /view/base/main http://localhost/miapps/base --> work , display content of /view/base/main http://localhost/miapps/base/main --> doesn't work, error is {"message":"no http resource found matches request uri ' http://localhost/miapps/base/main '.","messagedetail":"no type found matches controller named 'base'."} i post webapiconfig.cs

ssl - nginx and two certificates for one domain (EV nad wildcard) -

we have our domain.tld 2 certificates. 1 ev (for domain.tld , www.domain.tld) , wildcard subdomains. our website running on www.domain.tld (always) , subdomains used images (img.domain.tld). we using nginx "virtual hosts": server { # listen 443; listen 443 ssl spdy; server_name domain.tld *.domain.tld; ssl on; # wildcard ssl_certificate /usr/local/nginx/cert/wildcard/uni_star_domain_tld.crt; ssl_certificate_key /usr/local/nginx/cert/wildcard/wildcarddomain.tld.key; ... server { # listen 443; listen 443 ssl spdy; server_name www.domain.tld; ssl on; # ev ssl_certificate /usr/local/nginx/cert/wildcard/ev_cert_domain_tld.crt; ssl_certificate_key /usr/local/nginx/cert/wildcard/ev.cert.domain

Android Location service didn't work in background -

i working on location-app should begin track statistic data based on longitude , latitude when user presses button . stuff works when comes lock screen or put app in background service not work anymore ! i have read lot background services , broadcast receivers don't know how implement google api location listener in service , implement class in mainactivity . can tell me short code example how implement such service or link explained ? use fuse location service , save updated location every time public class locationnotifyservice extends service implements locationlistener, googleapiclient.connectioncallbacks, googleapiclient.onconnectionfailedlistener { locationrequest mlocationrequest; googleapiclient mgoogleapiclient; public static location mcurrentlocation; ............................. @override public void oncreate() { //show error dialog if goolgleplayservices not available if (isgoogleplay

How entities could be connected with each other inside the domain? -

let's assume there 2 domain entities: userimages methods addnewimage() , removeimage ( $imageid ), getimages ( $from, $count ). userprofile fields name , age , mainimageid , etc. following functionality desired inside domain: when application layer calls userimages -> addnewimage() , userprofile -> mainimageid set automatically in case empty. so, best way , best place implement in-domain over-entity business logic? domain events observing services, referencing special services entities, or else? i create entities using kind of factory, i.e. $userimages = domain::userimages($userid); // getting instance of userimages $newimageid = $userimages -> addnewimage(); // adding new image i should mention have lot of logic described above in project. thank help! first off, specified in other question , userimages not entity. instead, there entity called userimage refers user's image, singular. userimagerepository can provide access images