Posts

Showing posts from July, 2015

facebook graph API with objective c -

how can name using facebook id using facebook graph api? used code image data id: uiimage* new_image=[uiimage imagewithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:@"http://graph.facebook.com/id/picture?type=normal"]]]; nsdata *imagedata = uiimagepngrepresentation(new_image); how user's name? make \get request to: http://graph.facebook.com/ {user-id}?fields=username you'll response as- { username: "xxxxx", id: "9999999" } example

java - Importing dates from CSV with jOOQ -

i have csv file i'm trying import via jooq's loadcsv method. i'd import straight mysql database date column, csv file has dates formatted yyyymmdd instead of yyyy-mm-dd . there way can pass custom date format (or date parser) jooq import process? thanks! as of jooq 3.3, there no support such data type transformations in loader api. have registered issue #3221 add support useful feature. suspect should feasible (java 8 syntax): ctx.loadinto(author) .loadcsv(csv) .fields(author.id, author.first_name, author.last_name) .values( row -> author.id.getdatatype().convert(row[0]), row -> row[1].split(" ")[0], row -> row[1].split(" ")[1] ) .execute(); contributions welcome, of course ;-)

ios - Can Only add one object to NSMutableDictionary -

i have datepicker , uibarbuttonitem, when uibarbuttonitem pressed invokes method add selected date nsmutabledictionary. code shown below: diarydatearr = [[nsarray alloc] initwithobjects:diarydate, nil]; nsstring *datekeystr = [nsstring stringwithformat:@"datekey%d", dicdates.count+1]; diarykeystrarr = [[nsarray alloc] initwithobjects:datekeystr, nil]; dicdates = [[nsmutabledictionary alloc] initwithobjects:diarydatearr forkeys:diarykeystrarr]; nsarray * allkeys = [dicdates allkeys]; for(nsstring *key in [dicdates allkeys]) { nslog(@"%@",[dicdates objectforkey:key]);} nslog(@"count : %d", [allkeys count]); however, seemingly works until count how many keys within nsmutabledictionary , count returned 1, if click button twice of 2 different dates should theoretically (or @ least how to) should add date selected in date picker making count 2. never changes 1 how objects , keys not being placed dictionary? regards count returning number of

javascript - Passing Multiple Variables to a PHP page -

i want pass multiple variables city1 , area1 (javascript variables) in url php page got stuck in on part shown below. doing wrong? $("#list").load("selectcity.php?city1="+city1&"area1="+area1); $.ajaxsetup({ cache: false }); the & character should inside quotes , not outside quotes. corrected code : $("#list").load("selectcity.php?city1="+city1+"&area1="+area1); $.ajaxsetup({ cache: false }); get parameters separated character & . passing 2 parameters file separated & . ? sign in url indicates next characters coming after get parameters. or can use $.get easy set , works fine $.load : $.get("selectcity.php", {"city1": city1, "area1": area1}, function(response){ $("#list").html(response); });

ruby on rails - Trying to build a one to one relationship between two preexisting models -

i new rails , trying build 1 one relationship between 2 preexisting models (test , test_type) in rails. here workflow. has_one :test_type - tests model belongs_to :test - test_types model rails g migration add_test_type_to_test test_type:references rake db:migrate now looks has worked ok when try verify looks hasn't. rails console @type = testtypes.new :name => "my type" @type.save @test = tests.new :name => "my test" testtypes.find(1) //returns record ok @test.test_type //returns nil @test.test_type = testtypes.find(1) //nameerror: uninitialized constant tests::testtype @test.test_type //still nil according output finds type in database doesn't seem able add test class indicates me relationship not working. is able tell doing wrong? does work if change 1 line of code belongs_to :test -> has_one :test make one-on-one relationship. think error comes fact have not added test_type instance test_type attribute of test o

sql server - Need help to execute SQL in text file with SQLCMD -

i want load excel file ( .xls ) table in database. database on own computer , have sa account in sql server 08. excel file contains - id name 1 dog 2 cat 3 fish the file ( demo.txt ) sql code: insert [mydb].[dbo].[relative] select * openrowset('microsoft.jet.oledb.4.0','excel 8.0; database=c:\my temp files\excel','select * [sheet1$]'); the sqlcmd code: sqlcmd -s mypc\sql2008 -i "c:\my temp files\sql\demo.txt" the error in sqlcmd : msg 7308, level 16, state 1, server mypc\sql2008, line 1 ole db provider 'microsoft.jet.oledb.4.0' cannot used distributed queries because provider configured run in single-threaded apartment mode. a fix (which not solve problem) above error http://blog.sqlauthority.com/2010/11/03/sql-server-fix-error-ms-jet-oledb-4-0-cannot-be-used-for-distributed-queries-because-the-provider-is-used-to-run-in-apartment-mode/ sp_configure 'show advanced options'

utf 8 - Convert Japanese characters to UTF-8 for php json_encode -

i have japanese string in (utf-8 encoded) database '利用規約' passed php's json_encode function , receive warning: php warning: json_encode(): invalid utf-8 sequence in argument is there way convert valid utf-8 in order avoid this? if db utf-8 why php have problem string? update: turns out error in fact due problem sprintf , multibyte characters couple lines earlier. utf8_encode should work you. http://www.php.net/manual/en/function.utf8-encode.php if utf8_encode doesn't work, try mb_convert_encoding: mb_convert_encoding($string,"utf-8","auto");

java - printing partitioned set in partition prob -

in partition problem have understood pseudo polynomial time algorithm.but not able print balanced set . i not able figure out store instead of boolean values in table constructed algo. please provide algo print partitioned subset also. can provide solution in can modify table constructed achieve partitioned values. solving partition problem based on formulas: d(i,0) = true d(0,x) = false if x!=0 d(i,x) = d(i-1,x-arr[i]) or d(i-1,x) in order reproduce actual element can store matrix, indicated if element taken or not, let matrix q . in other words, q(i,x) = true if , if d(i-1,x-arr[i]) = true . now, can reproduce set with: set1 = {} set2 = {} x = sum/2 n 0 decreasing: if q(i,x): x = x - arr[i] set1.add(arr[i]) else: set2.add(arr[i]) an alternative not require constructing second matrix q , , instead retraces steps. basic idea similar previous one. set1 = {} set2 = {} x = sum/2 n 0 decreasing: if d(i-1,x-arr[i]): // ^^ con

Cannot start Spring Tool Suite server -

i've downloaded sts , create mvc project. run dynamic web , error. how fix? environment: ubuntu 12.10, springtoolsuite 3.5.0. publishing configuration... error copying file /home/hieugioi/programs/springtoolsuite/vfabric-tc-server-developer-2.9.5.sr1/base-instance/backup/catalina.policy: /home/hieugioi/programs/springtoolsuite/vfabric-tc-server-developer-2.9.5.sr1/base-instance/conf/catalina.policy (no such file or directory) /home/hieugioi/programs/springtoolsuite/vfabric-tc-server-developer-2.9.5.sr1/base-instance/conf/catalina.policy (no such file or directory) error copying file /home/hieugioi/programs/springtoolsuite/vfabric-tc-server-developer-2.9.5.sr1/base-instance/backup/catalina.properties: /home/hieugioi/programs/springtoolsuite/vfabric-tc-server-developer-2.9.5.sr1/base-instance/conf/catalina.properties (no such file or directory) /home/hieugioi/programs/springtoolsuite/vfabric-tc-server-developer-2.9.5.sr1/base-instance/conf/catalina.properties (no such file or

ios - Cant get FBGraphUser email -

i use facebook login app. (facebook ios sdk version 3.11.1) i ask "email" permission: nsarray *permissions = [nsarray arraywithobjects: @"basic_info", @"email", nil]; most of time, user's email that: nsstring *email = [user objectforkey:@"email"]; //user (nsdictionary<fbgraphuser> *) sometimes don't. (i can see nsdictionary not including email). i using fix app won't terminate when use email later , nil: nsstring *email = [user objectforkey:@"email"] ? [user objectforkey:@"email"] : @"no_email"; but need real mail, have come new solution. haven't noticed special problematic users. ideas can problem? it appears known problem... many reasons, not on facebook have email address registered. but said, problem need real mail. simplest solution use user's facebook email : user_name@facebook.com nsstring *email = [user objectforkey:@"email"] ? [user object

database - SQL script to get information to add to the DB -

i trying create swl script prompt user information added database. prompting user date , store name. after user enters store name want run query return code associated store name , assign variable. when run script, after user enters store name, happens: enter date of expense:01-01-13 enter store name expense against:meted 12 i not sure doing wrong new writing sql scripts. below script file appreciate help/tips. thank you. p.s., amusing sql plus / oracle. accept edate prompt 'enter date of expense:'; accept storename prompt 'enter store name expense against:'; declare v_storecode varchar; begin select code v_storecode store storename = '&storename'; end; insert expmast (expnum, edate, storecode) values(seq_expmast.nextval, to_date('&edate','mm-dd-yy'), 'v_storecode'); the 12 line number, because you're being prompted input. sql*plus expects / on new line execute anonymou

AngularJS filtering on categories -

i started playing angularjs earlier today , decided build simple app consists of categories containing items. the app has sidebar categories listed ( aside.navigation ) , main view items listed. plan load items ( $scope.items ) <ul> , filter them when user clicks on 1 of categories in sidebar. i tried couple of things, including simple filter withing html, , custom filter function. can't work. best way this? this html <html ng-app="stash"> ... <body ng-controller="stashctrl"> <div id="stash"> <aside class="navigation"> <h1 class="logo"><a href="#"><strong>stash</strong>.io</a></h1> <ul> <li class="icon-latest active"><a href="#">latest</a></li> <li class="icon-star"><a href="

php - how pagination work with sorting and search function -

i facing problem in pagination, searching , sorting function. function if dint combine pagination. once sorting, result did not change @ every page mean change in current page. example, @ page 2 ,then sorting,the result in page 2 have change due sort by.however, other page did not change , still default.may know going wrong. appreciate help. <?php include('db_connection.php'); $sql = "select count(*) product"; $r = mysql_fetch_array(mysql_query($sql)); $numrows = $r[0]; // number of rows show per page $rowsperpage = 2; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // current page or set default if (isset($_get['currentpage']) && is_numeric($_get['currentpage'])) { // cast var int $currentpage = (int) $_get['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page greater total pages... if ($currentpage > $totalpages) { // set current page last page $currentpag

Wordpress menu in Codeigniter controller -

i try call codeigniter controller outside of box wordpress blog menu, following error fatal error: cannot redeclare site_url() (previously declared in /../system/helpers/url_helper.php:53) public function getwordpressmenu() { ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1); // no theme output define('wp_use_themes', false); // initializes entire wordpress require $_server['document_root'] . 'blog/wp-blog-header.php'; wp_nav_menu('your_theme_menu_location'); } i know both of frameworks have same function there way disable on of inside of controller? in codeigniter can replace helpers creating new file @ application/helpers in case, can create new file @ application/helpers name url_helper.php just copy url_helper.php folder system/helpers , copy application/helpers/ . open file url_helper.php , rename fun

ios - Should I remove notification for NSUbiquitousKeyValueStoreDidChangeExternallyNotification -

i using tutorial started: http://www.raywenderlich.com/63269/how-to-save-your-game-data-tutorial-part-2-of-2 i have use it, implemented , test , working fine. here found notification should removed in dealloc (at end of article) http://subjective-objective-c.blogspot.com/2011/04/avoid-nsnotification-removeobserver.html my question should remove notification nsubiquitouskeyvaluestoredidchangeexternallynotification? , in method ? in general, notification, stop observing when no longer care notification. 1 case don't care more when object observing notification gets deallocated. what second article telling removeobserver: not best choice. removes observer all notifications. includes notifications registered notifications frameworks use internally. article explains, it's better use removeobserver:name:object: explicitly unregister each notification. it's not telling you should unregister notifications in dealloc , it's telling you should unregis

java - @Secured in @Autowired controller does not work -

using @secured annotation in container @autowired not working. @controller @requestmapping("/") public class hellocontroller { @autowired private applicationcontext applicationcontext; @modelattribute private string test() { // applicationcontext null return "test"; } @secured("role_user") @requestmapping(value = "test", method = requestmethod.get) public string printwelcome(modelmap model) { // applicationcontext null model.addattribute("message", "hello world!"); return "hello"; } } i think problem when using @modelattribute method private, in runtime controller created proxy object in case, fails spring dependency injection. accessing property applicationcontext causes nullpointerexception. i have never seen recommendation (or rule) create methods width @modelattribute annotation public. code works fine without @secured annota

php - missing images and old links after migrating Prestashop website -

i migrated prestashop website new server working there there navigation links going old domain , on home page images missing. on other pages images showing image path old domain. me changed url in seo & url under prefernces. cleared cache , changed shop_url in database also. nothing helped. new link http://216.144.246.92/ this issue because of not updating site url in database . just search main domain in sql file(database backup). of knowledge need replace above 50 places our new site domain url . we tried , after changing main site url (localhost/presta/any, if working in local) works fine. hope helps.

three.js textures distorsion -

Image
i have problem textures presentation (no matter if repeated 1 or whole picture - .png file). can see there bizzare distorsion , wonder if there way preserve it. var imgfiles = []; //imgfiles[0] = "img/versimlin.png"; //imgfiles[1] = "img/versimlin.png"; //imgfiles[2] = "img/horsimrnd.png"; imgfiles[3] = "img/horsimrnd.png"; //imgfiles[4] = "img/versimlin.png"; //imgfiles[5] = "img/versimlin.png"; var viewcubematerials = []; (var = 1; i<7; i++){ viewcubematerials[i-1] = new three.meshbasicmaterial({ map: three.imageutils.loadtexture(imgfiles[i-1]), side: three.doubleside }) } var viewcubegeometry = new three.cubegeometry( 1680,600,1680,1,1,1 ) var viewcube = new three.mesh(viewcubegeometry, new three.meshfacematerial(viewcubematerials )); scene.add(viewcube); as can see there nothing special within code might question of

Android 4.4 Kitkat and second external storage -

there has been written lot kitkat external sdcard write permission it's not clear me how works. unfortunately don't have kitkat device sdcard slot. question is, can write secondary external storage @ all? based on the docs . apps must not allowed write secondary external storage devices, except in package-specific directories if in understand it, if don't have permission can write app specific folder on primary external storage /sdcard/android/data/package/... , app specific folder on secondary external storage /extsdcard/android/data/package/... and write_external_storage can write locations on primary external storage /sdcard/* can't write location on secondary external storage (except app specific folder)? thanks answers! your analysis correct, other assuming primary external storage /sdcard (the exact path varies device, os level, , user account android 4.2+ tablets). here blog posts wrote on external storage , removable ("seco

Suggestion for WHERE condition in SQL Server -

here's edited code: code more close actual code running. gives me records except cancelled records. want include cancelled records not null fields in prod columns. select appid, prod1, prod2, prod3, prod4, prod5, prod6, prod7, prod8, case when len(prod1) > 0 or len(prod2) > 0 or len(prod3) > 0 or len(prod4) > 0 or len(prod5) > 0 or len(prod6) > 0 or len(prod7) > 0 or len(prod8) > 0 1 else 0 end nbrincomplete (case when left(productshortname, 2) in ('ct', 'gr') 1 else 0 end = 0) , (ctracks.ctrack null) , (appinitiateddate >= @startdate) , (appinitiateddate < @enddate) , (status <> n'cancelled' or status null) or (case when left(productshortname, 2) in ('ct', 'gr') 1 else 0 end = 0) , (ctracks.ctrack null) , (status <> n'cancelled' or status null) , (case when len(prod1

java - Why am I getting a NullPointerException even through a check? -

stack trace: java.lang.nullpointerexception @ testslot.isinternetexploreravailable(testslot.java:274) @ webproxyhtmlrendererbeta.getsingleslothtml(webproxyhtmlrendererbeta.java:168) // rest irrelevant testslot#isinternetexploreravailable() public boolean isinternetexploreravailable() { if (currentsession.get("isinternetexploreravailable") != null) // line 274 return (boolean) currentsession.get("isinternetexploreravailable"); return false; } currentsession.get(string key) simple fetcher fetch hashmap<string,object> ...getsingleslothtml() else if (browsername.contains(browsertype.ie) || browsername.contains(browsertype.iexplore)) if (!s.isinternetexploreravailable()) { // line 168 htmlclass += "browsernotavailable "; imgsrc = imgsrc.split(".png")[0].concat("_unavailable.png"); title = "browser not available"; } else { htmlclass += "browser

php - While loop inside if else statement not working -

i have code snippet failing work, don't know doing wrong, getting content mysql database , using if else statement while loop echo contents. <?php if ($row_item['cat_item_id'] == ''){ echo '<div class="col-sm-6 col-md-3""> </p> <p> no item show </p> </div> </div>'; } else { while ($row_item = mysql_fetch_assoc($item)){ echo ' <div class="col-sm-6 col-md-3" style="'.$row_item['display'].'"> <div class="thumbnail"> <img src="myaccount/user_data/'.$row_item['file_name&

javascript - How can i change the rotation icon in fabricjs -

please guide me modify fabricjs add custom icon rotation. i of answers not working fine. please let me know code change particular rotation icon only. for fabricjs above 1.6.6 changing function object prototype drawcontrols, small changes on hasrotation condition, result can seen jsfidle fabric.object.prototype.drawcontrols = function (ctx) { if (!this.hascontrols) { return this; } var wh = this._calculatecurrentdimensions(), width = wh.x, height = wh.y, scaleoffset = this.cornersize, left = -(width + scaleoffset) / 2, top = -(height + scaleoffset) / 2, methodname = this.transparentcorners ? 'stroke' : 'fill'; ctx.save(); ctx.strokestyle = ctx.fillstyle = this.cornercolor; if (!this.transparentcorners) { ctx.strokestyle = this.cornerstrokecolor; } this._setlinedash(ctx, this.cornerdasharray, null); // top-left this._drawcontrol('tl', ctx, methodname,left,top); // top-right this._drawcontrol('tr&

java - Birt Dataset oda exception -

i using pojo data-source , creating dataset using business logic .i trying fetch data database , want set in particular field. have hourlyrate database according employee hourlyrate fetch calling service method. places calling getservice() . getting null value. but throws: org.eclipse.birt.data.engine.odaconsumer.odadataexception: cannot execute statement. org.eclipse.datatools.connectivity.oda.odaexception ; java.lang.reflect.invocationtargetexception @ org.eclipse.birt.data.engine.odaconsumer.exceptionhandler.newexception(exceptionhandler.java:52) @ org.eclipse.birt.data.engine.odaconsumer.exceptionhandler.throwexception(exceptionhandler.java:108) @ org.eclipse.birt.data.engine.odaconsumer.exceptionhandler.throwexception(exceptionhandler.java:84) @ org.eclipse.birt.data.engine.odaconsumer.preparedstatement.execute(preparedstatement.java:586) @ org.eclipse.birt.data.engine.executor.datasourcequery.execute(datasourcequery.java:972) @ org.ecl

mysql - I set a key in django's request.session , but has no effect -

i set jobfile key in session below: def getjoblist(request): joblist = request.get.get('job') jobliststr = joblist[0:-1] request.session['jobfile'] = jobliststr return httpresponse("ok\n") and check mysql database, rows increment, when test key ,it shows key not in session: if request.session.has_key('jobfile'): # return false; i didn't know why? you may need save session after adding new key request.session['jobfile'] request.session.save()

jquery - Issue with offset top on chrome -

Image
i issue òffset().top property in jquery. works on every browsers except chrome. i'm working on table, offset().top on cells... my code : var topofcell = $('td').offset().top; var bottomofcell= $('td').offset().top + $('td').outerheight(); result on chrome : result on firefox, ie, ect... offset() method gets position relative document , may vary browsers browsers, using position() method solve problem gets position relative parent offset. , should apply css position in parent element. so, try using position() method or, may offset top getting value before content loaded try using on ready: $(document).ready(function(){ //do stuff here }); or, try using on window load function: window.onload = function(){ //do stuff here }

ios - Does my iPhone app have to work on iPad too? -

Image
i reading apple guidelines there point says iphone apps must run on ipad without modification, @ iphone resolution, , @ 2x iphone 3gs resolution does mean if app doesn't work fine on ipad, gets rejected? i'm posting here found many contradicting information regarding this. it means has run , not has optimized ipad. there big difference in that. don't have create ipad storyboard in order make app run on ipad - xcode lets ipad use iphone storyboard , open if iphone. view shrunk smaller rectangle. you aiming this:

asp.net - Transfer Data from azure VM to Azure Website instance in realtime -

i have multi-tier asp.net application , want move on azure cloud. currently workflow of application this: user uploads file, file processed , user gets live feedback of calculations. in documentation of azure read, azure website frontend , cloud service or vm businesslogic appoach. so calculations done in vm. uploaded data users in blob storage. vm , azure website can access them both right? for live feedback vm has send data azure website instance launched calculation. possible in way? believe solved webservices there prettier way in azure cloud? thanks help the uploaded data users in blob storage. vm , azure website can access them both right? yes. files stored in blob storage accessible both azure website , vm. for live feedback vm has send data azure website instance launched calculation. possible in way? believe solved webservices there prettier way in azure cloud? again, possible. 1 way handle communication utilizing messaging infrast

How to calculate distance between two android device using Bluetooth signal strength? -

i'm working on android application. in project want show bluetooth scanning device, mac address, bluetooth signal strength , distance between 2 android device. i have done 3 requirements don't know how distance using signal strength. package com.example.bluetoothdemo; import java.util.arraylist; import java.util.list; import java.util.set; import android.content.context; import android.content.intent; import android.content.intentfilter; import android.net.wifi.wifiinfo; import android.net.wifi.wifimanager; import android.os.bundle; import android.app.activity; import android.bluetooth.bluetoothadapter; import android.bluetooth.bluetoothdevice; import android.content.intent; import android.view.menu; import android.view.view; import android.widget.arrayadapter; import android.widget.button; import android.widget.listadapter; import android.widget.listview; import android.widget.textview; import android.widget.toast; import android.content.broadcastreceiver; public clas

asp.net - Calling a stored procedure with varchar as output parameter -

this question has answer here: ado.net - size property has invalid size of 0 7 answers i want assign output parameter of stored procedure session variable.so,basically,i looking call stored procedure has varchar out parameter.the stored procedure follows: alter proc spchecktaskperformed @taskid int, @email varchar(100), @status varchar(100) output begin select @status = status tbltaskperformed [email] = @email , [taskid]=@taskid end the code have below: private void checktaskperformed() { string cs = configurationmanager.connectionstrings["easyrozmoney_connectionstring"].connectionstring; using (sqlconnection con = new sqlconnection(cs)) { con.open(); sqlcommand cmd = new sqlcommand("spchecktaskperformed", con); cmd.commandtype = commandtype.storedprocedure;

javascript - How to move elements on scroll-down with scrolling down the page? -

please @ website . see in sections, when scroll down page, actual page not going down, elements , images start moving taking effect. did best implement such thing failed how can implement such thing (specially taking effect)? a nice site, , example of parallax scrolling . achieving site going take long time, can start looking @ parallax sites here , idea of source code , through demo's.

php - Syntax error when using simple query to database table -

i have simple setup in laravel while i'm learning , can't figure why i'm getting error. it's simple overlooking. i can this: route::get('users', function() { $users = user::all(); return view::make('users')->with('users', $users); }); example on laravel work perfectly, displaying information in users.blade.php view. in database have 'lists' table when copy structure of code above try , display lists receive following error. syntax error, unexpected '::' (t_paamayim_nekudotayim), expecting '(' on line $lists = list::all(); my code follows routes.php route::get('lists', function() { $lists = list::all(); return view::make('lists')->with('lists', $lists); }); list.php /models <?php class list extends eloquent {} lists.blade.php /views @extends('layouts.main') @section('content') @foreach($lists $list) <p>{{ $list->

asp.net - make the text for all textbox blue -

i have vb below: protected sub page_load(byval sender object, byval e system.eventargs) handles me.load textbox1.forecolor = system.drawing.color.blue end sub my multiline textbox <asp:textbox id="textbox1" runat="server" textmode="multiline" height="300px" width="99.6%" enabled="false" ></asp:textbox> i have 100 textboxes. wonder if there simple code can make of textboxes blue? thanks advice! best use css this: input[type=text] { color: blue; } it's practice have style defined in css file , reference asp.net page: <link rel="stylesheet" type="text/css" href="styles.css">

c# - Writing to text files using SaveFileDialog -

i'm working on add in microsoft excel in visual studio records balances each account (or worksheet) , saves them user-specified file. ability press button , select destination save work essential skill programmer, i'm perplexed why there little information on how it. closest thing found tutorial on msdn saves button icon image. the code i'm using follows: stringbuilder sb = new stringbuilder(); if (thisaddin.createdbudget) { string budget = "budget = " + thisaddin.blake.budget; savefiledialog savebudget = new savefiledialog(); savebudget.filter = "data files (*.dat)|*.dat|all files (*.*)|*.*"; savebudget.title = "save budget"; savebudget.showdialog(); if (savebudget.filename != "") { using (streamwriter sr = new streamwriter(savebudget.openfile())) { sb.appendline(budget); } } } else { messagebox.show("control disabled. budget not yet exist."

Open PDF-File in Android not working -

i try open pdf file apps directory through pdf viewer on device. packagemanager m = getpackagemanager(); string s = getpackagename(); packageinfo p; try { p = m.getpackageinfo(s, 0); s = p.applicationinfo.datadir; } catch (namenotfoundexception e) { log.w("error", "error package not found ", e); } intent intent = new intent(intent.action_view, uri.parse(s + "\\document.pdf")); intent.settype("application/pdf"); packagemanager pm = getpackagemanager(); intent crc = intent.createchooser(intent, "open file"); startactivity(crc); on test device pdf viewer installed. nevertheless i'm told no existing app able open file. doing wrong? if still interested, here solution: i changed code this: intent int

java - Return the index of the largest number in the array -

question: write method called largest takes array nums3 parameter. finds largest of numbers in array , returns index value of method. so know if return largest, that's value, how can return i, index? when compile, error: cannot find symbol i. public static int largest(int[] nums3) { int largest = nums3[0]; for(int i=0; < nums3.length; i++) { if(nums3[i] > largest) { largest = nums3[i]; } } return i; } one way can saving largest index, not value. need return value in case of empty array: public static int largest(int[] nums3) { if (nums3.length == 0) { return -1; } int largestindex = 0; for(int i=0; < nums3.length; i++) { if(nums3[i] > nums3[largestindex]) { largestindex = i; } } return largestindex; }

unity3d - Relational Queries In parse.com (Unity) -

i found example in parse.com. have 2 objects : post , comment, in comment objects have collumn: "parent" pointer post obj , want join them: var query = parseobject.getquery ("comment"); // include post data each comment query = query.include("parent"); query.findasync().continuewith(t => { ienumerable<parseobject> comments = t.result; // comments contains last ten comments, , "post" field // contains object has been fetched. example: foreach (var comment in comments) { // not require network access. string o= comment.get<string>("content"); debug.log(o); try { string post = comment.get<parseobject>("parent").get<string>("title"); debug.log(post); } catch (exception ex) { debug.log(ex); } } }); it worked! , then, have 2 objects: user , gamescore, in gamescore obj

python - Bash: Read UTC timestamp from a file and transform to Local Time for different Target Timezones -

i have utc timestamps in file generated using bash date following: 'sat mar 15 01:30:01 utc 2014' 'sat mar 15 01:30:16 utc 2014' 'sat mar 15 02:00:01 utc 2014' 'sat mar 15 02:00:12 utc 2014' i need transform timestamps local time of different regions. e.g. convert first entry above hongkong time, second singapore , on. can generate offsets can added local time. offsets following: 2:00 -5:00 . . one possible approach may parse date using python , add/subtract offset. however i'm wondering if can preferably in bash date . i've tried increment/decrement date such as: date -d 'sat mar 15 01:30:01 utc 2014 2 hours' however, above convert specified date system's date , add 2 hours, whereas need achieve particular target timezone , without having rely on specifying offsets manually. i avoid offset approach , specify target timezone directly. example convert date hong kong time using gnu date : $ tz='asi

android - Change corner radius of Imageview at runtime -

hello guys here xml file. want change corner radius of imageview @ run time in such way corner radius of bitmap in imageview should changed . have idea how can perform task. <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/maincontainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" > <tablelayout android:id="@+id/firstpictable" android:layout_width="102.5dp" android:layout_height="200dp" android:background="@drawable/tableborder" android:layout_margintop="5dp" android:padding="0.5dp" android:layout_marginbottom="5dp" > <imageview android:id="@+id/image1" android:layout_width="fill_parent" android:layout_height="fill_paren

Google Maps API and geocoding in Crimea -

i use google maps apis geocoding full address coordinates. worked fine before revolution in ukraine , fact crimea part of russian federation. result, nowadays receive this: { "results" : [], "status" : "zero_results" } do know wrong? thanks. fyi got answer google support: since crimea disputed territory ( http://en.wikipedia.org/wiki/list_of_territorial_disputes ), geocoder results not return results reverse geocoding.

windows phone 7 - Get list like CNN-app -

Image
i'm curious how (visual) list in cnn-app how multiple lines per item. if guess right searching listbox control. here , here examples may solve problem..

audio - Memory leak while playing sounds with java -

this code playing sounds: public class sound { public static void playsound(string path) { try { clip clip = audiosystem.getclip(); audioinputstream inputstream = audiosystem.getaudioinputstream(new file(path)); clip.open(inputstream); inputstream.close(); clip.start(); } catch (exception e) { e.printstacktrace(); } } } if call sound.playsound("xxx.wav"); many times see ram according task manager starts rise dramatically. how clean up? try close method. javadoc: void close() closes line, indicating system resources in use line can released. if operation succeeds, line marked closed , close event dispatched line's listeners.

Semi-random numbers generation in C++ -

this question has answer here: how select value list non-uniform probabilities? 4 answers suppose have set of numbers x = {0, 0, 0, 0, 1, 2, 2, 3}. there way me use rand() print out random numbers list proportion of generated numbers on time original proportion of numbers in set? in other words, proportion of zeros 0.5, ones 0.125, twos 0.25, , threes 0.125. you can specifying frequencies: #include <iostream> #include <random> int main() { using namespace std; mt19937_64 engine; discrete_distribution<int> numbers{4, 1, 2, 1}; cout << numbers(engine) << endl; }

javascript - How To Do Two Times String Charachets Replace/Remove at Once -

i have text string "1,000 kw" as var result = "1,000 kw" can please let me know how can clean display 1000 on 1 line? tried replace() as: var res1 = result.replace(',',''); var res2 = res1.replace(' kw',''); alert(res2); which working need have code in 1 line. thanks use regex replace that's not numbers nothing var res1 = result.replace(/\d/g,''); fiddle

regex - What is the RegExp Pattern to Extract Bullet Points Between Two Group Words using VBA in Word? -

Image
i can't seem figure out regexp extract bullet points between 2 group of words in word document. for example: risk assessment: test 1 test 2 test 3 internal audit in case want extract bullet points between "risk assessment" , "internal audit", 1 bullet @ time , assign bullet excel cell. shown in code below have pretty done, except cant figure out correct regex pattern. great. in advance! sub populateexceltable() dim fd office.filedialog set fd = application.filedialog(msofiledialogfilepicker) fd .allowmultiselect = false .title = "please select file." .filters.clear .filters.add "word 2007-2013", "*.docx" if .show = true txtfilename = .selecteditems(1) end if end dim wordapp word.application set wordapp = createobject("word.application") dim worddoc word.document set worddoc = wordap

c# - Office interop Chart autoscaling -

for generate 1 graph in word interop document use method below: public static void addsimplechart(document worddoc, microsoft.office.interop.word.application wordapp, string[,] data) { object omissing = system.reflection.missing.value; microsoft.office.interop.word.inlineshape oshape; object oclasstype = "msgraph.chart.8"; object oendofdoc4 = "\\endofdoc"; microsoft.office.interop.word.range wrdrng = worddoc.bookmarks.get_item(ref oendofdoc4).range; oshape = wrdrng.inlineshapes.addoleobject(ref oclasstype, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing, ref omissing); //demonstrate use of late bound ochart , ochartapp objects //manipulate chart object msgraph. object ochart; object ochartapp; ochart = oshape.oleformat.object; ochartapp = ochart.gettype().invokemember("application"

Read a specific word in a file PERL using regex -

i have configuration file name movie.conf , want read specific word in file. configuration file looks : #this movie setting #read movie source ffmpeg -f movie4linux2 -i /folder/movie1 -vcodec libx264 -preset ultrafast -tune zerolatency -s qvga -r 30 -qscale 5 -an -flags low_delay -bsf:v h264_mp4toannexb -maxrate 750k -bufsize 3000k -rfbufsize 300k -f h264 how can reads /folder/movie1 part using regex? can show me how. know using split can done. if want use regex on this? appreciated. if (/^ffmpeg.*-i\s+(\s+)/) { print $1; }

java - How to track users viewing habit -

i need keep counter couple of pages each user visits. lets need keep counter page 1 , 2. usera visits page 1 10 times therefore counter should 10, , userb visits page 1 5 times , page 2 7 times user's counter page 1 should 5 , page 2 should 7. countertable ( shows number of times each page has been visited each user) username page counter 1 10 b 1 5 b 2 7 to achieve this, have table in db keep usernames, page numbers , counters, every time user visits page associated counter in db incremented. my question that, if increment required counter, every time want retrieve pages (1 or 2) user needs wait application required record updated before visiting page. to avoid this, should use jms send asynchronous requests increment counters in database? option, use ajax maybe send async request server. is there more efficient method it? if not 1 more efficient? making assumption counter audit purposes instead of display purposes, o

c++ - OpenCV binary adaptive threshold OCR -

Image
i need convert images binary ocr. here functions using: mat binarize(mat & img, mat& res, float blocksize, bool inverse) { img.convertto(img,cv_32fc1,1.0/255.0); calcblockmeanvariance(img,res, blocksize, inverse); res=1.0-res; res=img+res; if (inverse) { cv::threshold(res,res,0.85,1,cv::thresh_binary_inv); } else { cv::threshold(res,res,0.85,1,cv::thresh_binary); } cv::resize(res,res,cv::size(res.cols/2,res.rows/2)); return res; } where calcblockmeanvariance : void calcblockmeanvariance(mat& img,mat& res,float blockside, bool inverse) //21 blockside - parameter (set greater larger font on image) { mat i; img.convertto(i,cv_32fc1); res=mat::zeros(img.rows/blockside,img.cols/blockside,cv_32fc1); mat inpaintmask; mat patch; mat smallimg; scalar m,s; for(int i=0;i<img.rows-blockside;i+=blockside) { (int j=0;j<img.cols-blockside;j+=blockside) {