Posts

Showing posts from April, 2012

python - Printing Simplified Corpus to Json File -

i'm trying print out brown corpus simplified tagset file. code i'm using, , ending blank file. import json import nltk nltk.corpus import brown brown_sents = nltk.corpus.brown.tagged_sents(tagset="universal") sent in brown_sents: open('brown_corpus.txt', 'a') outfile: json.dumps(sent, outfile) json.dumps() meant returning str , not writing open file. use json.dump(sent, outfile) instead, , should fine.

java - Creating threads vs process for better maintainence - Design approach -

i have scenario , want query employee information of organization , using third party rest apis. done different organizations, given list of employees, expecting around 500 50k users per organization. i in poc stage, want decide best approach handle this. 1 option create 1 single java process, , generate single thread per user. create single process per user , write shell script provide details of each employee. my question better solution , form maintenance point of view. might happen , users might have issues, due depending on 3rd party apis. might better approach support point , debugging point. might open question . know , if had encountered scenario before , , approach. if have number of tasks needs run concurrently want use thread pools . thread pool owns number of threads , handed units of work need done. pool passes each unit of work first idle thread, managing actual executions you. exactly how many threads pool should contain depends on exact requirement...

entity framework - cannot find default auto generated connection String in web config file in ASP.Net MVC 5 -

here web config file after extending dbcontext class in schoolcontext class, <?xml version="1.0" encoding="utf-8"?> <!-- more information on how configure asp.net application, please visit http://go.microsoft.com/fwlink/?linkid=301880 --> <configuration> <configsections> <!-- more information on entity framework configuration, visit http://go.microsoft.com/fwlink/?linkid=237468 --> <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </configsections> <appsettings> <add key="webpages:version" value="3.0.0.0" /> <add key="webpages:enabled" value="false" /> <add key="clientvalidatio...

how to write a loop of the number of for loops in R? -

this simple one, somehow got stuck... i need many loops result of every sample in support usual stacked loops: for (a in 1:n1){ (b in 1:n2){ (c in 1:n3){ ... } } } but number of loops needed in messy system depends on random variable, let's say, for(f in 1:n.for) so how can write loop deal this? or there more elegant ways this? note difference nested loops above (the variables a,b,c,...) matter in calculations, variable f of loop controls number of loops needed not go of calculations real purpose - count/ensure number of loops needed correct. did make clear? so trying generate possible combinations of number of peoples preferences towards others. let's have 6 people (the simplest case purpose): abi, bob, cath, dan, eva, fay. abi , bob have preference lists of c d e f ( 4!=24 possible permutations each of them); cath , dan have preference lists of b , e f, respectively (2! * 2! = 4 possible permutations each of them); eva , fay have pre...

xml - Changing the ActionBar title color of an Android app -

i have been reading asked questions still can't make color of text in actionbar change. code pretty copy/pasted instructions on following link: https://developer.android.com/training/basics/actionbar/styling.html#customtext <!--theme applied application or activity--> <style name="myactionbartheme" parent="android:theme.holo"> <item name="android:actionbarstyle">@style/myactionbar</item> <item name="android:actionbartabtextstyle">@style/myactionbartabtext</item> <item name="android:actionmenutextcolor">@color/lightblue</item> </style> <!-- actionbar styles --> <style name="myactionbar" parent="android:widget.holo.actionbar"> <item name="android:titletextstyle">@style/myactionbartitletext</item> </style> <!-- actionbar title text --> <style name="myactionbartitletext" parent=...

C++ When restarting my hangman game my score gets deleted along with player info which I dont want -

i'm making hangman program , works fine except when game ends restarts , makes user input user again , score gets restart. how fix need help.i want when restart game name , score previous game same. cant figure out algorithm so. know messed in main function used copy constructor can't figure way restart words. can me! in player.h file have: #ifndef player_h_ #define player_h_ #include <iostream> #include <string> #include <vector> #include <algorithm> #include <ctime> #include <cctype> using namespace std; class player { public: player(); void makeguess(char &guess); void win(); void lose(); char agree(); private: string name; int score; string mystring; char answer; }; #endif in hangman .h file have #ifndef hangman_h_ #define hangman_h_ #include <iostream> #include <string> #include <vector> #include <algorithm> #include <ctime> #include <cctype> #in...

javascript - How to call ajax by clicking d3.js graph -

i want call ajax function send data graph (d3.js forced layout graph) controller action in rails. my graph created json (from classic miserables example). want allow user click on node , trigger ajax 'get' call action in rails. the controller called users , action show want send name of node show action so far have: var node = svg.selectall(".node") .data(graph.nodes) .enter().append("circle") .attr("class", "node") .attr("r", function(d) { return d.group * 3; }) .style("fill", function(d) { return color(d.group); }) .call(force.drag) .on("click", getprofile(d.name));}) .on('dblclick', connectednodes); function getprofile(){ $.ajax({ type: "get", url: "/users/show" , }) }; obviously doesn't work. i'm not sure how pass name of node ajax. i don't have access variables, ran stripped down version , ...

reshape - Reshaping data in R using melt -

i have tried apply people have suggested reshape data, somehow failing data reshaped want it. appreciate if can help: my data looks this: ab lp pd1 pd2 py1 py2 py3 py4 py5 t 1 -50.000 -50.000 -50.000 -50.000 -50.000 -50.000 -50.000 -50.000 -50.000 1 2 -50.153 -53.316 -50.416 -50.416 -53.455 -53.467 -53.700 -53.403 -53.218 2 3 -50.288 -54.399 -50.726 -50.726 -53.603 -53.644 -54.457 -53.664 -53.776 3 4 -50.410 -53.630 -50.956 -50.956 -52.385 -52.649 -53.642 -52.575 -52.740 4 5 -50.519 -53.075 -51.127 -51.127 -52.072 -52.174 -53.132 -51.715 -52.563 5 6 -50.617 -52.616 -51.255 -51.255 -52.023 -51.947 -52.602 -51.857 -52.643 6 > and want change can plot ggplot need this: ab -50.000 1 ab -50.153 2 ab -50.288 3 etc, third columns last column original data, time (column t) if use v=melt(values) this: variable value 1 ab -50.000 2 ab -50.153 3 ab -50.288 4 ab -50.410 5 ab -50.519 6 ab -50.617 ...

jasper reports - Take sensitive frame with height of detail row -

Image
i try border bands in way : but have text field of row detail property isstretchwithoverflow="true" in way when try print report, on rows overflowed text field, i've discontinue on border (white space instead draw line of frame). very simple. i've added property stretchtype="relativetotallestobject" on frame object. so line has not discontinuity.

ios - xcode navigationbar is not more visible after popover with button -

Image
i have created popover in iphone view button inside segue viewcontroller. viewcontroller after popover have navigationbar not anymore. my project structure: navigationcontroller -> viewcontroller1 -> viewcontroller2(popover) ->viewcontroller3 all connections are: "show",except viewcontroller1 viewcontroller2: "present popover" if connect(show) directly viewcontroller1->viewcontroller3, fine... where can problem? i used tutorial: http://richardallen.me/2014/11/28/popovers.html viewcontroller1: func adaptivepresentationstyleforpresentationcontroller(controller: uipresentationcontroller) -> uimodalpresentationstyle { return uimodalpresentationstyle.none } override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "popoveridentifier" { let popoverviewcontroller = segue.destinationviewcontroller as! popoverviewcontroller.modalpresentationst...

python - using Kivy Garden Graph in KV language -

how use kivy module garden.graph inside kv file? found documentation explained how use in main python script. i imported kivy.garden.graph in python file, , can add graph inside kv file, didn't find documentation how set size, plots etc. graph: id: graph_test plot: meshlineplot this gives error since meshlineplot not defined , though imported on python side. any highly appreciated, maybe add info graph's github readme well. had same problem. here's solution: generally, according kivy documentation, in kv file: #:import name x.y.z is equivalent to: from x.y import z name so should use following: #:import meshlineplot kivy.garden.graph.meshlineplot worked in case graph class but, honest, didn't managed add plot graph yet.

java - Any issues with replacing new Socket() with SocketChannel.open().socket()? -

what can go wrong if replace socket = new socket() with socket = socketchannel.open().socket()? background: have legacy code using new socket() , , wanted able interrupt socket.connect() call. don't want rewrite code use nio. learned thread.interrupt() not interrupt socket.connect() , socket.close() on thread supposed interrupt connection. oddly, worked java 7 not java 6. i somehow got head using socket = socketchannel().open().socket() magically allow me use thread.interrupt() interrupt socket.connect() . doesn't, oddly, make socket.close() interrupt socket.connect() in java 6 too! note i'm not directly using attached socketchannel in way---it appears when create socket , never again. what can go wrong this? there several. a socket acquired via socketchannel doesn't appear support read timeouts. the inputstream , outputstream of socket aren't independent: have mutual lock in common. why want interrupt connect() call? s...

javascript - Animate Div If Visible jQuery -

i have no clue relating jquery. new this. trying make divs class of #animated slide in bottom when page scrolled , div comes view. copied code $(document).ready(function() { (function($) { /** * copyright 2012, digital fusion * licensed under mit license. * http://teamdf.com/jquery-plugins/license/ * * @author sam sehnert * @desc small plugin checks whether elements within * user visible viewport of web browser. * accounts vertical position, not horizontal. */ $.fn.visible = function(partial) { var $t = $(this), $w = $(window), viewtop = $w.scrolltop(), viewbottom = viewtop + $w.height(), _top = $t.offset().top, _bottom = _top + $t.height(), comparetop = partial === true ? _bottom : _top, comparebottom = partial === true ? _top : _bottom; return ((comparebottom <= viewbottom) && (comparetop >= viewtop)...

Unity3D 2D game. Fit camera horizontally -

i'm working on unity3d 2d mobile game , i've got problem connected aspect ratio. when changing aspect ratio camera fits vertically. landscape mode games practice. portrait mode games better fit camera horizontally. game needs fit camera horizontally. please me it. let's aspect ratio 4:3 if want make camera fit landscape mode of 16 units wide, make camera size of 16 / 4 * 4 if want make camera fit portrait mode of 16 units tall, make camera size of 16 / 3 * 4

Converting a table of html inputs to PHP array -

i trying information html table php array. easy following method: function getdata($table) { $dom = new domdocument; $dom->loadhtml($table); $items = $dom->getelementsbytagname('tr'); function tdrows($elements) { $str = ""; foreach ($elements $element) { $str .= $element->nodevalue . ", "; } return $str; } foreach ($items $node) { echo tdrows($node->childnodes) . "<br />"; } } the problem facing content of table has html inputs , want value of inputs. table of form: <table> <tr><td><input type="text" /></td><td><input type="text" /></td><td><div class="add">add</div></td></tr> </table> will able modify current function accomplish or should try approach as php server-side, not able value of input unless...

java - functioning of (== ) in terms of hashCode -

string s1="abc"; string s2=new string("abc"); when compare both s1==s2; return false and when compare s1.hashcode()==s2.hashcode return true i know (==) checks reference id's .does returning true in above comparison because above hashcode saved same bucket??please give me explanation don't forget hash codes primitive integers, , comparing primitives using == compare values , not references (since primitives don't have references) hence 2 strings having same contents yield same hash code, , comparison via == valid. the concept of bucket valid when put object hashed collection (e.g. hashset ). value of hash code dictates bucket object goes into. hash codes aren't stored.

java - Best / simplest way to transfer data from one Oracle database to another -

i need develop app pull data oracle database (via view sitting on a) , put data database b. app expose data in database b via rest api. far technical restrictions app has run in jboss 5 app server. i'm wondering cleanest implementation should be. should transfer between dbs occur @ db rather app level? advice appreciated. data size minimal... 9-10 columns , 1800 rows. there bellow ways this. import export if can manage call import export api program. you can use materialized view setting db link. you can use third party tool informatica.

in C#, changing background image of a button after click -

this code not report error , should have work.the button background image not change. idea of wrong? void myhandler(object sender, eventargs e, string val) { //process process.start(@val); //change button bkground image var button = (button)sender; button.backgroundimage = global::test.properties.resources.impok; } edit event myhandler being called buttons created event handler. private async void button3_click(object sender, eventargs e) { ... foreach (keyvaluepair<string, string> pair in printerdic) { //init string val = pair.value; string ky = pair.key; //button button bt_imp = new button(); if (list_localservprnlink.contains(val)) { bt_imp.backgroundimage = global::test.properties.resources.impok; } else ...

javascript - Failed to execute 'scroll' on 'Window': 2 arguments required, but only 1 present -

i have code here , gives me error. uncaught typeerror: failed execute 'scroll' on 'window': 2 arguments required, 1 present. i have jquery 1.8.3 installed, , script on bottom of page. code: <script type='text/javascript'> $(window).scroll(function() { var scroll = $(window).scrolltop(); if (scroll >= 150) { $(".navigation").addclass("darkheader"); } else { $(".navigation").removeclass("darkheader"); } }); </script> any help? on jsfiddle working. code on ipboard 3.4.8. use $(document).ready(function(){ } to element after document ready here demo click here ! update demo notice change of scroll click here !

Python: How to append to existing key of a dictionary? -

i have dictionary multidimensional lists, so: mydict = {'games':[ ['post 1', 'post 1 description'], ['post2, 'desc2'] ], 'fiction':[ ['fic post1', 'p 1 fiction desc'], ['fic post2, 'p 2 fiction desc'] ]} how add new list ['post 3', 'post 3 description'] games key list? you're appending value (which list in case), not key. mydict['games'].append(...)

How can you make an array of segues in swift? -

this question exact duplicate of: how segue randomly viewcontrollers in swift? [closed] 1 answer i'm trying make array in swift of segues can switch random view controller via pressing button. you can more reasonably maintain array of strings represent segue.identifier .

Dump a Python dictionary with array value inside to CSV -

i got this: dict = {} dict["p1"] = [.1,.2,.3,.4] dict["p2"] = [.4,.3,.2,.1] dict["p3"] = [.5,.6,.7,.8] how can dump dictionary csv structure? : .1 .4 .5 .2 .3 .6 .3 .2 .7 .4 .1 .8 really appreciated ! dict s have no order need ordereddict , transpose values: import csv collections import ordereddict d = ordereddict() d["p1"] = [.1,.2,.3,.4] d["p2"] = [.4,.3,.2,.1] d["p3"] = [.5,.6,.7,.8] open("out.csv","w") f: wr = csv.writer(f) wr.writerow(list(d)) wr.writerows(zip(*d.values())) output: p1,p2,p3 0.1,0.4,0.5 0.2,0.3,0.6 0.3,0.2,0.7 0.4,0.1,0.8 also best avoid shadowing builtin functions names dict .

navigation - How to get the page that the user redirected from -

i develop app windows store , have navigation code this: frame.navigate(typeof(hubpage), datatopass); now, want able page name user redirected from. for example have code above in more 1 page , want able in hubpage write code give me indication page user redurected. i know can add page name in 'datatopass' var avoid this. my question how can previuos page name? in wp8.1 (windows store apps) can know previous page , whole stack of redirected pages below code. var lastpage = frame.backstack.last().sourcepagetype backstack property more in context.

python Flask-oauth with facebook is throwing a webpage not found error -

i trying authenticate user using facebook oauth throwing webpage not found error after user allows app in facebook. here's code: from flask import redirect, flask, url_for, request app = flask(__name__) app.secret_key = 'asd' oauth = oauth() facebook = oauth.remote_app('facebook', base_url='https://graph.facebook.com/', request_token_url=none, access_token_url='/oauth/access_token', authorize_url='https://www.facebook.com/dialog/oauth', consumer_key='xxx', consumer_secret='yyy', request_token_params={'scope': 'email'} ) @app.route('/login') def login(): print(url_for('oauth_authorized')) return facebook.authorize(callback='www.resoorce.com' + url_for('oauth_authorized')) @app.route('/oauth_authorized') @facebook.authorized_handler def oauth_authorized(resp): print("asd") if resp none: print(u'yo...

android - how do I add individual strings to a row in CSV file? -

i need csv, started learning how use yesterday, , can't find solution problem. have csv file array: "name, address, id", using opencsv. want able add corresponded strings in row below it. example, if user press button, name "david" added the csv file, , like: "name,address,id" "david" and when user press other button, adress "3 street" added, like: "name,address,id" "david, 3 street" and on, in end there list of names , address , id. can't figured out how , cant similar. maybe there way it? let me try understand mean, in scenario 1, should have name added, in scenario 2, should have name,address added,if understand? this simple , quite achievable. firstly assuming have created row part in csv , saved sd-card in next part should using arraylist write csv, check out code below string csv = "c:\\work\\output.csv"; csvwriter writer = new csvwriter(new filewriter(csv)); ...

php - database restore for integration tests with phpunit -

i'm using phpunit , i'd know if there correct form restoring database before running integration tests. @ moment i'm calling sql server script php exec() on testcase setup method, don't know if best choice class testcase extends phpunit_framework_testcase { protected function setup() { exec("the restore command line"); } } is there more correct form that? thank you this dbunit about. have looked @ it?

r - Plot monthly and annual mean on a single plot -

Image
i want plot monthly , annual temperature. based on examples on forum have assembled monthly annual data. however, aggregation created data sorted month , year. how plot data beginning january 1995 in r base plot or ggplot? tt<- rnorm(4018, 5, 8) date<-seq(as.date('1995-01-01'),as.date('2005-12-31'),by = 1) df<-data.frame(date,tt) df$month <- months(df$date) df$year <- format(df$date,format="%y") df1<-aggregate(tt ~ month + year , df , mean) in base r can following: tt<- rnorm(4018, 5, 8) date<-seq(as.date('1995-01-01'),as.date('2005-12-31'),by = 1) df<-data.frame(date,tt) df$month <- months(df$date) df$year <- format(df$date,format="%y") df1<-aggregate(tt ~ month + year , df , mean) #make date column df1$date <- as.date(paste('01', df1$month, df1$year), format='%d %b %y') #plot tt on dates made above plot(df1$date, df1$tt)

node.js - node request pipe hanging after a few hours -

i have endpoint in node app used download images var images = { 'car': 'http://someurltoimage.jpg', 'boat': 'http://someurltoimage.jpg', 'train': 'http://someurltoimage.jpg' } app.get('/api/download/:id', function(req, res){ var id = req.params.id; res.setheader("content-disposition", "attachment; filename=image.jpg"); request.get(images[id]).pipe(res); }); now code works fine, after few hours of app running, endpoint hangs. i monitoring memory usage of app, remains consistent, , other endpoints return json respond normal not if event loop somehow being blocked. there gotcha of kind missing when using request module pipe response? or there better solution achieve this? i using express module. you should add error listener on request because errors not passed in pipes. way, if request has error, close connection , you'll reason. request ...

javascript - Google Maps map can be loaded only once -

i have page full of map triggers, when user clicks on these links, want create map javascript. works first time around, when close map , reopen it, content blank (except zoom, google logo, road/terrain dropdown). seems it's 'almost' working. doing wrong? tried empty content of map-canvas when hide map, issue persists. thanks here html <a href="#" class="btn cta map-trigger" data-lat="41.8911684" data-lng="12.507724100000019"> show map </a> and here javascript var render_map = function( lat, lng, title ) { var mapcanvas = document.getelementbyid('map-canvas'); // options var args = { zoom : 16, center : new google.maps.latlng(lat, lng), maptypeid : google.maps.maptypeid.roadmap }; // create map var map = new google.maps.map( mapcanvas, args); // create marker var marker = new google.maps.marker({ position: args...

java - BufferReader.readline() block PrinterWriter.println() -

after creating socket connection in android app, can't write in buffer after reading. this example establishing connection server: //... try{ socket = new socket(ip, port); out = new printwriter(new bufferedwriter( new outputstreamwriter(socket.getoutputstream())), true); in =new bufferedreader(new inputstreamreader(socket.getinputstream())); //ask connection out.println(req1); //server send me nonce result=in.readline().tostring(); //encrypting nonce specific alghorithm passwd=password.get_passwd(result); //sending password out.println(passwd); //here out.println doesn't write //... } catch (ioexception e){ e.printstacktrace(); } { try { socket.close(); out.close(); in.close(); } catch (ioexception e) { e.printstacktrace(); } } //... so can 1 me solving problem. thanks.

javascript - JsTree design is not proper display -

Image
run time, try add child under parent node. when click on tree branch. call ajax file has return list structure of child , set under parent node designing not proper. find tree structure image below $(document).on('click', '.jstree-ocl', function() { var contactid = $(this).closest('.clstwolevel').attr('id'); var groupid = $('#cbogroupname').val(); if (contactid != undefined) { $.ajax({ url: 'contact-group-treeview.php', data: 'contactid=' + contactid + '&groupid=' + groupid, type: 'post', success: function(response) { $("#morethantwolevel_"+contactid).html(response); } }); } }); <div id="jstree"> <?php while ($row = sqlsrv_fetch_array($getlevelonetwo, sqlsrv_fetch_assoc)) { ?> <ul> <li> <?php echo $row['name'] . ' (' . $row['totalcount'] . ')'; ?> ...

How do you make sure email you send programmatically is not automatically marked as spam? -

this tricky 1 , i've relied on techniques, such permission-based emails (i.e. sending people have permission send to) , not using blatantly spamish terminology. of late, of emails send out programmatically have started being shuffled people's spam folder automatically , i'm wondering can it. this despite fact these particular emails not ones humans mark spam, specifically, emails contain license keys people have paid money for, don't think they're going consider them spam i figure big topic in ignorant simpleton. use email authentication methods, such spf , , dkim prove emails , domain name belong together, , prevent spoofing of domain name. spf website includes wizard generate dns information site. check reverse dns make sure ip address of mail server points domain name use sending mail. make sure ip-address you're using not on blacklist make sure reply-to address valid, existing address. use full, real name of addressee in field,...

Host android application to initiate communicate with tizen application(Android to tizen) -

i have android application needs make connection when need gear 2 device. need ask question(yes or no) on tizen , response how do ?? there many tutorials (helloaccessoryprotocol app) initiates connection tizen need other way round findpeeragents() call gives below log onfindpeeragentresponse arg0 =sapimageswitcher arg1 =0 in try block of find peer agent response sap connection constructor onserviceconnectionresponse result error =1030 the error code here means connection_failure_peeragent_no_response on tizen side agentcallback included onrequest function below var agentcallback = { onrequest : function(peeragent) { console.log(" onrequest " + peeragent); saagent.acceptserviceconnectionrequest(peeragent); }, onconnect : function(socket) { console.log( "agentcallback onconnect" + socket); sasocket = socket; alert("sap connection established remotepeer"); createhtml("startconnection"); sasocket.setsocketsta...

javascript - google maps click event not working completely correct -

i use following script generate page function initialize() { var mapcanvas = document.getelementbyid('map'); var mapoptions = {center:new google.maps.latlng(latitudemid,longitudemid),zoom:15,maptypeid:google.maps.maptypeid.roadmap,streetviewcontrol:false,maptypecontrol:true,scalecontrol:true,scalecontroloptions:{position:google.maps.controlposition.top_right}}; var map = new google.maps.map(mapcanvas, mapoptions); var i; var insertion; var previousmarker; // ------------------------------- //show locations on map // ------------------------------- (i = 0; < fotocount; i++) { var mylatlng=new google.maps.latlng(latituden[i], longituden[i]); var marker = new styledmarker({styleicon:new styledicon(styledicontypes.marker,{color:'00ff00',text:letters[i]}),position:mylatlng,map:map}); marker.set('zindex', -i); insertion='<img src=\"http://www.pdavis.nl/ams/'.concat(bestanden[i],'.jpg\"></i...

Wordpress -- add description below to featured image -

i add annotation below featured image box in post page ,saying 'recommended image size: 1300px (width) x 340px (height) is possible in wordpress 4.2.2. the text admin user better guidance. any highly appreciated. in advance. you should go wp-admin->includes->post.php , around line 1295 (depending on version) find: if ( !empty( $thumbnail_html ) ) { $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->id ); $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html ); $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="wpremovethumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'remove featured image' ) . '</a></p>'; } change to: if ( !empty( $thumbnail_html ) ) { $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->id ...

linux - MySQL/MariaDB - Reset password without DB restart -

unfortunately forgot note down new password last recovery. means can't login root , init script can't restart due not having been updated (sys_maint). is there way me fix this, of guides found require restart mysql server, well, doesn't work in case. i kill process able start again afterwards? if use way, if works mariadb: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix after spending few more hours issue tried 1 way , worked, though didn't have access database. in terms of security concerns, official..: b.5.4.1.2 https://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

sass - SCSS, Compass and GULP: How to minify without breaking CSS? -

i using gulp-compass , want minify css. when this, following code .tags-bar .sub-bullet:nth-last-of-type { display:none; } .ux-panel-hidden{ display:none; } becomes minified to: .tags-bar .sub-bullet:nth-last-of-type,.ux-panel-hidden{display:none} the :nth-type part confuses browser, ux-panel-hidden doesn't read. jsfiddle minified code jsfildde non-minified code tags-bar , ux-panel in separate _scss files, not sure why minfication brings them together. how can fix it? here gulp code: gulp.task('compass', function() { return gulp.src('frontend/build/css/*.scss') .pipe(compass({ css: 'frontend/dist/css', sass: 'frontend/build/css', image: 'frontend/images/', font: 'stylesheets/fonts', require: ['susy', 'breakpoint'], bundle_exec: true })) .pipe(plumber({ errorhandler: onerror ...

sql - psql max group by just for some columns -

i have problem in psql query. don't know how select maximum value subset of 2 columns. it's hard explain problem without example, write one: i have table that: athlete | category | points at1 | cat1 | 100 at1 | cat1 | 90 at1 | cat1 | 80 at1 | cat2 | 95 at2 | cat1 | 97 at2 | cat2 | 60 at2 | cat2 | 71 i keep every athlete maximum points in every category. final table should that: athlete | category | points at1 | cat1 | 100 at1 | cat2 | 95 at2 | cat1 | 97 at2 | cat2 | 71 this classic usecase group by clause return distinct combinations of athlete , category . then, max(points) applied each combination: select athlete, category, max(points) mytable group athlete, category

mysql - How to order by an aggregate function in sequelize -

i feel if i've hit brick wall while converting old php app functionality on node , sequelize. maybe i'm approaching limits of orm can do, want ask before give up. let's imagine 3 tables: video , task , publishdate . the application requires video may have multiple publishdate s , multiple task s. task s have due dates calculated looking @ minimum of video 's publishdate s. so if video has 2 publishdate s of 2015-12-01 , 2015-08-15 , we'd use 2015-08-15 , perform additional calculations on task due date. the problem occurs when i'm trying list of task s ordered calculated due dates. i've attempted many different approaches. latest try attempts use sequelize.fn function models.task.findall({ where: {isactive: false, iscompleted: false}, include: [ { model: models.video, attributes: [[sequelize.fn('min', 'video.publishdates.date'), 'duedate']], include: [models.publishdate] ...

java - wsimport : Service Interface with bean as method parameter -

wsimport( http://www.webservicex.com/globalweather.asmx?wsdl ) creating source files. service interface(globalweathersoap) doesn't have methods accept bean arguments. /** * major cities country name(full / part). * * @param countryname * @return * returns java.lang.string */ @webmethod(operationname = "getcitiesbycountry", action = "http://www.webservicex.net/getcitiesbycountry") @webresult(name = "getcitiesbycountryresult", targetnamespace = "http://www.webservicex.net") @requestwrapper(localname = "getcitiesbycountry", targetnamespace = "http://www.webservicex.net", classname = "com.x.test.getcitiesbycountry") @responsewrapper(localname = "getcitiesbycountryresponse", targetnamespace = "http://www.webservicex.net", classname = "com.x.test.getcitiesbycountryresponse") public string getcitiesbycountry(@webparam(name = "countryname", targetnamespace = ...

java - How to extract derivation rules from a bracketed parse tree? -

i have lot of parse trees this: ( s ( np-sbj ( prp ) ) ( inode@s ( vp ( vbp have ) ( np ( dt ) ( inode@np ( nn savings ) ( nn account ) ) ) ) ( . . ) ) ) for sentence this: "i have savings account ." i need extract derivation rules these trees. derivation rules like: s -> np-sbj inode@s np-sbj -> prp prp -> inode@s -> vp np , on. is there prepared code (preferably in java) or pseudo code purpose? edit: i think problem general , common in many areas. simplified problem find each parent , it's children parenthesis tree. i wrote python. believe can read pseudocode. i edit post java later . added java implementation later. import re # grammar repository grammar_repo = [] s = "( s ( np-sbj ( prp ) ) ( inode@s ( vp ( vbp have ) ( np ( dt ) ( inode@np ( nn savings ) ( nn account ) ) ) ) ( . . ) ) )" # clean string (make sure there no double space in it) s = s.replace(" ", " ...

c++ - Multithread performance drops down after a few operations -

i encountered weird bug in c++ multithread program on linux. multithreaded part executes loop. 1 single iteration first loads sift file containing features. , queries these features against tree. since have lot of images, used multiple threads querying. here code snippets. struct multimatchparam { int thread_id; float *scores; double *scores_d; int *perm; size_t db_image_num; std::vector<std::string> *query_filenames; int start_id; int num_query; int dim; vocabtree *tree; file *file; }; // multi-thread normalization anyway void multimatch(multimatchparam &param) { // clear scores for(size_t t = param.start_id; t < param.start_id + param.num_query; t++) { (size_t = 0; < param.db_image_num; i++) param.scores[i] = 0.0; dtype *keys; int num_keys; keys = readkeys_sfm((*param.query_filenames)[t].c_str(), param.dim, num_keys); int normalize = true; doub...

i am looking to apply media queries through javascript -

i want slide divs of menu left right,i have done using javascript <div id="script" style="height: 250px;"> <div class="slide"> <div id="div1" class="slide-item"> <p>home</p> </div> </div> <div class="slide"> <div id="div2" class="slide-item"> <p>about us</p> </div> </div> <div class="slide"> <div id="div3" class="slide-item"> <p>events</p> </div> </div> <div class="slide"> <div id="div4" class="slide-ite...

php - Dropzone js - Drag n Drop file from same page -

i using dropzone plugin multiple files drag n drop functionality. drag n drop works fine when uploading pictures laptop / desktop. my question - how can drag n drop images dropzone same page. lets have dropzone div , having div having multiple images. want drag n drop images dropzone. this.on("drop", function(event) { var imageurl = event.datatransfer.getdata('url'); var filename = imageurl.split('/').pop(); // set effectallowed drag item event.datatransfer.effectallowed = 'copy'; function getdatauri(url, callback) { var image = new image(); image.onload = function() { var canvas = document.createelement('canvas'); canvas.width = this.naturalwidth; // or 'width' if want special/scaled size canvas.height = this.naturalheight; // or 'height' if want special/scaled size canvas.getcontext('2d').drawimage(this, 0, 0); // raw image data // callback(canv...

android - Find if a ListView is scrolled "fully" to the bottom? -

what want i want detect if listview have been scrolled "fully" bottom. word "fully", mean last element of list should visible. what did this did. list.setonscrolllistener(new abslistview.onscrolllistener() { @override public void onscrollstatechanged(abslistview view, int scrollstate) { } @override public void onscroll(abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount) { switch (view.getid()) { case r.id.enclist: final int lastitem = firstvisibleitem + visibleitemcount; if (lastitem == totalitemcount) { if (prelast != lastitem) { //to avoid multiple calls last item log.d("log", "last reached"); ...

php - How to get/set Header in Rest Server API? -

i have chriskacerguis rest server ,that listen client request api server do. base on client request want send/response data client in header only. my questions are: how access client header first? then how set header in rest server? this how send request rest server: function request_curl($url = null) { $utc = time(); $post = "id=1&customerid=1&amount=2450&operatorname=jondoe&operator=12"; $header_data = array( "content-type: application/json", "accept: application/json", "x-api-key:3ecbcb4e62a00d2bc58080218a4376f24a8079e1", "x-utc:" . $utc, ); $ch = curl_init(); $curlopts = array( curlopt_url => 'http://domain.com/customapi/api/clientrequest', curlopt_returntransfer => true, curlopt_httpheader => $header_data, curlopt_followlocation => tr...