Posts

Showing posts from August, 2011

android - ContentResolver openInputStream() throws FileNotFound on existing file -

i have apparently simple code file path = environment.getexternalstoragepublicdirectory(environment.directory_pictures); file testfile = new file(path,"image.jpg"); log.d(tag,"testfile: " + testfile + " exists: " + testfile.exists()); uri uri = uri.fromfile(testfile); contentresolver cr = context.getcontentresolver(); inputstream istr = cr.openinputstream(uri); the output is: testfile: /storage/emulated/0/pictures/image.jpg exists: true the uri value file:///storage/emulated/0/pictures/image.jpg . looks same file, openinputstream() throws filenotfoundexception. any idea why? on android 6.0.1. add permission androidmanifest.xml <uses-permission android:name="android.permission.read_external_storage" /> when targetsdkversion 23 or above (android 6), putting in androidmanifest.xml not enough , have request permission @ runtime.

string - Conditioned URL masking -

say have 2 domains 2 different servers. a.com people visit, , b.com hosts files view. when person views a.com/file viewing b.com/file . of course few pages url masking (like iframe), becomes impractical when new pages being made. so how go creating condition automatically mask new links genreated on b.com a.com? (if b.com/new exists, entering a.com/new masks that). additionally, possible, through a.com, b.com links open a.com links? thank very, much. there few ways it. alias a.com b.com dns does. also, b.com links open a.com when provide redirection protocol direct page a.com link , user see url a.com. this happens when enter fb.com, redirected facebook.com

visual c++ - How to find Square of a number inside a Factorial while loop in C? -

i'm trying create program not calculate factorial of number display output factorial less square of number. these requirements: type in number between 3 9. displays in output both factorial , square. if factorial of number inserted less square of number, output string "gotcha!" this code far. thank you #pragma once #include <stdio.h> #define min 3 #define max 9 #define _crt_secure_no_warnings int main() { int i, fact = 1, num; printf("enter number:\n"); scanf_s("%d", &num); while (num >= min || num <= max) { (i = 1; <= num; i++) { fact = fact*i; } if (num < min || num > max) { printf("out of range. please try again.\n"); scanf_s("%d", &num); } else { printf("factorial of %d is: %d\n", num, fact); return 0; } } } just calculate square of number multiplying itself. square = num * num; printf(&quo

java - Hide Sherlock ActionBar Icon (XML) -

i've been searching around , trying find way hide icon on actionbar in app using xml. have, doesn't seem work: <style name="theme.planable" parent="@style/theme.sherlock.light"> <item name="actionbaritembackground">@drawable/selectable_background_planable</item> <item name="popupmenustyle">@style/popupmenu.planable</item> <item name="dropdownlistviewstyle">@style/dropdownlistview.planable</item> <item name="actionbartabstyle">@style/actionbartabstyle.planable</item> <item name="actiondropdownstyle">@style/dropdownnav.planable</item> <item name="actionbarstyle">@style/actionbar.solid.planable</item> <item name="android:actionbarstyle">@style/actionbar.solid.planable</item> <item name="actionmodebackground">@drawable/cab_background_top_planable&l

mod rewrite - AngularJS + PHP api -

this folder structure: myproject/ api/ api.php public/ .htaccess index.html scripts/ ... angular stuff... my .htaccess follows: rewriteengine on # if existing asset or directory requested go rewritecond %{document_root}%{request_uri} -f [or] rewritecond %{document_root}%{request_uri} -d rewriterule ^ - [l] rewriterule ^/api/ ../api/api.php # if requested resource doesn't exist, use index.html rewriterule ^ /index.html so, want this: accessing http://localhost returns index.html . ajax calls within angularjs scrips /api/something should handled api.php file. currently, apache virtual host points myproject/public . accessing http://localhost works fine (it returns index.html) calls /api/something returns index.html. seems api.php never reached. ideas? i dont think can make work double dots not ending processing of rules. so, after matches api, goes on last rule , rewrites index.html add [l] @ end o

php - Could not enter data: You have an error in your SQL syntax; -

can me out problem? here php code stuck error: could not enter data: have error in sql syntax; check manual corresponds mariadb server version right syntax use near ')' @ line 1 how fix it? $sql = "insert pemohon2(p_id,k_nom_siri,p_jenis_aset,p_pengguna_terakhir,p_tarikh_rosak) select p_id,k_nom_siri,p_jenis_aset,p_pengguna_terakhir,p_tarikh_rosak pemohon )"; mysql_select_db('kenderaan'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('could not enter data: ' . mysql_error()); } mysql_close($conn); first of all, please use mysqli instead mysql deprecated. instance, $con=mysqli_connect("localhost","my_user","my_password","my_db"); second, missing word "values" inside query. $sql = "insert pemohon2 values(p_id,k_nom_siri,p_jenis_aset,p_pengguna_terakhir,p_tarikh_rosak) ; lastly, variable reference not assign inside php. instance, $p_id=p_id; $k_

pyspark - SparkSQL read from MySQL database table using Python -

this question has answer here: how work mysql , apache spark? 10 answers i have 'user' table in mysql. want read spark sql program. how can read table mysql apache spark's sparksql module using python? there connector can use task? thanks. there similar question answered . start pyspark this ./bin/pyspark --packages mysql:mysql-connector-java:5.1.38 then run sqlcontext.read.format("jdbc").options( url ="jdbc:mysql://localhost/mysql", driver="com.mysql.jdbc.driver", dbtable="user", user="root", password="" ).load().take(10) this work. depends on mysql set-up, if doesn't try changing password, username, db-url , other settings.

java - Exception in thread "main" Error in Eclipse when trying to run TestNG class -

when attempt run sample testng class in eclipse java 1.7.0_79 following errror: exception in thread "main" com.beust.jcommander.parameterexception: unknown option: -protocol @ com.beust.jcommander.jcommander.parsevalues(jcommander.java:742) @ com.beust.jcommander.jcommander.parse(jcommander.java:282) @ com.beust.jcommander.jcommander.parse(jcommander.java:265) @ com.beust.jcommander.jcommander.<init>(jcommander.java:210) @ org.testng.remote.remotetestng.main(remotetestng.java:162 i have tried installing testng through eclipse store, when didn't work. uninstalled , did through www.beust.com/eclipse site. my class doesn't show errors, project have question mark in lower-left part of image. i thought because missing jcommander.jar. i've gone , tracked down , included in libraries. the weird thing is, running same configurations on windows pc , able testng scripts running, when go through same setup on mac, error. this code i'm trying run:

javascript - Execution stops after the first iteration of the outter loop -

var array = [5,3,4,1] for(var x = 0; x < array.length; x++){ for(var y = array.length - 1; y >= x; y--){ if(array[x] > array[y]){ var temp = array[y]; array[y] = array[x]; array[x] = temp; } } } console.log(array); //output : [1,3,4,5] i understand loops meant swap loops swapping 2 values if x greater y. [1,3,4,5] result when x = 0, why doesn't change once x = 1, , on? shouldn't secondary for-loop run thru iterations , continue swap values until first loop reaches array.length (4)? edit: bit more information on thought process is: output [1,3,4,5] after first iteration, when iterates x = 1? @ point, x[1] = 3, correct? if statement fails when y decrements 5, 4, 3, 3 > 1 , think output changed [3,1,4,5]. @ point x iterates x[2] 4 , output becomes [4,3,1,5] , finally, x[3] = 5 no further swaps possible var array = [5,3,4,1] for(var x = 0; x < array.length; x++){ for(var y = array.length

php - How to integrating adminlte to laravel 5? -

i want use adminlte template laravel 5. have downloaded source code here. the first trying, have got error "vendor", , after looking solution internet it's because have no vendor folder in source code have downloaded. after adding vendor folder new laravel installation, have got error "whoops, looks went wrong." it. do know how solve it? what error appears after "whoops, looks went wrong." ? try composer update. check if .env file exists , configured requirements. check if server has write permissions log, display errors. easier encounter actual problem.

Hive Updates using Informatica -

my target hive table using informatica etl tool. updates not supported in hive earlier versions. how should updates records in scenario. ok go hive update feature using hive acid , transaction feature. informatica supports updates hive tables informatica 9.6 hf3 version provided tables support acid, more information can refer link ( https://cwiki.apache.org/confluence/display/hive/hive+transactions ), instead of doing this, rather in 2 step process, 1) identify records exist in target , records exist in stage data 2) merge these 2 , load them temporary table. 3) re-name temporary table actual target table name the above work scd type 1 implementations

how to compare package name from market url in android? -

i developing app contain broadcast receiver , contain list of app when user click particular app directed play store , download app jsons response app showing in al list url " https://play.google.com/store/apps/details?id=com.example.launcher " have when app downloaded in system check app package name of app json response url if match show toast else error message. how can acheive pls me week searching. here code broadcast receiver:- public class receiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { if (intent.getaction().equals("android.intent.action.package_added")) log.e("package added:-", intent.getdata().tostring()); } } @override public void onreceive(context context, intent intent) { string installapppackgename = intent.getdata().getschemespecificpart(); string url = "https://play.google.com/store/apps/details?id=com.example.launcher&

How to find the current available version of a Cordova plugin -

Image
i'm using cordova plugin - know up-coming version of plugin has fix need, @ moment i'm locked using older version of plugin before bug introduced. is there way find out current version of plugin without uninstalling , reinstalling (and having reinstall older 1 if it's not been updated yet)? you can use cordova-check-plugins list both locally installed version(s) , recent available remote version(s): $ cordova-check-plugins it allow automatically or interactively update installed plugins.

rubygems - How can I use an older version of Bundler for a Ruby project? -

...without uninstalling latest version. i'm working on project uses bundler 1.10, use bundler 1.11 other projects. since project on 1.10, whenever run bundle commands, gemfile.lock changes due different formatting introduced bundler 1.11. the solution i've found far running commands so: bundle _1.10.6_ [command] (from answer here: https://stackoverflow.com/a/4373478/1612744 ) is there better way? i'm using rbenv, not rvm. you use the rbenv-gemset plugin . since older version of gem in rbenv gemset doesn't override newer version in default gemset, you'd need install bundler each project, rather cumbersome. install plugin ( cd ~/.rbenv/plugins; git clone git://github.com/jf/rbenv-gemset.git ) or, if use homebrew, brew install rbenv-gemset gem uninstall -xi bundler for each project can use bundler 1.11, cd project echo bundler-1.11 > .rbenv-gemsets ("bundler-1.11" name of gemset) in 1 of projects, gem install bundler c

Ruby BCrypt hash comparison not working -

i new comer ruby, apologies if question has been answered. have read other questions , still cannot figure out doing wrong. i creating hashed passwords storing in db this: new_user.password = bcrypt::password.create(unhashed_password) # write user database new_user.store_user i retrieve user db checking against inputed user name, , check password this: # user database def self.get_user(check_user_name) db = user.open_db user = user.new user_arr = db.execute("select * user_data user_name = ?", check_user_name).first db.close # if user exists check password if user_arr.size != 0 print "enter password : " # password user user_input_password_attempt = gets.chomp end # parse db user user class if password guess correct stored_password = bcrypt::password.new(user_arr[2]) if user_input_password_attempt == stored_password @@users_logged_in += 1 user.user_id = user_arr[0] user.user_name = user_arr[1] user.password = user_arr[2] return user end :n

javascript - On scrolling fonts become lines? -

Image
i'm working in centos 7. i'm developing web tool biologist. project has come final stage. facing 1 critical problem. problem fonts, while scrolling down , on div. i added images below. each pagination page dynamically generated javascript. [image1] original. [image2] after scroll content font lines. then checked several browser in several machines got problem in 2 different machine. problem? how can solve this.? looks gpu rendering issue may try changing css text-rendering although not sure work sure try these 1 one of div or whatever container in text-rendering: auto; text-rendering: optimizespeed; text-rendering: optimizelegibility; text-rendering: geometricprecision;

reactjs - Get the value of checkbox using ref in React -

Image
is there way value of checkbox using ref in react. normal way return value "on" me. var myform = react.createclass({ save: function(){ console.log(this.refs.check_me.value); }, render: function(){ return <div><h1>myform</h1> <div classname="checkbox"> <label> <input type="checkbox" ref="check_me" /> check me out </label> </div> <button classname="btn btn-default" onclick={this.save}>submit</button> </div> } }); for checkbox, use "checked" instead of "value": var myform = react.createclass({ save: function () { console.log(this.refs.check_me.checked); }, render: function () { return <div><h1>myform</h1> <div classname="checkbox"> <label>

objective c - iOS - NSURLSessionTask unzip file downloaded -

i have files download @ didfinishdownloadingtourl: , want unzip it. current code looks this: - (void)urlsession:(nsurlsession *)session downloadtask:(nsurlsessiondownloadtask *)downloadtask didfinishdownloadingtourl:(nsurl *)location { for(nsmutabledictionary *downloadinfo in downloadingarray) { if([[downloadinfo objectforkey:kmzdownloadkeytask] isequal:downloadtask]) { if (location) { nsstring *srcpath = location.absolutestring; nsstring *fullpathdst = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; //unzip ziparchive *ziparchive = [[ziparchive alloc] init]; [ziparchive unzipopenfile:srcpath password:@"pasword"]; [ziparchive unzipfileto:fullpathdst overwrite:yes]; [ziparchive unzipclosefile]; nsfilemanager *filemanager = [nsfilemanager default

c# - xaml parse exception issue only on win7 -

i have issue got error id 1000 (kernelbase.dll) and error id 1026 system.io.filenotfoundexception when try run program on win 7 (witch had run fine before), runs on win 8/8.1/10. running .net framework 4.5 . i had been trying deleting code, error appears on other lines off code , thats keeps going on, know how fix or know how find out causing issue binding failure occurred message : managed debugging assistant ' binding failure ' has detected problem in ' f: \ omini \ omini dækberegner.exe ' . additional information : assembly display name ' presentationframework.aero2 ' not loaded binding context ' c# initializecomponent(); bredebox_nu.focus(); textboxes = new list<textbox> { bredebox_nu, profilbox_nu, fælgestr_nu, bredebox_ny, profilbox_ny, fælgestr_ny, oprofilbox, obredebox, ofælgestr }; win.sourceinitialized += new eventhandler(win_sourceinitialized); list<biler> items = ne

php - yii2 login page redirection looping with cancelled status -

Image
after spending many days, trying experts. stuck login redirection in yii2 application in chrome browser, this controller class, class invitationscontroller extends controller { public function beforeaction($action) { $array=array('index','imageupload','template','category','subcategory','slug','chooseanotherdesign'); if(!in_array($action->id, $array)) { if (\yii::$app->getuser()->isguest && \yii::$app->getrequest()->url !== url::to(\yii::$app->getuser()->loginurl) ) { \yii::$app->getresponse()->redirect(\yii::$app->getuser()->loginurl,false); } } return parent::beforeaction($action); } public function actiongenerateevent(){ $redirecturl=""; if(yii::$app->request->post()){

sql - How can I delete extra zero in a number in mysql? -

for example,i input number,it input format number. if input 0010,it return 10; if input 0.0200,it return 0.02; if input 0.10,it return 0.1; i try use code,but not work.can defined function or stored procedure encapsulate business functionality? select rtrim(00.40) trim() + 0 can trick: select trim(0010)+0, trim(0.0200)+0, trim(0.10)+0 dual output: +--------------+----------------+--------------+ | trim(0010)+0 | trim(0.0200)+0 | trim(0.10)+0 | +--------------+----------------+--------------+ | 10 | 0.02 | 0.1 | +--------------+----------------+--------------+ 1 row in set

python - Get the spans of named groups in order in one line -

i have regex r'(?p<mark1>)|\s+(?p<mark2>)|(?p<mark3>)\s+' (sample regex not actual one) , want spans of captured groups in matches in order. for example: 1. [match.span() match in re.finditer(regex, string)] returns spans in order gives span of whole match not captured group. 2. [match.span('mark1') match in re.finditer(regex, string)] returns spans in order of captured groups puts (-1, -1) other named groups. so, can spans of named groups in order of matches in 1 line, simple above queries? i found following way: [match.span(name) match in re.finditer(regex, string) name, value in match.groupdict().items() if value not none] is there simple one? an example present scenario: import re s = "asfasdf 32392 ..///?% aslf /./.// 342" reg = r'(?p<mark1>[a-z]+)|\s+(?p<mark2>[0-9]+)|(?p<mark3>[./?%]+)\s+' print([match.span(name) match in re.finditer(reg, s) name, value in m

python - Pyspark socket write error -

i'm trying read file(~600m csv file) pyspark. following error. surprisingly same code works correctly scala . i found issue page https://issues.apache.org/jira/browse/spark-12261 not work. reading code: import os pyspark import sparkcontext pyspark import sparkconf datasetdir = 'd:\\datasets\\movielens\\ml-latest\\' ratingfile = 'ratings.csv' conf = sparkconf().setappname("movie_recommendation-server").setmaster('local[2]') sc = sparkcontext(conf=conf) ratingrdd = sc.textfile(os.path.join(datasetdir, ratingfile)) print(ratingrdd.take(1)[0]) i getting error: 16/04/25 09:00:04 error pythonrunner: python worker exited unexpectedly (crashed) java.net.socketexception: connection reset peer: socket write error @ java.net.socketoutputstream.socketwrite0(native method) @ java.net.socketoutputstream.socketwrite(socketoutputstream.java:109) @ java.net.socketoutputstream.write(socketoutputstream.java:153) @

having issue in configuring server from rails with bigblue button -

Image
am developing app in integarating rails app bigblue button. using bigbluebutton_rails gem. have installed gem, have done rails generate bigbluebutton_rails:install then, have generated views, after got views, controllers , models. after tried access bigbluebutton conference app, tried create server couldnt configure server of bigblue button in form i didn't know should enter in form. how can create, join , use conference here. 1 me out of this?? you need bigbluebutton server installed somewhere (see how in https://code.google.com/p/bigbluebutton/wiki/installation ). configure rails application create meetings in bigbluebutton server. separate things, have 2 servers: bigbluebutton (web conference) server , web application written in rails access bigbluebutton server. the information need enter in form screenshot is: name: string name server. url: url of bigbluebutton server's api, example: http://my-server.org/bigbluebutton/api . security salt: salt

ios - AutoLayout for only iPad application -

i start application need support ipad devices. now, question need use autolayout functionality? what thinking app supports ipad,no need use autolayout because ipad devices uses same size classes. correct me if wrong. you have use size classes if using ipad device target application. there reasons why have use size classes : 1) ipad have diff screen sized , resolutions well. check them out here. 2) ipad multitasking feature there ios 9 need resize views according , need size classes check out here. note : if using autolayout no need use size classes size classes important you can check importance of size classes , working in apple's design guide line (here)

unit testing - print success messages for asserts in python -

i using assert in python. every time assert fails failure message have put there printed. wondering if there way print custom success message when assert condition passes ? using py.test framework. example: assert self.clnt.stop_io()==1, "io stop failed" for above assert message "io stop failed" if assert fails looking have "io stop succeeded" if assert passes. like assert self.clnt.stop_io()==1, "io stop failed", "io stop succeeded" yes, simplest surely place print below assert: assert self.clnt.stop_io()==1, "io stop failed" print("io stop passed @ location ==1")

c++ - Native library for stereo-images and computing disparity/depth map -

Image
for more complex project, need compute approximate, relative distances of objects 2 images (from stereo-cameras). practically neat tutorial explains: https://chrisjmccormick.wordpress.com/2014/01/10/stereo-vision-tutorial-part-i/ , result think shouldn't reinventing wheel project , since speed important (realtime 2 videostreams) i'm looking native library (preferably in c++ whole project written in) task. does have suggestion? open source greatest not mandatory. huge in advance! try libelas library (library efficient large-scale stereo matching). best!

c# - How to get last entered textdata from textfile? -

does 1 know how fetch last entered textdata textfile 1 know var readtxt = file.readalltext(@"d:\file\log.txt"); simple answer: it's impossible unless have prior version of file. imagine, file is b c what's happened before? a added or d removed or b changed e ? if have previous version can compute called edit distance , e.g.: https://en.wikipedia.org/wiki/levenshtein_distance before after c b c edit distance (levenshtein one) 1 , edit operation b inserted . however, edit distance doesn´t guarantee exact editing procedure , provides most probable one .

amazon ec2 - How to use run deck service from local browser using up address? -

i have installed rundeck in docker using ec2 instance. when run image , start rundeck . it's fine. lynx http:localhost:4440 us able show rundeck dashboard. but, how can access rundeck windows browser? i tried using address connection refused. in order access outside setup, might have ensure following things: ensure host server (ec2) forwarding ports docker container. should have used -p or -ports when launching container this. test: ec2 instance, should able access: http://localhost:4440 ensure have public ip assigned ec2. should able see aws ec2 console: http://console.aws.amazon.com/ec2 ensure security group(s) instance has inbound connections accept 4440 ip or rest of world. after this, http://:4440 should work. hope got question correct. let me know how goes, thanks, anoop

jquery cookie set css to display: none -

i'm using jquery cookie plugin , i'm trying have browser remember state of css after refresh, here's code when button clicked: $('#cartholder').attr('style','display: none !important'); $.cookie("cartdisplay", 'none !important'); then in header have: if ($.cookie("cartdisplay")){ $('#cartholder').attr('style', $.cookie("cartdisplay")); } the problem is, after each refresh display property still reset it's default property. in console window see jquery cookie has stored necessary value, it's not being written dom after each refresh. any 1 able me out? thanks should not use attr('style') override styles. use .css instead. try avoiding !important . try $('#cartholder').css('display','none'); $.cookie("cartdisplay", 'none'); in header. $(document).ready(function(){ if ($.cookie("ca

ios - Ask user to choose photo from photo library or camera with swift2 -

Image
i want user choose photo photo library or camera. couldn't find example of it. want prompt user uialertview . my code works fine photo library. @ibaction func selectleftphoto(sender: anyobject) { flag = 1 let mypickercontroller = uiimagepickercontroller() mypickercontroller.delegate = self; mypickercontroller.sourcetype = uiimagepickercontrollersourcetype.photolibrary self.presentviewcontroller(mypickercontroller, animated: true, completion: nil) } @ibaction func selectrightbutton(sender: anyobject) { flag = 2 let mypickercontroller = uiimagepickercontroller() mypickercontroller.delegate = self; mypickercontroller.sourcetype = uiimagepickercontrollersourcetype.photolibrary self.presentviewcontroller(mypickercontroller, animated: true, completion: nil) } func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]

xmpp - How does clustering of ejabberd nodes work? -

does work master-slave way, xmpp clients connect master node, , master node uses slave nodes distribute load? if not, how load balancing can done after clustering of ejabberd nodes? all nodes equal , there no master. state kept in mnesia or mysql (like roster table, session etc.). configuration replicated on nodes. usually means there lb in front of whole cluster. 1 cluster represented 1 domain. can have more , federate them.

android - Implementing face tracking using unity3D openCV plugin -

i want make android application allows users put masks onto faces. need face , face features tracking that. i've looked sdks, , put eye on opencv unity plugin. i've downloaded face tracking sample asset store, works badly, , wondering: possible implement better face tracker myself using opencv plugin, or it's best can offer? face tracker sample project asset store works badly because developers made bad or because opencv's maximum? why think it's working badly: here's video . watch 0:19 - face oval , mouth pretty distorted; 1:14 - rotation , position in space very, imprecise, objects shaking much.

r - Hierarchical clustering on rows of varying length with sequence of numbers -

Image
i want hierarchical clustering in 1 of project. my original problem have huge graph on have iterated large number of paths , reported nodes of path in below format. each number in below sample represents graph node , row represents path. want cluster these paths on basis of number of sharing nodes way segregate similar kind of paths. 1210, 158, 1222, 1468 1210, 1222, 198 158, 1468, 25, 26, 27, 28 now want hierarchical clustering between rows based upon number of similar nodes. in table above, rows(paths) 1 , 2 part of 1 cluster due same nodes 1210 , 1222. rows(paths) 1 , 3 part of cluster due similar nodes 158 , 1468. i checked can use hclust function hierarchical clustering. function takes dissimilarity matrix argument. not sure how create distance metric. seems use jaccard similarity measure. don't find option in dist method jaccard similarity , and variable column format above. regards, here's example of hclust jaccard distance (using vegdist in v

javascript - Redirection disrupts image upload -

when user submits form, user should redirected other page. have used window.location.href redirection not working. redirects uploading image won't work then. here code: addrent.js(upload image code focused more shortening code line) $.ajax({ url:"/add/space/", data:senddata, type:'post', success: function(data, textstatus, xhr ) { var pk = xhr.getresponseheader('pk-user'); console.log('pk is',pk); $.ajax({ url:"/upload/image/"+pk+"/", data:image, contenttype:false, processdata:false, type:'post', mimetype: "multipart/form-data", success: function(data) { console.log('success'); } }); window.location.href="http://commonrentpspace.me/"; // if use redirect, images not upload } }); } }

php - Codeigniter 3 Setting session pops MYSQL error -

i'm working codeigniter not long time, encountered weird issue. i'm trying set session called user_id after login process reason mysql error, doe not use mysql session storage. there's session config file. $config['sess_driver'] = 'files'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; $config['sess_save_path'] = null; $config['sess_match_ip'] = false; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = false; there shouldn't reason ci give me mysql error when trying set session. i have managed find answer... issue default lastest codeigniter version did not had $config['sess_use_database'] = false; added in config.php file.

javascript - In openlayers 3, how to fill the polygon with a picture from a url? -

i add picture in polygon, however, not find such function in openlayers 3. there way achieve this? thanks in advance! since pull request #4632 can use canvasrenderingcontext2d.fillstyle ol.style.fill#color property , create pattern . something this: var cnv = document.createelement('canvas'); var ctx = cnv.getcontext('2d'); var img = new image(); img.src = 'https://i.imgsafe.org/73d1273.png'; img.onload = function(){ var pattern = ctx.createpattern(img, 'repeat'); // featurepoly ol.feature(new ol.geom.polygon(...)) featurepoly.setstyle(new ol.style.style({ fill: new ol.style.fill({ color: pattern }) })); }; live demo.

php - Accessing data within an array -

i create array ends quite bit of data. example of array so. array:9 [▼ 0 => array:9 [▼ "id" => "1232806" "date" => "21/04/2016" "name" => "test" "owner" => "someone" "value" => "2160.00" "status/stage" => "70%" 0 => array:2 [▼ "structure" => "" "prospect" => "no" ] 1 => array:2 [▼ 0 => array:8 [▼ "quote id" => "q0020" "name" => "test" "amount" => "2160" ] 1 => array:2 [▼ 0 => array:1 [▼ "type" => "new" ] 1 => array:1 [▼ "month" => "june 16" ] ] ] ] ] i trying data out of array. can top level items out without

How to copy particular element in an XML using XSLT 1.0 -

first, let me provide sample xml guys clear after. <a>1</a> <b>1</b> <c>1</c> <d>1</d> <e>1</e> <f>1</f> is possible copy node b , e f. need neglect node c , d. there <xsl:copy> can copy elements, need particular element out of original xml. thank you. sure can remove needed elements. write empty templates on specified elements after identity transform. source xml <root> <a>1</a> <b>1</b> <c>1</c> <d>1</d> <e>1</e> <f>1</f> </root> xslt 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:strip-space elements="*"/> <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:

c# - How to present year instead of date in Hyperlink control in webForms -

i need show year instade of date string in hyperlinkfield in asp.net webforms <asp:hyperlinkfield headertext="economic year" datatextfield="date" sortexpression="date"datanavigateurlfields="id" datanavigateurlformatstring="p_profitlossadd.aspx?id={0}"></asp:hyperlinkfield> but hyperlinkfield not take dataformatstring="{0:d} property of control . <asp:hyperlinkfield headertext="economic year" datatextfield="date" datatextformatstring="{0:yyyy}" sortexpression="date"datanavigateurlfields="id" datanavigateurlformatstring="p_profitlossadd.aspx?id={0}"></asp:hyperlinkfield>

vb.net - Create custom autoid with date -

i want generate autoid date date 06 july 2013. id should q/xy/130701 13 means year, 07 means month, , 001 should auto increment. autoid q/xy/130701 q/xy/130702 q/xy/130703 .. .. q/xy/130710 q/xy/1307100 then if next month,the id change q/xy/130801 q/xy/130802 and on.. want create autoid once enter 1 record database , autoid generated , call out database display @ gui. suggestion it? database sql server 2008. should alter http://www.codeproject.com/articles/491733/auto-generated-sequence-number-in-sql-server ?

node.js - nodejs multithread for the same resource -

i'm quite new nodejs , i'm doing experiments. them (and hope i'm wrong!) nodejs couldn't serve many concurrent requests same resource without putting them in sequence. consider following code (i use express framework in following example): var express = require('express'); var app = express(); app.get('/otherurl', function (req, res) { res.send('otherurl!'); }); app.get('/slowfasturl', function (req, res) { var test = math.round(math.random()); if(test == "0") { var i; settimeout ( function() { res.send('slow!'); }, 10000 ); } else { res.send('fast!'); } }); app.listen(3000, function () { console.log('app listening on port 3000!'); }); the piece of code above exposes 2 endpoints: http://127.0.0.1:3000/otherurl , reply "otherurl!" simple text ht

php - How to sum second fields from two arrays? -

i have 2 arrays: name1 5 name2 10 name1 11 name2 10 i want output name1 16 name2 20 how can this? please specific 5 .... elements or int elements assuming u want merge 2 arrays define array name_1_2[16] for(int i=0;i<5;i++) { name_1_2[i]=name1[i]; } for(int i=0;i<7;i++) { name_1_2[5+i]=name2[i]; }

swing - Simplest Gui Test Java repaint -

it's simple question, maybe don't understand tutorial i'm reading from. i've been stuck on while. program simple gets aside "hello world". i'm trying this: when user clicks button, "o" moves right. simple enough, put repaint()? need add something.repaint(); repaint screen or itself? nested class problem? t_t making me miserable how no 1 seems have problem can't comprehend. in advance. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class guitest { static int x = 20; private static class movetest extends jpanel { public void paintcomponent(graphics g) { super.paintcomponent(g); g.drawstring("o", x, 30); } } private static class buttonhandler implements actionlistener { public void actionperformed(actionevent e) { x += 1; } } public static void main(string[] args) { movetest displaypanel = new movet

import - Webpack does not find my css file -

i'm strugling import css file webpack. keep getting error: error in ./index.js module not found: error: cannot resolve 'file' or 'directory' ../style/style.css in c:\developement\prja/app @ ./index.js 11:0-29 i tried sorts of path style.css. 'css!../style/style.css' , '/style/style.css' or './style/style.css' none of them works. tried use require instead of import. keep getting same error message. any ideas? my index.js entry point file looks this: import 'expose?$!expose?jquery!jquery'; import angular 'angular'; import 'bootstrap-webpack'; import '../style/style.css'; var ngmodule = angular.module('app', []); an webpack.config.js: module.exports = { context: __dirname + '/app', entry: './index.js', output: { path: __dirname + '/app', filename: 'bundle.js' }, module: { loaders: [ {

c# - how to force Show() to execute now, not after others methods -

in baseform of winform project code connecting database moved load event show event. in show event there call update() before fetching data, makes form appear faster more pleasant users. but found code on places example : formritdetail ritdetail = new formritdetail(); ritdetail.primarykeyvalue = ritid; ritdetail.show(); ritdetail.sendsaleemail(cancelsale); ritdetail.close(); this worked perfect while code fetching data in load event, gives error have tracked down. in sendsaleemail method data not fetched yet. the fetching happens in shown() event, seems c# call sendsaleemail first, , call show(). how can force c# methods in order write them ? can call ritdetail.update() after ritdetail.show() know that, general solution not involves writing additional code everywhere show() method called. is possible ? in baseform of winform project code connecting database moved load event show event. there real problem. depend on event executed valid object state. th

vba - Sorting a Range of Data -

this code sorting range of data based on column e values sub sortbylevel() activeworkbook.worksheets("sheet1").sort.sortfields.clear activeworkbook.worksheets("sheet1").sort.sortfields.add key:=range("e13:e528" _ ), sorton:=xlsortonvalues, order:=xlascending, dataoption:=xlsortnormal activeworkbook.worksheets("sheet1").sort .setrange range("a12:l528") .header = xlyes .matchcase = false .orientation = xltoptobottom .sortmethod = xlpinyin .apply end end sub note b12:l12 range of headers. have impression can more simpler that. suggestions appreciated. thanks, michael use : range("a12:l528").sort key1:=range("e13"), order1:=xlascending, header:=xlyes

weblogic12c - I am trying to display session count from weblogic server and trying to display in java -

can me in this. how fetch value weblogic , display in front end. jmx best bet access weblogic statistics data. since large topic, refer oracle weblogic documentation accessing weblogic server mbeans jmx if link ever breaks: search "accessing weblogic server mbeans jmx 12.1.1" or corresponding version. oracle has chapter various wl versions.

Coding Graham's scan algorithm to find convex hull enclosing a set of points. I'm not able to understand the logic behind the left/right turns -

i have been referring http://www.geeksforgeeks.org/convex-hull-set-2-graham-scan/ to see if make right or left turn during scan, being done is given points p, q, r if (slope of p-q) - (slope of q-r) > 0, considered clockwise turn. if < 0, considered anti-clockwise turn. i'm getting maths after long time. can please explain how logic left/right turn works ?

win universal app - Background Agent in UWP -

in windows 8.1 , wp 8.1, there slight difference between way background agent used work: winrt: in winrt, in cases os not terminate background agent when background agent exhausts quota. instead suspend agent , allow continue later. suspension done without warning event being raised or callback called. os not stop background agent when becomes idle (for example when waiting command server respond). win phone: in win phone, os terminate background agent when background agent exhausts quota. termination done no warning. in win phone, os stop background agent when background agent found idle . in situation os raise ibackgroundtaskinstance.canceled. my question is, there such difference between windows 10 mobile , windows 10 desktop? in windows 10 background agent has been replaced background task . whatever type of w10 device (mobile or desktop) it's run

java - How to Package and deploy a Swings application on other system / network -

i pretty new eclipse. while playing around window builder option develop swings program have struck hurdle. have created simple book management system, want make executable [ similar software installation ] , run on other system/network [ double click , go ]. have tried explore many options posted on-line ( not window builder or swings program ) in vain. any or directions on front me in clearing out hurdle. cheers...!!! you can export project executable jar. right-click on project, export, java, runnable jar file. create closest thing executable can java. can executed double click.

ios - Get elements from array where date is today -

i have array of objects property date of type nsdate. array includes future days , past days. i want array of elements array includes dates in today, not last 24 hours. i ordered elements descending (new old): alldashboards.sortinplace({ $0.date!.compare($1.date!) == nscomparisonresult.ordereddescending i tried loop, check if date yesterday , cut array there, doesn't work may no element yesterdays date: dash in alldashboards { if (nscalendar.currentcalendar().isdateinyesterday(dash.date!)) { print(i) alldashboards.removerange(range.init(start: 0, end: i)) break } += 1 } is there method see if date past day instead of if date part of day? one-liner: let todaydashboards = alldashboards.filter { nscalendar.currentcalendar().isdateintoday($0.date!) }

javascript - how to access array data from api in angularjs -

i want access array calling api in angular js. , use them in ng-repeat angularcode: $scope.onsubmit = function () { $scope.records = []; var answers = []; // post data server here. answers contains questionid , users' answer. $http.get('http://localhost/api/leaderboard/:quizid', answers).success(function successcallbac(data,status) { $scope.records = data; //console.log(records); }); }; html code: <div ng-repeat="list in records"> <div class="row"> <h3>{{list}}}</h3> <h3> {{ list}}</h3> </div> </div> i called api in ng-click event ,i receiving data api cannot use them in ng-repeat records not displaying in html instead showing error: angular.js:12477 referenceerror: records not defined how solve problem ?? you have: $scope.records = data; console.log(records); obviously second line must be: console.log($scope.re

c# - Getting a loop to build a string correctly -

i'm trying pull tournament age webpage: http://www.reddishvulcans.com/uk_tournament_database.asp i'm trying create string based on valid ages entry each table. for example, if "carling cup" enterable 7 year olds, string generated "u7", or if it's enterable 7, 8, , 9 year olds, resulting string "u7, u8, u9". i've made start, logic break if ages go "under 7s, gap here no under 8s , under 9s". here code: public static list<record> getrecords() { string url = "http://www.reddishvulcans.com/uk_tournament_database.asp"; var webget = new htmlweb(); var doc = webget.load(url); var root = doc.documentnode; var ages = root.selectnodes("//div[@class='infobox']/table/tr[5]/td/img"); list<string> tournamentages = new list<string>(); string agegroups = ""; list<string> agestring = new list<string&

Subview cannot be displayed in the camera preview in IOS with swift -

i use avfoundation framework capture , display camera video preview , works. now, want add own uiimageview on top of camera preview, here fragments of code. previewlayer = avcapturevideopreviewlayer(session: capturesession) previewlayer!.videogravity = avlayervideogravityresizeaspect previewlayer!.connection?.videoorientation = avcapturevideoorientation.portrait previewlayer!.frame = previewview.bounds previewview.layer.addsublayer(previewlayer!) var imageview : uiimageview imageview = uiimageview(frame: cgrect(x: 130,y: 320,width: 60,height: 30)) imageview.image = uiimage(named:"scanbutton.png") previewview.addsubview(imageview) self.capturesession!.startrunning() the "scanbutton.png" image file in project folder. the uiimageview cannot displayed. can tell what's wrong, thanks.

filtering one list based on another list c# -

this question has answer here: filter list list c# 4 answers i have 2 lists. the first list list of members memberkey identifies member. the second list list memberkeys ; i want filter member list memberkeys in list of memberkeys. list<member> memberslist = getmembers(); list<int> memberkeys = // list of member keys find list<member> members = memberlist.where(x => x.memberkey ????? // in memberkeys list quite simple way: list<member> members = memberlist.where(x => memberkeys.contains(x.memberkey)).tolist();

c - Why struct shallow copy does not work? -

i'm testing shallow copy struct code: #include "stdio.h" #include "conio.h" int main() { struct str { char * name; int value; }; struct str str_1 = {"go", 255}; struct str str_2; str_2 = str_1; str_1.name = "back"; printf("%s\n",str_1.name); printf("%s\n",str_2.name); printf("\n"); system("pause"); return 0; } i expected result should be: back but was: back go edit: expected because shallow copy, str_1.name , str_2.name should point same place. edit: , dynamic allocation, got expected: #include <stdio.h> #include <conio.h> #include <string.h> int main() { struct str { char * name; int value; }; struct str str_1; struct str str_2; str_1.name = (char*) malloc(5); strcpy(str_1.name,"go"); str_2 = str_1; strcpy(str_1.name,"back&qu

hadoop - how to start emr cluster on amazon? -

i have setup emr cluster in amazon web service 1 master , 2 slaves. don't know whether should use start-all.sh command start nodes on cluster. or, how can start emr cluster nodes? you can create emr cluster using aws console or aws cli . aws emr create-cluster \ --name "1-node dummy cluster" \ --instance-type m3.xlarge \ --release-label emr-4.1.0 \ --instance-count 1 \ --use-default-roles \ --applications name=spark \ --auto-terminate there no need start services using start-all.sh. default services started automatically . if want include services can add services using boot strapping.