Posts

Showing posts from February, 2012

ruby on rails - Active Admin Exporting to CSV file -

i'm using active admin use admin functionalities in rails 4.0 application. have users table lists id name email phone no i have put button on top of list this. action_item only: :index link_to 'export csv', '#' end i want export users id name & email csv file when click on button. please me this just add section inside admin csv column :id column :name column :email end check active admin customize csv if open link, see line column(:author) { |post| post.author.full_name } it adds authors name post csv file, way can add field want

ubuntu - Angular2 Quickstart gulp error -

i trying angular2 quickstart application , running running errors when run gulp command. i have ubuntu 15.04. installed nodejs v0.10.25 , npm 1.4.21. installed gulp v3.9.0. cloned latest angular2/quickstart using git clone https://github.com/angular/quickstart.git hello2ng2 then went inside hello2ng2 folder , issued following command npm install and issued following command build quickstart app gulp i got following errors... not sure how fix it. looking help. [12:38:46] starting 'default'... [12:38:46] starting 'clean'... [12:38:46] finished 'clean' after 13 ms [12:38:46] starting 'build:ng2'... npm warn package.json angular2@2.0.0-alpha.30 no repository field. npm warn package.json rtts_assert@2.0.0-alpha.30 no repository field. npm warn package.json angular2@2.0.0-alpha.30 no repository field. npm warn package.json rtts_assert@2.0.0-alpha.30 no repository field. events.js:72 throw er; // unhandled 'error...

javascript - how to override dojo function -

i'd correct problem of incorrect week number in dojox/calendar/calendar. know change => exports._getweekofyear function in dojo/date/locale it works if put in js file, but, not want/cannot modify dojo's files. i wanted apply overriding solutions found here: http://g00glen00b.be/dojo-inheritance-overriding-extending/ or here without success syntaxerror: missing : after property id on line var obj = new exports(); code last try: require(["dojo/_base/lang", "dojo/date/locale"], function(lang, locale){ lang.extend(locale, { var obj = new exports(); obj._getweekofyear = function(/*date*/ dateobject, /*number*/ firstdayofweek){ if(arguments.length == 1){ firstdayofweek = 0; } var determinedate = new date(); determinedate.setfullyear(dateobject.getfullyear(), dateobject.getmonth(), dateobject.getdate()); var d = determinedate.getday(); if(d == firstdayofweek) d = 7...

ios - How to add Load more cell in UICollectionView? -

Image
i want add load more cell in uicollectionview ? can tell me how can add load button ? have created collectionview works fine want add load more button in bottom of collection view cell this here's collection view #pragma mark <uicollectionviewdatasource> - (nsinteger)numberofsectionsincollectionview:(uicollectionview *)collectionview { return 3; } - (nsinteger)collectionview:(uicollectionview *)collectionview numberofitemsinsection:(nsinteger)section { switch (section) { case 0: return 66; case 1: return 123; } return 31; } - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { nsuinteger row = [indexpath row]; nsuinteger count = [self.stockimages count]; if (row == count) { //add load more cell } democellview *cell = [collectionview dequeuereusablecellwithreuseidentifier:[democellview reuseidentifier] forindexpath:indexpat...

php - Codeigniter 3 - Session not working -

i have updated form 2.2.x 3.0.0 - following update procedure codeigniter's website http://www.codeigniter.com/userguide3/installation/upgrade_300.html i have having real issues new session library - heres issue. we have login section dependant on subdomain , user/pass credentials give privileges admin / reseller / client / user in order determine correct privileges user have built customer library (location:application/library) have called session_management, library not extend core session driver/library , never has , has no extension class, library auto-loaded, prior ci 3.0.0 working fine. first session_management __construct() $this->ci =& get_instance(); $this->ci->load->model('users'); $this->ci->load->model('clients'); $this->ci->load->model('sessions'); $this->ci->load->driver('session'); $this->ci->load->library('password_hash'); $this->ci->load->helper('ur...

Broken CSS keyframe animations when using WebPack's css-loader with UglifyJS plugin -

we're using este.js dev stack in our application uses webpack bundle js & css assets. webpack is configured use webpack.optimize.uglifyjsplugin when building production env , stylus-loader , exact loader configuration production env. follows: extracttextplugin.extract( 'style-loader', 'css-loader!stylus-loader' ); i have 3 styl files: // app/animations.styl @keyframes arrowbounce 0% transform translatey(-20px) 50% transform translatey(-10px) 100% transform translatey(-20px) @keyframes fadein 0% opacity 0 50% opacity 0 100% opacity 1 // components/component1.styl @require '../app/animations' .component1 &.-animated animation arrowbounce 2.5s infinite // components/component2.styl @require '../app/animations' .component2 &.-visible animation fadein 2s after production build, both keyframe animations renamed a (probably css minification css-clean ) , can deduce fadein ...

android - AutoCompleteTextView with SimpleCursorAdapter return NullPointerException on filtering -

i have autocompletetextview have linked simplecursoradapter . working fine , when user input characters not in database , filtering method returns null cursor. cause non-fatal nullpointerexception. code is madapter.setfilterqueryprovider(new filterqueryprovider() { @override public cursor runquery(charsequence constraint) { string partial = null; if(constraint!=null) partial = constraint.tostring(); cursor result= dbhelper.readproductcategory(partial); return result; } }); warning in logcat w/filter﹕ exception occured during performfiltering()! java.lang.nullpointerexception @ com.orderoapp.ordero.data.productdatabasehelper.readproductcategory(productdatabasehelper.java:70) @ com.orderoapp.ordero.ordersfragment$1.runquery(ordersfragment.java:87) @ android.support.v4.widget.cursoradapter.runqueryonbackgroundthread(cursoradapter.java:397) @ android.suppor...

objective c - CABasicAnimation stop animation on completion - iOS -

i have ios app using cabasicanimation on repeat: cabasicanimation *fadeanim = [cabasicanimation animationwithkeypath:@"opacity"]; fadeanim.fromvalue = [nsnumber numberwithfloat:1.0]; fadeanim.tovalue = [nsnumber numberwithfloat:0.2]; fadeanim.duration = 1.0; fadeanim.autoreverses = yes; fadeanim.repeatcount = infinity; [colourbutton.titlelabel.layer addanimation:fadeanim forkey:@"opacity"]; i have button when pressed meant stop animation. -(ibaction)stopanim { [colourbutton.titlelabel.layer removeallanimations]; } it works fine 1 thing noticing is stops animation suddenly, doesn't let animation finish. how can finish current animation , stop. (or in other words how can removeallanimations....withanimation ?). on side note, need include coreanimation framework work. far animation running , havn't imported coreanimation framework. thanks, dan. just add animation , after remove first 1 this: caba...

java - How to detect if the image contains the given object or area or these two images are the same in OpenCV -

Image
i want check if image contains given part (a small image in side it) or these 2 image same. better understanding question image bellow. the image looking inside images: some other images: these images not same size. images above first, third , forth images containing given image. so have tried 3 ways this: 1. first way using opencv norm function in opencv core class. 2. second way comparing histograms of images. 3. third way using algorithm fast , orb. but no 1 worked better me, first way working when 2 images same each other. second way working when 2 images same. third way working when part of images same. so cannot result using above ways. if can tell how this. note: using opencv 3 in java, surf , sift not supported. thanks in advance!

r - gvisTables not rendering in Shiny apps -

the actual issue i'm trying solve: i'm creating dashboard include data tables. numbers formatted commas thousands separators, there (apparently) issue dt package when it's used shiny, in comma-separated formatting causes dt::renderdatatable read in numbers character, affects how numbers sorted. (dt's number formatting functionality not work shiny, appears.) where i'm @ far: solution i've been able find use googlevis instead of dt create tables. i'm running different issue (described below), care having data tables comma-separated numbers sort numbers. the googlevis issue: when use gvistable outside of shiny apps, render fine, not render @ when using rendergvis , htmloutput in shiny. example, i'll borrow example 4 here. not using shiny, code looks this: library(datasets) library(googlevis) myoptions <- list(page='enable', pagesize=10, width=550) table <- gvistable(population,options=myoptions) plot(table) using shiny, it...

How to convert a HashMap to a K/V-String in Java 8 with Streams -

i want create string of key value pairs of hashmap<string, string> m fast possible. i tried: stringbuffer buf = new stringbuffer(); buf.append("["); (string key : m.keyset()) { buf.append(key); buf.append("="); buf.append(m.get(key)); buf.append(";"); } buf.append("]"); with java8 tried: m.entryset().stream() .map(entry -> entry.getkey() + " = " + entry.getvalue()) .collect(collectors.joining("; " , "[" , "]")); is there faster, better code that? seems costly append keys , values in map function, doesn't it? map -> map.entryset().stream().map(entry::tostring).collect(joining(";", "[", "]")) (note omitted imports.) like luiggi mendoza said: i not worry performance in case unless it's critical part of system , it's pointed out bottleneck usage of profiler or similar tool. if haven't ...

Meteor.setInterval on server side, Performance? -

i looking way clean of database entries might not need after 24hours or that, looking meteor code: https://github.com/meteor/meteor/blob/832e6fe44f3635cae060415d6150c0105f2bf0f6/packages/oauth/pending_credentials.js i found part: // periodically clear old entries never retrieved var _cleanstaleresults = function() { // remove credentials older 1 minute var timecutoff = new date(); timecutoff.setminutes(timecutoff.getminutes() - 1); oauth._pendingcredentials.remove({ createdat: { $lt: timecutoff } }); }; var _cleanuphandle = meteor.setinterval(_cleanstaleresults, 60 * 1000); i couldn't find exectuion of function. wondering if var _cleanuphandle means execute every 60 seconds? , if it's seems strange endless function run every 60 seconds? might general javascript question trying understand performance of kind of thing , if can safely re use technique? main goal store temporary data on server , remove after it's not needed. i recommend using task qu...

How to use Drupal rules to adapt content access permissions for nodes that are older than 1 week? -

i have special content type named "example". want show new nodes of type anonymous users of site. what need: after 1 week node created, content access permissions ( content access module installed) changed users particular role able see node. should triggered on cron or what? or how nodes older 1 week? could provide instructions on how that? because i'm new rules module , have no ideas. you should able rules (see this question , not want close), i'd go tiny custom module implementing hook_cron , fetch nodes creation date < (now - 1 week), , modify permissions each of them. it should more efficient rule approach explained in first link, need loop on nodes on each cron execution. , rules can quite more annoying writing plain php. prefer learning drupal api spending hours clicking in rules interface (rules great, it's hard). good luck

SQL Server, Count Consecutive Weeks Record Has Been in Top 5 -

i have complicated query: select rs.name, rs.sumhits, rs.weeknumber from( select name, weeknumber, sum(hits) sumhits, rank() on (partition weeknumber order sum(hits) desc) rank ( select name, datediff ( day, (select dateadd(wk, datediff(wk,0,(select min(table2.date) table2)), 0)), (table2.date) ) / 7 weeknumber, hits table1 inner join table2 on table1.nameid = name.id ) group name, weeknumber ) rs rank <= 5 order weeknumber desc which provides me top 5 "names" "hits" each week. i add field calculates number of consecutive weeks each name in week's top 5 has been in top five. so, column have value of 1 if name in week's top 5 not in last week's, value of 3 if name week's top 5 had been in top 5 previous 2 weeks, etc. what best way accomplish this? you think of query cte , add further information in follow-up ctes or final select: something this: with mycte ( qu...

floating point - Handling extremly small numbers in C++ -

let , b 2 numbers between 0 , 1. how calculate pow(a,10000)/(pow(a,10000)+pow(b,10000)) ? ex:- following code gives -nan output instead of 0.5 double = 0.5,b = 0.5; cout<<pow(a,10000)/(pow(a,10000)+pow(b,10000)); there no simple generic solution problem. writing computer programs dealing small and/or big numbers "art of science" - called numerical analysis. typical tricks involves scaling before calculating. in case each pow(..) rounded 0 because closest representable value real result. after 0/(0 + 0) nan, i.e. not number. you go long double: long double = 0.5; long double b = 0.5; long double c =pow(a,10000); long double d =pow(b,10000); cout << c << endl; cout << d << endl; cout<<c/(c+d); which result in: 5.01237e-3011 5.01237e-3011 0.5 but " while". increasing power bit (just zero) , problem back. long double = 0.5; long double b = 0.5; long double c =pow(a,100000); long double d =pow(b,100000)...

java - How to add a view (circular progress bar for example) relative to another view in a tablelayout -

Image
hope can advise. i have created android app in android studio dynamically , programmatically adds load of buttons tablelayout. number of buttons set user there 1 or there 100. using tablelayout added neatly 2 buttons each row , sized correctly. happy this. i add view (in form of circular progress bar) in front of each button when button pressed circle rotates while whatever button has been setup actioned. want progress bar preferably sit in middle of button i'm not overly fussy. can advice best way achieve this? need redo buttons in relative layout? there way of adding views on top of other views in table layout? advice or suggestions welcome. thank my current button code... (it assumes there 2 buttons on each row , know number of rows , number of buttons). tablelayout.layoutparams tableparams = new tablelayout.layoutparams(tablelayout.layoutparams.wrap_content, tablelayout.layoutparams.wrap_content); tablerow.layoutparams rowparams = new tablerow.layoutpara...

asp.net - MemoryCache.Default invalidated after first Request -

i have weirdest problem - started using memorycache , thought pretty straightforward... turns out isn't. empty asp.net mvc5 application, hosted on local iis 7.5 on first request value should have been added cache - if refresh page, cache should hold value. when debug application, breakpoint (on commented line) gets hit twice: on first request, on second request. after cached value can used. why cache not return value on first reload expected? public class temp { public int age { get; set; } } public class homecontroller : controller { public actionresult index() { var temp = (temp)memorycache.default.get("myval"); if (temp == null) { // gets hit on first 2 requests, after cache returns value temp = new temp { age = -127 }; memorycache.default.add("myval", temp, datetime.utcnow.addminutes(10)); } return view(); } } i not think need use memorycache ...

selenium webdriver - Set up Protractor tests with Jenkins -

i need protractor tests run using jenkins. know has been asked before, , this seems answer. i'm confused bash script comes , how move forward. here's i've got: protractor config file: var htmlscreenshotreporter = require('protractor-jasmine2-screenshot-reporter'); require('jasmine-reporters'); exports.config = { seleniumaddress: 'http://localhost:4444/wd/hub', capabilities: { 'browsername': 'chrome' }, framework: 'jasmine2', suites: {...}, jasminenodeopts: { showcolors: true, defaulttimeoutinterval: 10000 }, onprepare: function() { global.isangularsite = function(flag) { browser.ignoresynchronization = !flag; }; browser.manage().window().setposition(0,0); browser.manage().window().setsize(1280, 1024); } jasmine.getenv().addreporter( new jasmine.junitxmlreporter('protractor_output', true, true) ); } how can tests run jenkins? please help

angularjs - Change button colors dynamically using angular js -

i have 2 buttons in green , red color. want change color of button. suppose if click on red colored button green colored button change gray. when click on green colored button , red colored button change gray. how can achieve in angular js? please check working example: http://plnkr.co/edit/dhqr4amhbkqsgg4gwrb4?p=preview controller var app = angular.module('plunker', []); app.controller('mainctrl', function($scope) { $scope.click = ''; }); html <button ng-click="click = 'red'" ng-class="{'red': click == 'red' || click == '', 'grey': click == 'green'}"> red</button> <button ng-click="click = 'green'" ng-class="{'green': click == 'green' || click == '', 'grey': click == 'red'}">green</button> css .grey { background-color :#808080; } .red { background-color :#ff0000; } .gr...

c - How can an argument be different in the caller and the callee? -

i'm debugging program , ran across i've never seen before. below excerpt gdb . 1236 size = init_text_buffer(fn); (gdb) p fn $13 = 0x7fff1cd22d80 "-" (gdb) s init_text_buffer (fn=0xd00 <error: cannot access memory @ address 0xd00>) @ editors/vi.c:720 720 { the function init_text_buffer called char pointer value 0x7fff78136bd0 . step function argument suddently has different value. what possible causes of this? i'm not asking debug code (i didn't include how you?), need pointer in right direction. thing has left me no clues @ all. you should go hybrid assembly mode (ctrl+x 2) , stepi examine instructions being performed. had - in case optimization c code of course didn't reveal. in case, reveal memory overrun. worth shot.

jvm - Does RSS tracks reserved or commited memory? -

i'm running experiments different jvm options on java 8 in order lower rss: script used rss tracking: ps -o rss -o vsz -o pid $pid jvm args setting java process: -xx:+printnmtstatistics -xx:+unlockdiagnosticvmoptions -xx:nativememorytracking=detail taking baseline jcmd: jcmd $pid vm.native_memory baseline taking diff jcmd: jcmd $pid vm.native_memory summary.diff output (partial thread area): - thread (reserved=130696kb -21564kb, committed=130696kb -21564kb) (thread #121 -21) (stack: reserved=130048kb -21504kb, committed=130048kb -21504kb) (malloc=379kb -67kb #610 -105) (arena=268kb +7 #240 -42) question : memory taken account rss output above, committed or reserved ? the relation between reserved/committed , resident/virtual little more complex. rss covers pages resident in physical memory. things have been paged out ...

IOS resize or reposition line on touching end points (Objective c) -

Image
i trying resize line, touching red circle points. let's say, want move line above lips in image below, how can achieve this. line not moving position. have started thing , can't find relevant resources accomplish this. trying best...please guide me in right direction. below code , reference image. objective c code: - (void)viewdidload { [super viewdidload]; uibezierpath *path = [uibezierpath bezierpathwitharccenter:cgpointmake(100, 100) radius:10 startangle:0 endangle:6.2831853 clockwise:true]; //add second circle [path movetopoint:cgpointmake(100.0, 100.0)]; [path addlinetopoint:cgpointmake(200, 200)]; [path movetopoint:cgpointmake(200, 200)]; [path addarcwithcenter:cgpointmake(200, 200) radius:10 startangle:0 endangle:6.2831853 clockwise:true]; [path closepath]; [[uicolor redcolor] setstroke]; [[uicolor redcolor] setfill]; [path stroke]; [path fill]; cashapelayer *shapelayer = [cashapelayer layer]; shapelaye...

parsing - How do you parse and process HTML/XML in PHP? -

how can 1 parse html/xml , extract information it? native xml extensions i prefer using 1 of native xml extensions since come bundled php, faster 3rd party libs , give me control need on markup. dom the dom extension allows operate on xml documents through dom api php 5. implementation of w3c's document object model core level 3, platform- , language-neutral interface allows programs , scripts dynamically access , update content, structure , style of documents. dom capable of parsing , modifying real world (broken) html , can xpath queries . based on libxml . it takes time productive dom, time worth imo. since dom language-agnostic interface, you'll find implementations in many languages, if need change programming language, chances know how use language's dom api then. a basic usage example can found in grabbing href attribute of element , general conceptual overview can found @ domdocument in php how use dom extension has been covered exte...

material design - Android NavigationView sub-menu heading not showing -

Image
hi using android navigationview . have group of items , sub items menu items drawer. here sub-menu items appearing below divider after main menu items, problem heading sub menu not showing up. sub items showing just below divider without header. cant figure out problem. inserting menu tag inside sub items group , putting sub items inside menu tag fix issue makes sub items getting selected(appearing selected) after selecting 2 times. how can fix this? here code: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <group> <item android:id="@+id/nav_home" android:checkable="true" android:icon="@drawable/ic_person" android:title="item1" /> <item android:id...

qt - Accessing the value in Qmap with the help of its key -

i have qmap , have defined qmap<qstring,modelvariables>modelmap modelvariables structure parameters valueref , value , id . want access parameter value defined in structure. wrote following code shows error. float hxt_val_ft04 = modelmap.value("hxt_v_ft04"); error: expected primary expression before '.' token. mvariables["hxt_v_ft04"] return modelvariables object if there key matching "hxt_v_ft04" . otherwise default construct object , return it. can use mvariables["hxt_v_ft04"].value

subset - R: how to remove certain rows in data.frame -

> data = data.frame(a = c(100, -99, 322, 155, 256), b = c(23, 11, 25, 25, -999)) > data b 1 100 23 2 -99 11 3 322 25 4 155 25 5 256 -999 for such data.frame remove row contains -99 or -999. resulting data.frame should consist of rows 1, 3, , 4. i thinking of writing loop this, hoping there's easier way. (if data.frame have columns a-z, loop method clunky). loop this i = 1 for(i in 1:nrow(data)){ if(data$a[i] < 0){ data = data[-i,] }else if(data$b[i] < 0){ data = data[-i,] }else data = data } maybe this: ind <- reduce(`|`,lapply(data,function(x) x %in% c(-99,-999))) > data[!ind,] b 1 100 23 3 322 25 4 155 25

Update source to all excel links in word vba -

i trying update source links in word report using macro in word vba. want able offer dialog box user select file , replaces current source in links in word doc. code have below works slowly. seem have open excel in background or links wont work? not sure why is?? it seems go through eack link in tuen. there way globally change links @ same time possibly using find , repalce? please appreciated! need reprot in work , need find solution possible. private sub commandbutton1_click() dim oldfile string dim xlsobj object dim xlsfile_chart object dim dlgselectfile filedialog 'filedialog object ' dim thisfield field dim selectedfile variant 'must variant contain filepath of selected item dim newfile variant dim fieldcount integer ' dim x long on error goto linkerror 'create filedialog object file picker dialog box set dlgselectfile = application.filedialog (filedialogtype:=msofiledialogfilepicker) dlgse...

Timer in java, cant get the player to flinch 3 seconds -

i'm trying make player flinch when gets attacked. cant timer right, disable collision when mobs touch player cant able collision between player , mobs after 3 seconds. cant right.. please :/ code if(flinching == false) { if(tempobject.getid() == objectid.firstmob) { currenthealth = health; if(getbounds().intersects(tempobject.getbounds())) { currenthealth = health; health -= 5; flinching = true; long current_frame_time = system.nanotime()/1000000000; //seconds long last_frame_time = current_frame_time; long current_frame_time2 = system.nanotime()/1000000000; while(current_frame_time2 - last_frame_time != 3) current_frame_time2 = system.nanotime()/1000000000; if(current_frame_time2 - last_frame_time == 3) flinchin...

javascript - HTML5 Canvas image segmentation -

Image
i'm trying remove white/gray pixels of background (a wall) image foreground (a hand in case) should left. i tried manipulating canvas pixels foreground extraction not nice because of shadow or other inconsistencies in background. tried green colored background doesn't enhance performance. for (i = 0; < imgdata.width * imgdata.height * 4; += 4) { var r = imgdatanormal.data[i + 0]; var g = imgdatanormal.data[i + 1]; var b = imgdatanormal.data[i + 2]; var = imgdatanormal.data[i + 3]; // compare rgb levels green , set alphachannel 0; selectedr = *a value 0 - 255* selectedg = *a value 0 - 255* selectedb = *a value 0 - 255* if (r <= selectedr || g >= selectedg || b <= selectedb) { = 0; } } is there sophisticated method or library make background of image transparent? there few mistakes in code : the last line a = 0 nothing changing local variable. have modify directly in array after that, see result...

python - concatenating scipy matrices -

i want concatenate 2 csr_matrix, each shape=(1,n) . i know should use scipy.sparse.vstack : from scipy.sparse import csr_matrix,vstack c1 = csr_matrix([[1, 2]]) c2 = csr_matrix([[3, 4]]) print c1.shape,c2.shape print vstack([c1, c2], format='csr') #prints: (1, 2) (1, 2) (0, 0) 1 (0, 1) 2 (1, 0) 3 (1, 1) 4 however, code fails: from scipy.sparse import csr_matrix,vstack import numpy np y_train = np.array([1, 0, 1, 0, 1, 0]) x_train = csr_matrix([[1, 1], [-1, 1], [1, 0], [-1, 0], [1, -1], [-1, -1]]) c0 = x_train[y_train == 0].mean(axis=0) c1 = x_train[y_train == 1].mean(axis=0) print c0.shape, c1.shape #prints (1l, 2l) (1l, 2l) print c0,c1 #prints [[-1. 0.]] [[ 1. 0.]] print vstack([c0,c1], format='csr') the last line raises exception - file "c:\anaconda\lib\site-packages\scipy\sparse\construct.py", line 484, in vstack return bmat([[b] b in blocks], format=format, dtype=dtype) file "c:\anaconda\li...

python 2.7 - When I am creating a dictionary for German Language , I am facing some problems in making tokens -

i using sublime text editor coding. code: # coding: utf-8 import nltk line = "frau präsidentin, zu recht befaĂŸt sich das parlament regelmĂ¤ĂŸig mit der verkehrssicherheit." print nltk.word_tokenize(line.decode('utf8')) result: [u'frau', u'pr', u'\xe4', u'sidentin', u',', u'zu', u'recht', u'befa', u'\xdf', u't', u'sich', u'das', u'parlament', u'regelm', u'\xe4', u'\xdf', u'ig', u'mit', u'der', u'verkehrssicherheit', u'.'] [finished in 0.4s] still tokens not correct. because breaking präsidentin sub token dont want. according docs : this particular tokenizer requires punkt sentence tokenization models installed. i'm guessing need these, include german model. instructions installing these can found @ http://www.nltk.org/data.html , or models can directly downloaded here ...

javascript - Table in smartphone layout -

i have table images, , it's showed pretty on pc, if view website smartphone table large , ruin mobile layout, there's way fix it? this link can see problem: http://www.animeshare.it/lista-anime/ . i'd fit number of columns based on screen width. that's hard table layout. i'm not sure if required use table, suggest using css3 flex-box model instead better mobile compatibility. in example below, contents of #grid div wrap depending on size of #grid div. html <div id="container"> <div id="grid"> <div class="animecell"><img src="" /><br />label 1</div> <div class="animecell"><img src="" /><br />label 2</div> <div class="animecell"><img src="" /><br />label 3</div> <div class="animecell"><img src="" /><br />label...

performance - Extremely slow object instantiation in Python 2.7 -

i had complete assignment used lot of coordinate operations. thinking save time , simplify code, defined class encapsulate behaviour of coordinate pair. class looked this: class vector (tuple) : def __init__ (self, value) : tuple.__init__ (self, value) def __add__ (self, other) : return vector ((self [0] + other [0], self [1] + other [1])) this allowed me write code (for example): def translate (pointlist, displacement) : return [point + displacement point in pointlist] but application terribly slow. slower other assignments. couldn't locate inefficiency in implementation of algorithm, did simple test see overhead of vector class. expected somewhere between 5% , 15%. my test of vector class looked this: v = vector ((0, 0)) d = vector ((1, -1)) loopidx = 3000000 while loopidx > 0 : v = v + d loopidx -= 1 print (v) this runs (typically) in kind of time: real 0m8.440s user 0m8.367s sys 0m0.016s for compariso...

finance - MACD java Double array -

i little stuck on how implement importing of closing price of ford. currently, using scanner while there next line should continue loop down. after importing line need converted double. question how can import entire file string array , convert double , use loop cycle through double array compute macd given equations. import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; public class importcsv { public static void main(string[] args) { //to import .csv file string filename = "ford.csv"; file file = new file(filename); try { scanner inputstream = new scanner(file); //ignore first line inputstream.next(); while (inputstream.hasnext()) { //get whole line string data = inputstream.next(); //split string array of strings string [] values = data.split(","); //convert double double closingprice = double.parsedouble(values[4]); // system.out.p...

How to use NSPredicate to find an NSString begins with numbers or special characters in ios? -

could please help, how use nspredicate find nsstring beginswith numbers or other special characters (but not begin alphabets)? want sort array name contains numbers , special characters. advance help. you should able use matches keyword: [nspredicate predicatewithstring:@"self matches [^a-za-z]+.*"] you can find more docu here: https://developer.apple.com/library/mac/documentation/cocoa/conceptual/predicates/articles/psyntax.html#//apple_ref/doc/uid/tp40001795-215868 and definition of how define regex here: http://userguide.icu-project.org/strings/regexp