Posts

Showing posts from February, 2015

python - How do hex escapes correlate with audio in PyAudio? -

i'm playing around pyaudio in attempt make microtonal music, can't seem off ground. found bit of code on using core audio in-program: http://code.activestate.com/recipes/578301-platform-independent-1khz-pure-audio-sinewave-gene/ , i've made small adjustments: import time import pyaudio # open stream stream=pyaudio.pyaudio().open(format=pyaudio.paint8,channels=1,rate=24000,output=true) # amount of time wave played in seconds length = 1 # generate 1khz signal @ speakers/headphone output # sine wave, 8 bit depth start = time.clock() while time.clock() - start <= length: stream.write("\x00\x30\x5a\x76\x7f\x76\x5a\x30\x00\xd0\xa6\x8a\x80\x8a\xa6\xd0") # close open _channel(s)_ stream.close() pyaudio.pyaudio().terminate() from understand, hex escapes raw audio being sent audio output. i've put them hex converter , graphed values. looks sin wave, i'm still no closer intuitive understanding of what's going on. eventual goal write function c

I want to encode Chinese to \\u5de5\\u4f5c formate in php. -

i want encode chinese \u5de5\u4f5c formate in php. there builtin php function or method ? the function json_encode() can used escape utf-8 encoded strings unicode format. example: <?php echo json_encode('工作'); output: "\u5de5\u4f5c"

css - Parallax Scrolling Imagery on different browsers -

i launched portfolio site , checking out on different browsers. underlying images becomes giant , takes entire screen (mainly on firefox). run ios yosemite on google chrome , looks great , works perfectly. parallax effect pure css. let me know think or how can fix this. thank you. bbennettdesign.com you using keith clark's pure css parallax effect , normally, changed items on parallax structure oneself. please remove styles , html markup , check it. if effect working, test specific codes. because effect work on firefox. browser support firefox, safari, opera , chrome support effect. firefox works there minor issue alignment. ie doesn't support preserve-3d yet (it's coming) parallax effect won't work. that's ok though, should still design content work without parallax effect - know, progressive enhancement , that! or can use this.

.net - How can I cancel Task.WhenAll? -

currenly using following code wait collection of tasks complete. however, have situation want able cancel/abort whenall call, via cancellation token preferably. how go that? dim taskcollection new list(of tasks.task) x integer = 1 threads dim newtask tasks.task = taskhandler.delegates(delegatekey).invoke(me, proxies, totalparams).continuewith(sub() threadfinished()) taskcollection.add(newtask) next await tasks.task.whenall(taskcollection) i'm assuming it's going along lines of next bit of code, i'm not sure go in 'xxx'. await tasks.task.whenany(tasks.task.whenall(taskcollection), xxx) use taskcompletionsource<t> create task asynchronous condition not have asynchronous api. use cancellationtoken.register hook modern cancellationtoken-based cancellation system cancellation system. solution needs combine these two. i have cancellationtoken.astask() extension method in asyncex library , can write own such: <system.ru

diff - Git show whole file changes -

is there way git show command show whole contents of file when viewing commit? example: if show like foo.cpp +++ int main() { +++ std::cout << "hello" << std::endl; +++ } i want output say: foo.cpp #include <stdio> //assuming earlier commit +++ int main() { +++ std::cout << "hello" << std::endl; +++ } is there simple way this? this kind of hack, git show (like git diff ) has -u option lets specify how many lines of context show. if use number that's bigger region between difference , start or end of file, it'll show whole file. if use big number, it'll work way want on (hopefully) file try on: git show -u99999

java - Other coreference resolution alternatives -

i'm working project requires use of coreference resolution sentences. tried out stanford corenlp's coreference resolution , works fine, though noticeably , expectedly run slower larger pieces of text i'm analyzing. could suggest alternative coreference resolution tools may run faster stanford's? (preferably in java or python) you may want try berkeley coreference resolution system (superceded berkeley entity resolution system or illinois coreference package . of them run on jvm (first 2 in scala).

Writing integers in binary to file in python -

how can write integers file in binary in python 3? for example, want write 6277101735386680763835789423176059013767194773182842284081 file in binary in 24 bytes (unsigned, working positive integers). how can this? tried following: struct.pack("i", 6277101735386680763835789423176059013767194773182842284081) this results in valueerror: cannot fit 'int' index-sized integer i have tried same other formats ("l", "q"), result in errors: struct.error: argument out of range if convert integer 24 bytes, able write file, since know how that. however, can't seem convert integers bytes. also, how make sure 24 bytes written per integer? writing smaller numbers (1000, 2000, 1598754, 12), should take 24 bytes. and how can read integers again file afterwards? with python 3 can following: i = 6277101735386680763835789423176059013767194773182842284081 open('out.bin', 'wb') file: file.write((i).to_bytes(24, byt

javascript - Group by on JSON array using Underscore JS -

i have json array object follows: var orders = [{ orderid: 1, firstname: 'john', lastname: 'smith', address: { street: '123 main street', city: 'new york', zip: 10001 } }, { orderid: 2, firstname: 'john', lastname: 'smith', address: { street: '456 main street', city: 'new york', zip: 10001 } }, { orderid: 3, firstname: 'john', lastname: 'smith', address: { street: '123 main street', city: 'new york', zip: 10001 } }, { orderid: 4, firstname: 'john', lastname: 'smith', address: { street: '123 main street', city: 'new york', zip: 10002 } }]; i trying use underscore.js create new array object, grouped address meet use case of displaying orders have been shipped 123 main street, new

angularjs - Angular reporting 404 on url source -

i have angular template: <div class="item holder" ng-repeat="article in articles"> <div class="col-xs-4 col-sm-4 col-md-3 holder imgholder"> <a href="{{article.articlelink}}"><img src="{{article.image}}" alt="" /></a> </div> </div> it shows list of articles. i'm getting following error on console: get http://example.com/%7b%7barticle.image%7d%7d 404 (not found) the template renders articles correctly error. why getting error? first take article.image , print console console.log , copy + paste url browser. browser 404 ? if happens wrong without url. if not case then: it looks angularjs replacing key characters url safe characters. try using ng-src="article.image" instead. if still getting 404 , still has %7d 's in output article.image console make sure string not bad.

ios - Error in NSDecimalNumberDivision: 'NSInvalidArgumentException', reason: '-[__NSCFNumber decimalNumberByDividingBy:]: unrecognized selector? -

my code // nsdecimalnumber *percentspent = [distributionmodel.spent decimalnumberbydividingby:self.monthlysummarymodel.totalspent]; // nslog(@"percent:%@", percentspent); nslog(@"spent:%@, totalspent:%@", distributionmodel.spent, self.monthlysummarymodel.totalspent); where @property (nonatomic, strong) nsdecimalnumber *spent; @property (nonatomic) nsdecimalnumber *totalspent; console log when percentspent commented out 2014-12-01 15:38:20.161 app-ios[15980:60b] spent:27.01, totalspent:2077.01 2014-12-01 15:38:20.201 app-ios[15980:60b] spent:2000, totalspent:2077.01 2014-12-01 15:38:20.251 app-ios[15980:60b] spent:40, totalspent:2077.01 2014-12-01 15:38:20.292 app-ios[15980:60b] spent:10, totalspent:2077.01 error when execute calculate percentspent 2014-12-01 15:35:44.843 app-ios[15963:60b] -[__nscfnumber decimalnumberbydividingby:]: unrecognized selector sent instance 0x17d4f020 2014-12-01 15:35:44.851 app-ios[15963:60b] *** termin

android - How to use adb pull with a directory name containing ® -

i backup photoshop touch files using adb pull in windows bat file. problem photoshop touch (using save gallery) stores files in /storage/sdcard0/pictures/adobe® photoshop® touch. cannot figure out how represent name special character. adb pull -a "/storage/sdcard0/picturesadobe® photoshop® touchadb" gives: remote object '/storage/sdcard0/pictures/adobe½ photoshop½ touch' not exist adb shell ls "/storage/sdcard0/pictures gives: adobe® photoshop® touch screenshots (actually special character appears different in cmd shell. copied there above.) i tried adb shell ls /storage/sdcard0/pictures/adobe*/ . | tr -s "\n\r" "\0" | xargs --verbose --null --max-args=1 adb pull -a gives: c:\android\platform-tools\adb pull -a remote object '/storage/sdcard0/pictures/adobe® photoshop® touch/1360025632957.p ng' not exist c:\android\platform-tools\adb pull -a remote object '/storage/sdcard0/pictures/adobe® photoshop® touch/136

php - Communicating between a page and a popup oauth page -

i have application has button opens blank page linkedin oauthentication. my question is, when user completes authentication , processing linkedin, how tell original page process complete? i thinking creating ajax method tells database user in oauth , when complete tell same database process on , original page find out. any ideas? see: how can oauth request open new window, instead of redirect user current page? the trick window.opener property, available popup. using simple reload window.opener.location.reload() or possibly more complicated using postmessage (in either case code live in page oauth redirects on completion).

simple social network using node.js and mongodb -

i trying build simple social network , following book(building node applications mongodb , backbone)( https://github.com/swiftam/book-node-mongodb-backbone/tree/master/ch10 ). however, realized node.js version has been updated. i tied solve issue got problem in chat.js states error: ch10/routes/chat.js:27 data.sessionstore.load(data.sessionid, function(err, session) { typeerror: cannot read property 'load' of undefined module.exports = function(app, models) { var io = require('socket.io'); var utils = require('connect').utils; var cookie = require('cookie'); this.io = io; //var session = require('connect').middleware.session.session; var sio = io.listen(app.server); sio.configure(function() { // utility methods see if account online app.isaccountonline = function(accountid) { var clients = sio.sockets.clients(accountid); return (clients.length > 0); }; sio.set('authorization', funct

Python Relative Imports and Packages -

i'm trying create package , have tree structure looks this: dionesus/ setup.py dionesus/ __init__.py dionesus.py dionesus.py has class called dionesus. init .py empty. how import class dionesus without having specify top level folder? i have do: import dionesus d = dionesus.dionesus.dionesus() i import statements like: import dionesus d = dionesus.dionesus() first, can still use absolute import, using from … import form: from dionesus import dionesus d = dionesus.dionesus() this problematic if ever need import both dionesus , dionesus.dionesus in same module, that's pretty implicit in desire give them both same non-disambiguated name… alternatively, if you're in parent or sibling or other relative of dionesus.dionesus, can use relative import. depending on are, it'll different (that's relative means, after all); may importing . , .dionesus , .. , etc. wherever is, it's same from … import form above, relative name in

postgresql - How to get current month and Last month in Redshift -

i wondering if can last month , current month in redshift? looked @ functions @ http://docs.aws.amazon.com/redshift/latest/dg/r_current_date_time_functions.html for current month, guess can following: left(current_date, 7) for previous month, came following: left(add_months(current_date, -1), 7) but wondering if there simpler way of doing these? select extract(month current_date); select extract(month current_date - '1 month'::interval);

apache pig - How to execute -fs in hadoop pig -

i want output files hdfs local storage ran code in pig script fs -get user/miner/adhoc/results/mine1.txt /home/miner/jeweler/results unfortunately executing code returns error 2997: encountered ioexception i saw default bootup file /var/lib/hadoop-yarn/.pigbootup not found do need import or need set properties in pig script? it seems path incorrect gives ioexception. root slash missing in path. correct path: /user/miner/adhoc/results/mine1.txt you can try also: fs -copytolocal /user/miner/adhoc/results/mine1.txt /home/miner/jeweler/results

How to leave a Hazelcast cluster gracefully? -

currently, when remove node (e.g. ip-2) call hazelcastinstance.shutdown() . still end seeing lot of warnings in logs, e.g. [ip-1]:5701 [xxx] [3.3.3] removing connection endpoint address[ip-2]:5701 cause => java.net.socketexception {connection refused address /ip-2:5701}, error-count: 5 [ip-1]:5701 [xxx] [3.3.3] node not have connection member [ip-2]:5701 [ip-1]:5701 [xxx] [3.3.3] hz._hzinstance_1_xxx.io.thread-in-0 closing socket endpoint address[ip-2]:5701, cause:java.io.eofexception: remote socket closed! is there more proper way remove nodes cluster? this recommended way. guess logging bit confusing.

postgresql - How can I load incrementally migrate data from PostgresSQL to HDFS? -

i have postgresql database use production server. want set hadoop/spark cluster run mapreduce jobs. in order need load data postgres database hdfs. naive approach have batch job once day dumps contents of database (120gb) hdfs. wasteful , costly. since data won't change 1 day next, theoretically cheaper , more efficient send diffs every day. possible? i've read little sqoop, , seems provide functionality want, requires making changes database , application. there way doesn't require making changes database? apache sqoop can connect postgresql database. sqoop provides incremental import mode can used retrieve rows newer previously-imported set of rows, i.e, can table updates happened between previous run , current run. no changes required database. using sqoop postgresql connector can connect sqoop database , incremental imports without database changes.

javascript - prevent multiple submission with button -

i viewing possibilities preventing multiple submission button tag. problem facing if users click submit button fast enable them submit multiple posts. restrict submission 1 submission. tried use onclick="this.disabled = true , makes button not working @ all. current button tag looks this: return "<button class='button btn btn-primary' id='gform_submit_button' onclick='this.disabled = true' type='submit'><span>submit!/span></button>"; can guide me how achieve this? ultimately, cannot prevent multiple submissions on client-side. have implement these security measures on server-side, in whatever server-side language using (e.g., php).

bash - Find string from a file to another file in shell script -

i new shell scripting. wanna know how can obtain result wanted following: i have 2 files (file_a , file_b) file_a contains: 09228606355,71295939,1,http://sun.net.ph/043xafj.xml,01000001c123000d30 09228505450,71295857,1,http://sun.net.ph/004xafk.xml,01000001c123000d30 file_b contains: http://sun.net.ph/161ybfq.xml ,9220002354016,93111 http://sun.net.ph/004xafk.xml ,9220002354074,93111 if url (4th field) in file_a present in file_b, out be: 09228505450,71295857,1,http://sun.net.ph/004xafk.xml,01000001c123000d30,9220002354074,93111 it display whole line in file_a , added 2nd , 3rd field of file_b. i hope question clear. thank you. this might work (gnu sed): sed -r 's/^\s*(\s+)\s*,(.*)/\\#^([^,]*,){3}\1#s#$#,\2#p/' fileb | sed -nrf - filea this builds sed script fileb , runs against filea. second sed script run in silent mode , lines match sed script printed out.

node.js - Force login a user as a locally generated user when using OAuth2 strategy in PassportJS? -

is possible force login user locally generated user when using oauth2 strategy in passportjs? need force login of specific user purposes of developing on local. maybe manually generating auth cookie or something? turns out login method used this. in route handler, put this: if req.headers.host == 'localhost' user = {id: 109593029532252360621} req.login user, (err) -> if !err return res.redirect('/')

Android set style rule of parent element based on child element value -

given layout named rellayoutwrap.xml: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativelayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <textview android:id="@+id/priorityview" android:layout_width="50dip" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/statuscheckbox" android:layout_alignparentright="true" android:layout_aligntop="@+id/statuslabel" > </textview> </relativelayout> i apply different background color relative layout parent element based on value of textview element. the value of textview element can change inflate/recycle view. ie.: layoutinflater inflate

javascript - Trying to Understand How jQuery calculates computed properties for IE8 using currentStyle -

i'm trying understand how jquery arrives @ pixel values ie8 when dealing non-pixel based property values, such margin-top: 2em , or height: auto . ie9+, getcomputedstyle() can provide easily, in case of ie8, currentstyle not. trying arrive @ solution can calculate total height of element, including css height, padding, border, , margin browsers ie8+. have come across following answer, can't understand going on in accepted answer. cross-browser (ie8-) getcomputedstyle javascript? i wondering if explain going on in code? here shim computed style webplatform. if (!window.wpo) { window.wpo = {}; } if (!wpo.utils) { wpo.utils = {}; } wpo.utils.getcomputedstyle = function(_elem, _style) {// wpo getcomputedstyle shim. var computedstyle; if (typeof _elem.currentstyle != 'undefined') { computedstyle = _elem.currentstyle; } else { try{computedstyle = document.defaultview.getcomputedstyle(_elem, null);}catch(e){return ''

javascript - I can't pass a variable from my jQuery code to my PHP code -

i'm trying pass variable jquery code html/php code using ajax , post, error message "notice: undefined index: testdata in c:\xampp\htdocs\teszt\test1.php on line 9". i'm using xampp, i'm running code in localhost, i'm using mozilla firefox , here's html/php code (test1.php): <!doctype html> <html lang="hu"> <head> <title>test</title> <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head> <body> <?php echo "<p class='testparagraph'>" . $_post['testdata'] . "</p>";?> <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript" src="http:

ios - App Rejected - Crashes on Launch unable to replicate -

i have app works when test on device, after submitting apple review, told app crashes @ launch. further investigation of symbolicated crash log showed there wrong below function ( line 131: self.highscore = leaderboardrequest.localplayerscore.value ) anyone see before? i'm thinking has 64bit architecture can't replicate error. func gethighscore(leaderboardid: string) { let localplayerid = gklocalplayer.localplayer().playerid let leaderboardrequest = gkleaderboard(playerids: [localplayerid]) gkleaderboard! leaderboardrequest.identifier = leaderboardid if leaderboardrequest != nil { leaderboardrequest.loadscoreswithcompletionhandler({ (scores:[anyobject]!, error:nserror!) -> void in if error != nil { //handle error log.debug("error retrieving score") } else { log.debug("here go: \(leaderboardrequest.localplayerscore.

string - Strncpy Causing Segmentation Fault c++ -

i have c++ program reads text file , converts text file string. then, converts string character array using strncpy. have seen stackoverflow question on strncpy , taken necessary precautions in order avoid issues causes when creating array. please explain why still causes stack error. #include <iostream> #include <string.h> #include <random> #include <fstream> #include <istream> #include <sstream> #include <stdio.h> using namespace std; int main() { //open stream reader ifstream fin; //opens text file in stream reader fin.open("songlyrics.txt"); //will used aggregate characters in text file string song; //used pointer when reading each character in text file char ch; //while end of file not reached while(!fin.eof()) { //get character file , add song string fin.get(ch); song += ch; } //close file fin.close(); //make character array called lyrics

mysql - display sub-menu of parent menu from parent id php -

<?php $page= $objpage-> get_page(); $id = isset($_get['id']); $child= $objpage-> get_child_page($id); ?> <ul class="nav nav-tabs"> <li role="presentation" class="dropdown"> <?php while($row = mysql_fetch_array($page) ) { ?> <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria- expanded="false"> <?php echo $row['title']; ?> <span class="caret"></span> </a> <?php } ?> </li> </ul> function get_page : function get_page($id="") { $sql = "select "; if( !empty($field) ){ $sql .=" title page page_id>1 " ; } else { $sql .= " * page "; } if( !empty($id) ){ $sql .=" page_id=".$id; } else { $sql .=" parent_id= -1&quo

c# - How to solve "Report item not linked to Dataset" error in RDLC? -

Image
i using visual studio 2010 , have created rdlc report without using report wizard , added dataset when right click on textbox,choose expression , navigate datasets see dataset added report when click on fields shows "report item not linked dataset". not facing issue in vs 2008 , report works correctly in it. don't know how solve issue in vs2010. me regarding issue. have attached screenshot of issue below. please check it. the code used display values in table given below know how display values in textboxes instead of table. protected void page_load(object sender, eventargs e) { localreport lr = null; dataset ds = new dataset(); con.open(); sqlcommand cmd = new sqlcommand(); sqldataadapter da = new sqldataadapter("select catalogno catalogno, productname productname, quality_plan_ref_no qprefno,drawing_no drawingno,isr_no isrno,batchno batchno,allotted_qty allottedqty,convert(varchar(10),allotted_date,105) allotteddate batch_allott cata

how to bind data to gridview in windowsApplication C# -

i have below code in button. clicking button , retrieve data sql server , display in gridview. can retrieve , filled in dt.but data not shown in grid view, theproblem? please crack me out. private void gvipretrieve_click(object sender, eventargs e) { connstring(); conn.open(); using (sqlcommand cmd = new sqlcommand("gvretrieve_ip", conn)) { cmd.commandtype = commandtype.storedprocedure ; using (sqldataadapter sda = new sqldataadapter(cmd)) { using (datatable dt = new datatable()) { sda.fill(dt); datagridview2.datasource = dt; } } } } make sure there no gridview in windows application.there control show data in form of rows , columns i,e datagridview.here best useful link binding data sql server database through datatabl

ios - How can I programmatically find Swift's version? -

i know can find version of swift i'm running right reverting terminal , typing: xcrun swift --version swift version 1.1 (swift-600.0.57.4) target: x86_64-apple-darwin13.4.0 also, i've been reading preprocessor macros in swift, no luck finding swift version constant. as swift 1.2 approaches nice flag old code runs on swift 1.1 (xcode 6.2) or new code needs xcode 6.3 (swift 1.2) note: can use system() like: system("xcrun swift --version | grep version > somefile.txt") then open somefile.txt, rather prefer simpler solution you can use conditional compilation directives test specific swift version used build project: #if swift(>=3.0) print("hello, swift 3!") #elseif swift(>=2.2) print("hello, swift 2.2!") #elseif swift(>=2.1) print("hello, swift 2.1!") #endif

node.js - Soft delete in Sails/Waterline -

trying delete user model using: //hard delete user.destroy({id:userid}, function(err, res){ //hard delete }) i need soft delete on user model , setting flag isdeleted true on delete , updating document: updateuser.isdeleted = true; user.update({id:userid}, updateuser, function(err, res){ update project }) and while fetching documents doing check if isdeleted - true or not. there in-built feature provided sails or waterline can configure perform soft delete , avoid updating , fetching based on isdeleted flag? you can use beforefind() life cycle function filter of soft deleted records model: parrot,js module.exports = { attributes: { // e.g., "polly" name: { type: 'string' }, // e.g., 3.26 wingspan: { type: 'float', required: true }, // e.g., "cm" wingspanunits: { type: 'string',

swing - Create Polygon with Mouse Listener Java -

import java.awt.event.*; import java.awt.*; import javax.swing.*; import java.util.*; import javax.swing.event.*; import javax.swing.jpanel; public class triangle extends jframe { public triangle() { add(new polygonspanel()); } public static void main(string [] args) { triangle t = new triangle(); t.setsize(500,500); t.settitle("triangle"); t.setvisible(true); t.setdefaultcloseoperation(jframe.exit_on_close); t.setlocationrelativeto(null); } } class polygonspanel extends jpanel implements mouselistener { private int x1,x2,x3,y1,y2,y3; @override protected void paintcomponent(graphics g) { super.paintcomponent(g); polygon p = new polygon(); p.addpoint(x1,y1); p.addpoint(x2,y2); p.addpoint(x3,y3); this.addmouselistener(this); g.drawpolygon(p); } public void mouseexited(mouseevent e) {

How to add Contact with birth date to Android using Cordova / Phonegap Contacts Plugin -

we facing issue while trying add birthday contact while using cordova android while adding new contact phonebook following part of code contact = navigator.contacts.create({ "displayname": displayname }); // store contact name var contactname = new contactname(); contactname.familyname = lastname; contactname.givenname = firstname contact.name = contactname; contact.birthday = new date("16 may 1984"); // save contact contact.save(); with above code, when data viewed in android phone, birthday save 29-12-6731 instead of expected 16-may-1984 we have tried possible combinations of date entry viz: 16-may-1984 ; 16/may/1984 ; 16/5/1984 ; new date(1984,05,16) but in vain results same. also need know how save anniversary date when using plugin ios, date saved 15-may-1984 (1 day less expected). looks issue still unresolved: https://issues.apache.org/jira/browse/cb-1602 the bug filed under https://issues.apache.org/jira/browse/cb-8115 not add

ios - Photos framework checking image type -

i have code fetching photos library , accessing types. have no idea how check whether image png or jpeg.? alassetlibrary can easily. want implement photos framework. have idea.? suggestions. in advance. try: let asset: phasset = ... let opts = phimagerequestoptions() // opts.synchronous = true // if want synchronous callback opts.version = phimagerequestoptionsversion.original phimagemanager.defaultmanager().requestimagedataforasset(asset, options: opts) { _, uti, _, _ in println(uti) } i don't know how without fetching actual data. to convert uti mime-type: import mobilecoreservices let uti = ... let mime = uttypecopypreferredtagwithclass(uti, kuttagclassmimetype).takeretainedvalue()

apache poi - paragraph.getRuns() to separate a paragraph -

when use apache poi change date of contract automatically, confused @ how dose paragraph.getruns() separate paragraph. have following paragraph 自 2014 年 10 月 1 日起至 2014 年 10 月 31 日止 i use following code see how many xwpfrun paragraph.getruns() return string currentparagraph = ""; for(xwpfrun xwpfrun : paragraph.getruns()){ currentparagraph += xwpfrun.gettext(0); system.out.println(currentparagraph); } i find first 5 number xwpfrun independently,eg ,2014,10,1 last number "31" separated 2 xwpfrun :"3", , "1"; this makes hard change date xwpfrun ,and want know how deal , how paragraph.getruns() works? sometimes text in docx files gets broken arbitrary number of runs. while inconvenient, it's not difficult deal with. the solution iterate runs in paragraph, , concatenate text each string. then, update date , store text of first run. las

Searching from a mysql database based on a string in php -

i have string foo = "a,b". want search in mysql database user_id while comparing string likes field. likes field has data in format interest => c v d b. different characters seperated space. tried using result not upto mark. how can go it? this code select user_id users interest %foo%; mysql not support multiple keyword search in set field, should add or condition of each search keyword regexp if format interest like=> a,c,v,d,b can use find_in_set() function otherwise regexp provide exact search. select user_id users interest regexp '[[:<:]]a[[:>:]]' , interest regexp '[[:<:]]b[[:>:]]' this query search a , b in field not aa , bbax like not support exact search.

xpath - R and xpathApply -- removing duplicates from nested html tags -

i have edited question brevity , clarity my goal find , xpath expression result in "test1"..."test8" listed separately. i working xpathapply extract text web pages. due layout of various different pages information pulled from, need extract xml values <font> , <p> html tags. problem run when 1 type nested within other, resulting in partial duplicates when use following xpathapply expression or condition. require(xml) html <- '<!doctype html> <html lang="en"> <body> <p>test1</p> <font>test2</font> <p><font>test3</font></p> <font><p>test4</p></font> <p>test5<font>test6</font></p> <font>test7<p>test8</p></font> </body> </html>' work <- htmltreeparse(html, useinternal = true, encoding='utf-8') table <- x

java - How to check if image file exists in classpath through gwt client side? -

i creating image object want set url of image dynamically. image img = new image(); if(vehicletype.equals("car")) img.seturl(images/car.png); else img.seturl(""); here, don't know if car.png exists in images folder in classpath. how can check existence? want set default vehicle image object if car.png not on classpath. thanks you can't check if image on class path client side. what can add errorhandler image adderrorhandler() method can detect if browser can't load image (because doesn't exist on server side example). image img = new image(); img.seturl("set url"); img.adderrorhandler(new errorhandler() { @override public void onerror(errorevent e){ // failed load image } }); note: there image.addloadhandler() method can use detect when image loaded. another way create method @ server side published in service checks if image availabe, , call method client code. a side note if

spring integration - ftp outbound channel adapter not transferring same files -

i have following configuration in application. writing file ftp folder , reading ftp location. i want take file ftp location , save in directory decided dynamically. done using 2 chained channel adapters. ftp nbound channel adapter picks file, puts in local directory , file inbound channel adapter picks file , puts in final destination. need filter old files process. ftp inbound channel adapter custom filter gave me ftpfile object in filtering method. object gives last modified date rather date file put in filter. due limitation had use file inbound channel adapter well. since not know how generate source directory dynamically, using plain java code copy required file local-directory ftp outbound channel picks , puts on ftp location. this configuration: <bean id="filenamegenerator" class="com.polling.util.filenamegenerator"/> <int-file:inbound-channel-adapter id="filesin" directory="file:${paths.root}" channel=&q

javascript - Accessing a particular DOM element -

how access <li>jquery chumps!</li> element? not have id i'm not sure do. i'm going store in variable <!doctype html> <html> <head> <title>simplify, simplify</title> <script type='text/javascript' src='script.js'></script> </head> <body> <div> remember! <ul> <li> <ol> <li>start function keyword</li> <li>inputs go between ()</li> <li>actions go between {}</li> <li>jquery chumps!</li> </ol> </li> <li>inputs separated commas.</li> <li>inputs can include other functions!</li> </ul> </div> </body> </

regarding array declaration in c++ -

int main(){ int n; scanf("%d",&n); int a[n]; } in above space array a[] , allocated ? in stack or heap ? if compiler compiles that, it's going on stack. in standard parlance, if care apply construct that's not standard-conforming, has automatic storage duration, meaning don't have clean , become invalid @ end of scope. what have there vla (variable length array), construct c allows have arrays dimensions known @ runtime. usually, way work similar "function" alloca , decreases stack pointer amount known @ runtime , "returns" pointer it. put "function" in quotes because doing requires low-level hackery that's not provided normal function scope semantics. vlas don't exist in c++, you're using compiler extension, , precise semantics of vlas in extension depend on compiler. since gcc, i'll leave link the relevant part of documentation .

javascript - Asp.net web api Session -

i'm not getting concept web api , session. i've created asp.net web api project , integrated angularjs in it.every time i'm gonna call web api. i have read articles state not use session in web api. understand web api stateless approach. agree. stil there way use session. first question: if, after login, want show user name on every page should web api approach???? second question: don't use session in webapi. other way/approach store client information safely. if use html5 local storage, can editable. if cookie used, can deleted. what , how should user till application in running mode? this semantics clouds discussion. people confuse session object statelessness. , say: 'don't use session because isn't stateless!'. however mean should strive have restful calls idempotent, meaning don't change behavior depending on whatever in background. session, or runtime-cache, or whatever use cache data, has no effect on stateless d

c# - How to add a menu for a grid panel on right click in Ext.NET from code -

i have created grid panel in code behind using c# , want add menu on right click button on row of grid panel using c# not ext.net tags. please? u can use rowcontextmenu here references offical web site of ext.net , forum page

php - Laravel Send Email with HTML Elements -

i trying send email using smtp in laravel html elements coming along in email body. i.e., i getting below mail <h2>welcome</h2><br><p>hello user</p><br><p>thanks</p> instead of welcome hello user thanks here code : what thing missing make applied on content of email $msg = "<h2>welcome</h2><br><p>hello user</p><br><p>thanks</p>" $message->setbody($msg); $message->to('user@gmail.com'); $message->subject('welcome mail'); try this... $msg = "welcome hello user thanks" $message->setbody($msg); $message->to('user@gmail.com'); $message->subject('welcome mail');

How to increase performance for HTTPS in Oracle Application Server? -

how can tune performance (by perhaps changing parameters) make https faster in oracleas? thank you please refer documentation tuning standards: https://docs.oracle.com/cd/e23943_01/core.1111/e10108/http.htm#asper99079 here relevant pieces effect ssl tuning in experience can make difference: section 5.4.1.1: sslsessioncachetimeout directive in ssl.conf determines how long server keeps saved ssl session (the default 300 seconds). session state discarded if not used after specified time period, , subsequent ssl request must establish new ssl session , begin handshake again. section 5.4.1.3: if large volumes of data being protected through ssl, pay close attention cipher suite being used. sslciphersuite directive specified in ssl.conf controls cipher suite. if lower levels of security acceptable, use less-secure protocol using smaller key size (this may improve performance significantly). finally, test application using each available cipher suite specified security

How to find the order changed contents in arrays using javascript? -

ex : original array : =[1,2,3,4,g,5] if user wrongly entered above array : = [2,1,3,4,g,5] how find position changed element original array list using javascript ?(i.e. [1,2] have been changed). // try entering @ prompt: [2, 1, 3, 4, 'g', 5] var original = [1, 2, 3, 4, 'g', 5], input = eval(prompt('enter array please.')); input.foreach(function (element, index) { var expected = original[index]; if (element !== expected) { // different. // logic handle difference goes here. example: console.log('elements different; ' + 'expected `' + expected + '\', ' + 'got `' + element + '\'.'); } });

java - NoClassDefFound in gradle scripts while working with google play services -

i facing strange problem. using google play services library dependency project. when run eclipse fine, when build apk gradle script, following exception java.lang.noclassdeffounderror: com.google.android.gms.analytics.googleanalytics strange part see class in .aar of library project when decompile final apk, class not present. not using proguard, not sure why class not being copied aar file final apk. any highly appreciated. thanks, i able solve problem.. reason why classes service play jar not being copied in apk because jar built on java 7 , dx tool not able process it. changed build tool version in gradle script 18.0.1(dx can process java 6) 19.0.3( dx tool can process java 7). other people.

hide - how to show attribute name and datatype on entity properties power desinger -

Image
i design schema name , datatype on entity properties hiding. how show it. please view image http://i.stack.imgur.com/7kxed.png i guess hidden resizing them 0 on list header. anyway... you can use customize columns , filter button on toolbar, unselect name & code, validate customize columns , filter dialog [ok] , go customize columns , filter , select name & code, validate [ok] , and columns should come default size.

R best way to produce and edit interactive plots like in MATLAB? -

it used case matlab better @ creating interactive plots. is, plots 1 able use mouse interactively change aspects of plot, height , width, x , y limits, position of legend, ... akin of having plot creation , and svg editor in same place. what best way achieve same goal in open source r? alternative being, produce plot r, save pdf or svg, open file open source svg editor inkscape, , edit layout of plot second step. is there r package in place? there few r packages allow jump either tcl or opengl world of interactive graphics (and believe x11 tools well). further, there package, name sadly escapes me @ moment, runs "on top of" base plotting tools , lets of interactive rescaling work. however, suggest spend little time learning ggplot , change approach graphics generation. unless intent manipulate graph in realtime for, e.g., presentation, it's more efficient edit grob object , replot until image want. remember, first rule of efficient programming

ios - Change setTitle to setImage -

i'm new developing excuse me if or ask doesn't make sense @ all. working on project in want play audio files mp3. allready made play pause button. got work music plays , when press on button "pause" text changes "play". want make playpause button image instead of plain text. "old" line of code: - (ibaction)playorpause:(id)sender { if(self.myaudioplayer.playing == yes) { [self.myaudioplayer pause]; [self.playpausebutton settitle:@"play" forstate:uicontrolstatenormal]; i tried changing last line setimage: [self.playpausebutton setimage:@"playicon.png" forstate:uicontrolstatenormal]; but doesn't seem work immediately. thanks you need use uiimage instance. try: [self.playpausebutton setimage:[uiimage imagenamed:@"play"] forstate:uicontrolstatenormal]; where @"play" name of image. (do not forget add images in project.)

Rest Service URI mapping to Java Inner Classes -

i have model rest service operations trying create uri hit java inner classes. let me know if can achieved using rest web service? using rest easy services. edit: (using code provided answer peeskillet) javax.ws.rs.processingexception: unable invoke request @ org.jboss.resteasy.client.jaxrs.engines.apachehttpclient4engine.invoke(apachehttpclient4engine.java:287) @ org.jboss.resteasy.client.jaxrs.internal.clientinvocation.invoke(clientinvocation.java:407) caused by: org.apache.http.conn.httphostconnectexception: connection http://localhost:8081 refused @ org.apache.http.impl.conn.defaultclientconnectionoperator.openconnection(defaultclientconnectionoperator.java:190) @ org.apache.http.impl.conn.managedclientconnectionimpl.open(managedclientconnectionimpl.java:294) @ org.apache.http.impl.client.defaultrequestdirector.tryconnect(defaultrequestdirector.java:643) @ org.apache.http.impl.client.defaultrequestdirector.execute(defaultrequestdirector.java:479) @ org.apache.http.impl.c

How can we add subtitles in video view in android 4.2.2? -

protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.videoview_main); mediaplayer mp=new mediaplayer(); videoview = (videoview) findviewbyid(r.id.videoview); } pdialog = new progressdialog(videoviewactivity.this); // set progressbar title pdialog.settitle("android video streaming tutorial"); // set progressbar message pdialog.setmessage("buffering..."); pdialog.setindeterminate(false); pdialog.setcancelable(false); // show progressbar pdialog.show(); try { mediacontroller mediacontroller = new mediacontroller( videoviewactivity.this); mediacontroller.setanchorview(videoview); uri video = uri.parse(videourl); videoview.setmediacontroller(mediacontroller); videoview.setvideouri(video);

function - Is this a legit javascript syntax? -

this question has answer here: what (function (x,y){…})(a,b); mean in javascript? 7 answers i want ask if following function declared correctly , if syntax possible. (function(){ $(document).on("click", ".mybutton", function(event) { if ($(this).attr("id") == "buttonauftrag") { $.mobile.changepage("#pagetwo"); } } )(); the function should triggered on button click. googled , never found syntax this. first line (function(){ , closing of function confusing me. there few things take care of (function() {//<-- function without name $(document).on("click", ".mybutton", function(event) { if (this.id === "buttonauftrag") {//<-- updated line $.mobile.changepage("#pagetwo"); } });//<-- added line })();//<-- e

php - CodeIgniter - Where to place scripts with -

i'm not sure if right place, since seem able answer anything, i'll give try... i trying convert website, use codeigniter framework, , going okay believe. followed tutorial , made controller, can show basic pages. however, place php scripts (like 1 logging in) in separate folder, have following: /application/ /views/ /pages/ /scripts/ / templates/ the pages subfolder 1 containing normal sites, whereas scripts folder contains scripts (sorry weird layout, using lists). tried modify controller pages, work on scripts, looks this: <?php class scripts extends ci_controller { public function run($page = 'home') { if ( ! file_exists(apppath.'/views/scripts/'.$page.'.php')) { // whoops, don't have page that! show_404(); } // connect database, using configuration /application/config/database.php $this->load->database(); // capitalize first lette

OrientDB : custom sort order for OIndexNotUnique -

i using graph api , have created index not_unique on string property. entryversiontype.createproperty('property', otype.string).createindex(index_type.notunique); now configure index sort algorithm. don't want use default sort order ( string::compareto(object) ). is there way register custom comparator ? i not aware of possibility change java.util.comparator used index engine. however, can create own index engine .

jquery - Correct way to launch a function from a href? -

following this stackoverflow example off launching twitter app within phonegap app.. i thought link below work not im guessing im lot launching function correctly? <a onclick="twittercheck()">launch twitter app</a> js in example: //twitter checker // if mac// var twittercheck = function(){ appavailability.check('twitter://', function(availability) { // availability either true or false if(availability) { window.open('twitter://user?screen_name=xerxesnoble', '_system', 'location=no');} else{window.open('https://itunes.apple.com/ca/app/twitter/id333903271?mt=8', '_system', 'location=no'); }; }); }; //if android var ua = navigator.useragent.tolowercase(); var isandroid = ua.indexof("android") > -1; //&& ua.indexof("mobile"); if(isandroid) { twittercheck = function(){ appavailability.check('com.twitter.android', function(avail

scala - Predicting an ordered sequence of future events? -

please advise on methods , models prediction of future events sequenced in time based on event history. spark mlib or weka machine learning libraries that? i need solve following problem: input data: huge (750 gb) set of records user reading history, record has following structure: userid, title, author, genre, date_read task: given partial reading history of user predict what next titles , in oreder read? more precise: system must predict ordered sequence of next titles user has read few ones available titles in data set. in other words predict ordered sequence of titles user started reading.

facebook - Spam in FB Comments, deleted app and still get notifications -

i've been getting spam comments months in 1 of apps. got annoying decided delete app. however, has not stopped issue. comments still come through , still notified. can't enter settings app it's deleted - how turn these notifications off?!

java - Issues with Spring Integration and process taking time and pausing -

i looking @ issue have in our application. spring integration being used poll particular directory , process files in directory. can process 5k 1kb files , there huge pause application doing nothing sitting idle , completes process in 4 minutes. next run take bit longer , 1 after takes longer , on until restart application goes 4 minutes mark. has experienced issue before. i wrote standalone version without spring integration , dont same issue. have below pasted xml config, incase have done wrong can't spot. thanks in advance. <!-- poll input file directory new files. if found, send java file object on inputfilechannel --> <file:inbound-channel-adapter directory="file:${filepath}" channel="inputfilechannel" filename-regex=".+-ok.xml"> <si:poller fixed-rate="5000" max-messages-per-poll="1" /> </file:inbound-channel-adapter> <si:channel id="inputfilechannel"