Posts

Showing posts from September, 2010

android - Where to place SlidingTabLayout.java and SlidingTabStrip.java files in project? -

i'm new android studio , i'm following tutorial implements sliding tab layout application. tutorial says put slidingtablayout.java , slidingtabstrip.java in our project, doesn't where. now, put declared them 2 classes , put them under java folder. (...app\src\androidtest\java). however, when try include slidingtablayout object in xml file, says "the following classes not be: found:com.android4devs.slidingtab.slidingtablayout", means must have put 2 files in wrong place. used these files before , know put them? thank you the error says could not found slidingtablayout class. means have tell correctly slidingtablayout file placed. in xml change com.android4devs.slidingtab package name. can find package name in slidingtablayout.java or in manifest file.

mocking - Mock method reported as called 0 times when it seems it MUST be being called at least once -

i have method i'm mocking reported being called 0 times, though seems should being called 1 times. here's test class method (simplified): function testfailedpasswordlogin() { $badpassword = 'not'.$this->testpassword; // setup fake user repo returns our test user (since we're passing valid username, incorrect password) $this->users = $this->getmock('users', array('getbyusername')); $this->users->method('getbyusername')->with($this->testuser->username)->willreturn(null); $this->auth = new auth($this->users); $this->assertfalse($this->auth->login($this->testuser->username,$badpassword)); $loggedinuser = $this->auth->user(); $this->assertequals(null, $loggedinuser); } update: decided try using mock framework (prophecy): $this->users = $this->prophesize('users'); $this->users->getbyusername($this->testuser->username)->s

mysql - FInd the names of customers are interested in every artist -

i looking customer names of customers have interest in artists. i understand in relational algebra, can use division operator, not understand sql format in doing so. i have these tables columns: customer (customerid, firstname, lastname) artist (artistid) customer_interest_in_artists (artistid, customerid) how go doing this? you using simple min() construct: select c.firstname, c.lastname, min(ci.customerid not null) interest_all artist left join customer_interest_in_artists ci using (artistid) left join customer c using (customerid) group c.customerid having interest_all = 1

Improving pure HTML+CSS iframe menu -

i'm making website simple menu bar @ top of each page. make menu easy update, hard-coding whole menu each page not ideal. modifying , re-uploading every page cumbersome , since website hosted statically, cannot use php create menu either. my current solution uses iframe , separate html file menu. pasted in body of each new page: <iframe src="menu.html" width="100%" height="55x" id="menuframe" style="border:none"></iframe> i this, works nicely: <!-- `theme.css` --> #menudiv { width: 100%; height: 38px; } .menu-item { height: 20px; width: 120px; margin: 0; display: inline-block; text-align: center; padding: 4px; border-radius: 50px; background: 000000; border: 2px solid black; } <!-- `menu.html`: --> <!doctype html> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href=&q

ruby on rails - Difference in ways to call partials? -

i assuming applies other things well, i've noticed in tutorials i've gone through far. basically, difference between: <%= render :partial => "shared/warning" %> and <%= render partial: "shared/warning" %> the syntax hash literal in ruby is: { key => value } the key can object, including symbol , eg. { :foo => "bar" } using symbol keys in hash became popular, , idiomatic in ruby in ruby 1.9 optional syntax added hash created symbol keys, , there on following precisely equivalent above: { foo: "bar" } update further specific use case, ruby allows drop {} s when passing hash argument method (as being able drop () s), following equivalent: foobar( { foo: "bar" } ) foobar( foo: "bar" ) foobar foo: "bar" foobar :foo => "bar"

Slider Bar for date time javascript jquery. Need advice -

i see useful link make slider bar date ranges, 1 time , dates. ideally, i'm looking @ times , date within 3 day period. looking able slide 2 points! http://ghusse.github.io/jqrangeslider/ got using formatter: function (value) http://jsfiddle.net/vm844/1861/

Jquery and php not working to load images onto screen from folder -

i have folder images in , trying load images file onto webpage. know images in correct format , dir correct. images not appearing on page. html file. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script> $(document).ready(function() { $.ajax({ url: "loadimages.php", datatype: "json", alert("this working"); success: function(data) { $.each(data, function(i, filename) { $('#imgs').prepend('<img src="' + filename + '"><br>'); }); } }); }); </script> <html> <body> <div id="imgs"> </div> </body> </html> this php file. <?php $filenamearray = [".png"]; $handle = opendir(dirname(realpath(__file__)).'/images/'); while($file = readdir($handle)){ if($fil

javascript - How to use SAP OpenUI5 to display table in frontend? -

i newer sap openui5. want display table in frontend, here code: test.view: var opanel = new sap.ui.commons.panel("panel",{text:"calculated fields"}); var tabledata = { "teammembers":[ {"firstname":"clark", "lastname":"kent", "gender":"male", "occupation":"superman","enable": true}, {"firstname":"donald", "lastname":"duck", "gender":"male", "occupation":"a millionare","enable": true}, {"firstname":"marge", "lastname":"simpson", "gender":"female", "occupation":"a housewife","enable": false}, {"firstname":"jane", "lastname":"marple", "gender":"female", "o

c# - When I type static, Visual Studio replaces it with ContextStaticAttribute -

every time i'd put in static keep replacing contextstaticattribute . i need 10 rep post images, here's link: http://i.imgur.com/jboof3s.png ) i not want have press right arrow put in local variable! i figured out how did typing static inside method. variables in method cannot static, class level elements can. simply declare variables inside class, not method. example: namespace consoleapplication2 { class program { static string username; // correct private static void main() { static // incorrect } } }

mysql - Node.js redis pubsub -

i'm beginner of nodejs. want make chatting service using nodejs. use nodejs/jade/mysql construct basic part of system , want provide pub/sub users. we receive users' interests text field or using hash tags (anyway received users' interests , stored in mysql -> did it). then, want show users chatting room list according interests. instance a's interests 'game', 'car' , 'food', search chat rooms 'game', 'car', 'food' , show these chat rooms first. i want use redis provide service have no idea! 1) installed redis , can run redis-server. 2) //redis var redis = require('redis'); var publisher = redis.createclient(); var subscriber = redis.createclient(); subscriber.on('message', function(channel, message){ console.log('message ' + message + ' on channel ' + channel + ' arrived!'); }); subscriber.on('subscribe', function(channel){ publisher.publ

java - How to create a menu/tab in Android application? -

i'm new java , android studio, i'm learning how make simple app buttons. application has bunch of buttons though, thought nicer if split buttons 2 windows/tabs using menu of sort. right now, xml file looks this: <relative layout.... <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 1" android:id="@+id/opt1" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 2" android:id="@+id/opt2" android:layout_below="@+id/opt2" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="option 3" android:id="@+id/opt3" android:layout_

javascript - Is there a way to make a Point feature show as text? -

in leaflet there option icons div's instead of images. meant make marker text, label moved user. trying reproduce using ol3 no success. is there available in ol3 have text on map behaves point feature? in, can moved in edit mode , attached map in vector layer. yes possible if set correctly style markers (without using image): new ol.style.style({ text: new ol.style.text({...... look @ following working example: http://jsfiddle.net/pfavero/yabta24t/13/

can't find groovy script file on one out of 3 nodes. elasticsearch groovy script in a file -

i'm getting responses 2 out of 3 nodes in cluster. using groovy script *file* in elasticsearch query - groovy script file location the file isn't being found on 3rd node, it's on nodes same name , permissions! nodes named demo01 - 03. here's log output: demo03: [2015-06-18 05:52:21,739][info ][script ] [demo03] removing script file [/etc/elasticsearch/scripts/source_types.groovy] [2015-06-18 06:40:16,764][info ][script ] [demo03] compiling script file [/etc/elasticsearch/scripts/source_types.groovy] [2015-06-18 06:40:41,771][info ][script ] [demo03] compiling script file [/etc/elasticsearch/scripts/source_types.groovy] [2015-06-18 06:41:06,779][info ][script ] [demo03] compiling script file [/etc/elasticsearch/scripts/source_types.groovy] [2015-06-18 06:44:26,788][info ][script ] [demo03] removing script file [/etc/elasticsearch/scripts/source_type

ios - Xcode 7 beta - build error (xcassets) -

i install xcode 7 beta , converted swift project swift 2 guidelines. build ok xcassets: reached error in logs: compileassetcatalog /users/phoenix/library/developer/xcode/deriveddata/{...}/build/products/debug-iphoneos/{...}.app {...}/images.xcassets cd /users/phoenix/dev/xcode/{...} export path="/applications/xcode-beta.app/contents/developer/platforms/iphoneos.platform/developer/usr/bin:/applications/xcode-beta.app/contents/developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /applications/xcode-beta.app/contents/developer/usr/bin/actool --output-format human-readable-text\ --notices --warnings --export-dependency-info /users/phoenix/library/developer/xcode/deriveddata/{...}/build/intermediates/{...}.build/debug-iphoneos/{...}.build/assetcatalog_dependencies.txt --output-partial-info-plist /users/phoenix/library/developer/xcode/deriveddata/{...}/build/intermediates/{...}.build/debug-iphoneos/{...}.build/assetcatalog_generated_info.plist\ --app-icon appicon --

ruby on rails - dynamic cancan from database with complex conditions -

i'm trying define user created roles select permissions list of permissions. want permission this: def initialize(user) user.projects_users.each |project_user| project_user.role.privileges |privilege| can :create, projectsuser, :project_id => project_user.project_id end end end but i'm trying save privileges in database in such way can outcome above def initialize(user) user.projects_users.each |project_user| project_user.role.privileges |privilege| can privilege.action.to_sym, privilege.subject_class.constantize, privilege.conditions end end end the problem lies in 'privilege.conditions' part. cannot store condition must executed in ability.rb file. if try store: { :project_id => project_user.project_id } it there no variable named 'project_user'. save string , in ability file eval(privilege.condition), need on values. tried this: def initialize(user) user.projects_users.each |project_user| proj

composer php - PHP Include class by using "use" with PSR-4 -

i'm using psr-4, defined psr-4 section on composer.json "autoload": { "classmap":[ ], "psr-4": { "app\\": "app/" } }, when tried import class using "use" keyword use app\http\controllers\controller; i error: fatalerrorexception in uploadfilescontroller.php line 13: class 'controllers\controller' not found if set static route file include("c:\xampp\..."); it works, after found same problem other files including php clases illuminate. what's problem?

c# - MonoGame vs Unity3D -

this first question asked on stackoverflow. want ask more experienced game developers better monogame or unity3d. intention learn 1 of these enable me create own android , possibly windows games using c#. of these best suited creation of android games? i'm looking @ making 2d games. appreciated if outline difference between these tools besides 1 being engine , other framework. apologize if in post sounds stupid or incorrect. in defence i'm beginner when comes game development. i assume beginner suggust use unity3d. never worked unity, know there lot implemented you. example: animations, gravity , collision. class mates told me wasn't realy hard(for software engineer student). used ai project. i took xna lesson , xna , monogame pretty same. monogame low level platform. have implement youself. wouldn't realy call engine, more framework. since xna dead, asked teacher: "why learning xha, if xna dead?" well, didn't learn xna, because xna amazin

dns - Can you use Route 53's latency based routing in conjunction with Cloudflare? -

i've registered domain through route 53. records in route 53: fakeelias.ca. #.#.#.# fakeelias.ca. ns brett.ns.cloudflare.com roxy.ns.cloudflare.com fakeelias.ca. soa ns-####.awsdns-17.org. awsdns-hostmaster.amazon.com. staging.fakeelias.ca. #.#.#.# www.fakeelias.ca. alias fakeelias.ca. (z1pgzi762j7wmn) to cloudflare working in front of s3 buckets had replace ns entry cloudflare gave me , cname mappings buckets work through cloudflare. what's not working paths fakeelias.ca, www.fakeelias.ca , staging.fakeelias.ca. i want use latency based routing through route 53 fakeelias.ca point nearest nginx server. staging.fakeelias.ca point nginx staging server. ns entries cloudflare messing up? i'm kinda new dns stuff. update 9/2016: cloudflare has released traffic manager feature can global load balancing , health checks: https://blog.cloudflare.com/cloudflare-traffic-manager-the-details/

c++ - Wrapper for __m256 producing segmentation fault with constructor -

i have union looks this union barevec8f { __m256 m256; //avx 8x float vector float floats[8]; int ints[8]; inline barevec8f(){ } inline barevec8f(__m256 vec){ this->m256 = vec; } inline barevec8f &operator=(__m256 m256) { this->m256 = m256; return *this; } inline operator __m256 &() { return m256; } } the __m256 needs aligned on 32 byte boundary used sse functions, , should automatically, within union. and when this barevec8f test = _mm256_set1_ps(1.0f); i segmentation fault. code should work because of constructor made. however, when this barevec8f test; test.m256 = _mm256_set1_ps(8.f); i not segmentation fault. so because works fine union aligned properly, there's segmentation fault being caused constructor seems i'm using gcc 64bit windows compiler ---------------------------------edit matt managed produce simplest example of error seems happening here. #inc

Restrict Android app to very specific resolutions and screen sizes -

Image
in app plan support few specific screen sizes , resolutions, here are: how can restrict app able installed on these screens? in androidmanifest.xml , or developer console, or both? you can apply add flags in manifest.xml file : http://developer.android.com/guide/topics/manifest/supports-screens-element.html , can restrict : should use attribute in mainfest android:largestwidthlimitdp="enter mobile pixel value above want restrict."

ios - how to define strings in xcconfig and quotes -

i've started using xcconfig file environment specific build settings , noticed string quotes literally interpreted. e.g. app_bundle_displayname_suffix = "debug" will show app name of myapp "debug" display name (with quotes) how handle strings in xcconfig file, necessary define strings? if not how deal empty spaces , escaping? special characters e aware of? the answer depends on actual build setting you're trying change, , gets used. as you've observed, setting app_bundle_displayname_suffix can take single word, , adding quotes here results in them being incorporated xcode value of setting. however, in other places different. particularly, if setting passed onto toolchain during build. in these cases, have use quoting , escaping both xcode and command-line. for example: if want use xcconfig file set preprocessor definitions (i.e. macros) , want define string macro, have escape quotes shell doesn't strip them, , if have

apache - eDismax queries with stopwords and language specific fields -

i have 3 text fields: content_en content_sp content_fr each of above fields has it's own set of analyzers, tokenizers , filters. have own set of stopwords. i use langidentifierprocessor ( https://cwiki.apache.org/confluence/display/solr/detecting+languages+during+indexing ) determine language indexed document in, , solr write content of document correct field. finally, use edismax parser handling queries. qf parameters map 3 fields above , mm parameter set 100%. here issue: when search query of 'yellow house', solr return documents terms yellow , house . great. now, when query 'the yellow house', won't back. after debugging time, have found solr constructs query similar following 'the yellow house': +( (content_sp:the | content_fr:the) (content_en:yellow | content_sp:yellow | content_fr:yellow)(content_en:house | content_sp:house | content_fr:house)) remember have mm set 100%, meaning terms must found in document returned. since term

mysql - Java program connect to access database -

i have java program connects external microsoft access database. following shows code in databasehandler class, used connect database. static public int makeconnectiontofireplacedb() { try { // make connection database connectiontofireplacedb = drivermanager.getconnection("jdbc:odbc:fireplace"); } catch (sqlexception exception) { return (-1); // return -1 if there problem // making connection } return (0); // return 0 if connection made database } // end the follow shows part of code class of program uses external database. class views data database (which @ bottom of code isn't necessary question). when try access database following error: unable connect database table fireplace. if ( databasehandler.loaddriver() == -1 ) { joptionpane.showmessagedialog (frame, "problem loading jdbc/odbc driver."); // check see if can connect database table } else if ( databaseh

html - How to create a circle and a bar that overlap with css? -

Image
for user profile i'm trying create circular image plus horizontal bar same height image. also, should responsive. should in image below. in black bar there text. could please me correct css? so far have code below goes wrong in black bar below circle , not next it. don't know how make black bar start in middle of image, have image on top, , have text in black bar start sufficiently right (while being responsive screen size). <div class="col-md-12 profile-topbar"> <div class="round"> <img src=<%= image_path('profile.gif') %>> </div> <div class="text-bar"> ... </div> </div> in css file: .round { margin: 2em; border-radius: 50%; overflow: hidden; width: 150px; height: 150px; -webkit-border-radius: 50%; -moz-border-radius: 50%; box-shadow: 0 0 8px rgba(0, 0, 0, .8); -webkit-box-shadow: 0 0 8px rgba(0, 0, 0, .8); -moz-box-shadow: 0 0 8px rgba(0, 0,

ios - Parse loginWithUsernameInBackground block callback not working -

so have parse app in appstore already. i'm submit update app using latest parse sdk 1.7.4 , noticed manual parse login not working! i hope due code , not parse issue because that's major f**k if ask me... anyway, here code, appreciated. [pfuser loginwithusernameinbackground:username password:password block:^(pfuser *user, nserror *error) { if (!error) { //do stuff user } else { //error handling here } i of course did search on internet find answer , people saying not use background functions because things need run on main thread. , tried using dispatch async , forced run on main thread still no callback login. here error msg i'm getting: -[bftask isfaulted]: unrecognized selector sent instance *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[bftask isfaulted]: unrecognized selector sent instance when run below code: nserror *error; pfuser *user = (pfuser *)[pfuser loginwithusername:use

svg - Setting id and class with the haskell diagrams package -

i working diagrams package haskell, , using svg backend. embed svg markup directly html document, graph part of web page. have built pretty cool looking bar graph, , add basic interactivity it. example, when hover on bar, i'd make color lighter. or maybe pop well. way accomplish setting class attributes of of svg nodes. possible diagrams package? know can target multiple backends , that class attribute has no meaningful counterpart in of them, wondering if there nevertheless way sneak in backend-specific information. insights can provide. this cannot done in diagrams, although have in future. can part of way there using diagrams-canvas backend, displays on local host , cannot embedded web page. thing can suggest pretty print svg -p command line option , edit svg hand.

android - SSL Exception when using Volley -

i'm using volley in android perform app requests. unfortunately, i'm getting following error: com.android.volley.noconnectionerror: javax.net.ssl.sslhandshakeexception: javax.net.ssl.sslprotocolexception: ssl handshake aborted: ssl=0x61e15f78: failure in ssl library, protocol error error:1407743e:ssl routines:ssl23_get_server_hello:tlsv1 alert inappropriate fallback (external/openssl/ssl/s23_clnt.c:744 0x5b647c58:0x00000000) i'm using 2 fragments , inside viewpager , request content during onresume. requests url same query parameter (which set type of content, e.g. trending vs hot). the url in form https://host/api/content?type={hot/trending} . authorization done through request header. the weird part exception 1 of 2 requests fail , varies 1 time time. after added delay between them, exception stopped occurring (oddly pointing race condition?). seems bad workaround , i'd solve right way. any thoughts on cause of it? edit: the request created stand

embedded - understanding bit shifting in registers -

i have update 32 bit register using these data includes bit shifting, confused 2 things: which lsb , msb, what operator | given expression: 3 << 0 | 7 << 3 | 1 << 6 | 0 << 7 | 1 << 7 | 0 << 8 | 0 << 10 | 0 << 11 | 0 << 12 | 0 << 13 | 0 << 14 and remaining 15 bits 0 . how data shifted, assuming initial bits in register 0's? 011 111 1 0 1 0 0 0 0 0 0 x.......x or x .....x 0 0 0 0 0 0 1 0 1 111 011 the lsb (least-significant bit) bit value represents 1 (2^0) , msb bit value represents 2^(n-1), n number of bits in register. in general, when written out in binary, msb left-most bit , lsb right-most bit. more not, lsb shown bit 0 in hardware documentation, though know 1 company reverses bit numbering msb numbered 0. << c shift-left operator, shifting bit away lsb , toward msb. therefore 7<<3 represents 111000 in binary. | c bit-wise or operator. used combine

Is it possible to use gitHub source control on local machine ? -

my programming language c# ( visual studio ) , android ( android studio ) , need source control use. is possible use github local disk source control ? git version control system can used source code control. works on local filesystems across networks. github online service hosts git repositories. git , github not same thing. https://git-scm.com/ homepage git version control system. https://git-scm.com/book/en/v2 book "pro git" includes information how set repository.

ruby - Rails server gives error when I load localhost:3000 -

this question has answer here: rails 'parse_query' error on server in brand new app 2 answers so, have started learning ruby on rails, used following command create ror project: rails new blog next write following command run rails server: rails s the rails server runs, , load localhost:3000 in web browser; 500 internal error on web browser. the log file has following error: argumenterror (wrong number of arguments (2 1)): actionpack (4.2.2) lib/action_dispatch/http/request.rb:338:in `parse_query' rack (1.6.3) lib/rack/request.rb:191:in `get' actionpack (4.2.2) lib/action_dispatch/http/request.rb:300:in `get' actionpack (4.2.2) lib/action_dispatch/http/parameters.rb:14:in `parameters' actionpack (4.2.2) lib/action_dispatch/http/filter_parameters.rb:37:in `filtered_parameters' actionpack (4.2.2) lib/action_controll

prolog - How to check which items on the list meet certain condition? -

how make function called buslinelonger, receives @ least 2 parameters decide if bus line longer or not? */this how works*/ * busstops(number_of_the_bus,number_of_stops)*/ /*?- buslinelonger([busstops(1,7),busstops(2,4),busstops(3,6)],5,which). * = [1,3]. using comparative things, @> <@ /==@. sorry english edit... far i've think of this buslinelonger([busstops(a,b)|r],n,[_|_]):- n@>b, buslinelonger(r,n,a). here's how using meta-predicates , reified test predicates , , lambda expressions . :- use_module(library(lambda)). first, define reified test predicate (>)/3 this: >(x,y,truth) :- (x > y -> truth=true ; truth=false). next, define three different implementations of buslinelonger/3 (named buslinelonger1/3 , buslinelonger2/3 , , buslinelonger3/3 ) in terms of following meta-predicates: maplist/3 , tfilter/3 , tfiltermap/4 , , tchoose/3 . of course, in end need one ---but shouldn't keep exploring various options have

javascript - Angular module needs to be defined twice -

i have been playing around angular code , found has app.controllers twice on page. once in module of app towards top , once @ bottom. when remove 1 or other code breaks. don't know why need both since app.services doesn't need or directives or filters. insights on why? (function () { angular .module('app', [ 'app.controllers', 'app.services', 'app.directives', 'app.filters' ] ) .config(['$scedelegateprovider','$routeprovider', function ($scedelegateprovider, $routeprovider) { $scedelegateprovider.resourceurlwhitelist([ 'self', 'https://maps.google.com/**']); $routeprovider // home .when('/', { templateurl: 'partials/home.html' } ) // default .otherwise('/'); } ] ); angul

Coldfusion 9 Flash Multifile Upload Widget fails due to unrelated code -

this issue continues along inability run remaining parts of process in application, namely file sorting file type , compression capability. i'm running issue pdf compression code causing multifile uploader freeze @ 99%, still uploading first file preventing subsequent files uploading. issue 1: file upload fails when try exclude pdf files list. issue 2: presence of query , loop code compress pdf files causes fileuploader stop @ 99%, still uploading first file no subsequent files in multi-file upload. multifile upload handler code <cfif files eq 'multiple'> <cffile action="upload" destination= "c:\uploads\" result="myfiles" nameconflict="makeunique" > <cfset filesys = createobject('component','cfc.filemanagement')> <cfif len(get.realec_transactionid)> <cfset internalonly=1 > </cfif> <cfset uploadedfilenames='#myfiles.clientfile#' > <

r - How to convert class of several variables at once using dplyr -

so have data frame several variable characters want convert numeric. each of these variables starts "sect1". can 1 @ time, i'm wondering if can accomplished @ once. i've done in clunky way using following code. maybe there's better way? df=data.frame(sect1q1=as.character(c("1","2","3","4","5")), sect1q2=as.character(c("2","3","4","7","8")),id=c(22,33,44,55,66), stringsasfactors = false) df1 = sapply(select(df,starts_with("sect1")),as.numeric) df = select(df,-starts_with("sect1")) df =cbind(df,df1) try mutate_each , (as per @franks comment %<>% operator magrittr package in order modify in place ) library(magrittr) df %<>% mutate_each(funs(as.numeric), starts_with("sect1")) str(df) # 'data.frame': 5 obs. of 3 variables: # $ sect1q1: num 1 2 3 4 5 # $ sect1q2: num 2 3 4 7 8 # $ id : num 22

sorting - Using linux sort on multiple files -

is there way can run following command linux many files @ once? $ sort -nr -k 2 file1 > file2 i assume have many input files, , want create sorted version of each of them. using like for f in file* sort $f > $f.sort done now, has small problem if run again, if not sort files again, create file1.sort.sort go file1.sort. there various ways fix that. can fix second problem creating sorted files thate don't have names beginning "file": for f in file* sort $f > sorted.$f done but that's kind of weird, , wouldn't want files named that. alternatively, use more clever script checks whether file needs sorting, , avoids both problems: for f in file* if expr $f : '.*\.sort' > /dev/null : no need sort elif test -e $f.sort : sorted else sort -nr -k 2 $f > $f.sort fi done

python - Placing every value in its percentile in Pandas -

consider series following percentiles: > df['col_1'].describe(percentiles=np.linspace(0, 1, 20)) count 13859.000000 mean 421.772842 std 14665.298998 min 1.201755 0% 1.201755 5.3% 1.430695 10.5% 1.438417 15.8% 1.466462 21.1% 1.473050 26.3% 1.500834 31.6% 1.512218 36.8% 1.542935 42.1% 1.579845 47.4% 1.647162 50% 1.690612 52.6% 1.749047 57.9% 1.955589 63.2% 2.344475 68.4% 3.075641 73.7% 4.466094 78.9% 8.410964 84.2% 14.998738 89.5% 41.363612 94.7% 162.865079 100% 1511013.790233 max 1511013.790233 name: col_1, dtype: float64 i column col_2 percentile each row assigned in calculation made above. how can in pandas? df2 = pd.dataframe(range(1000)) df2.columns = ['a1'] df2['percentile'] = pd.qcut(df2.a1,100, labels=false) or l

sql - How check if the sum of the values of two columns, in the same row have exactly 100 as result in mysql -

i have problem in mysql (phpmyadmin).. should want check if values of 2 columns 100… example have table | blablabla | blablabla | value1 | value2 | and user want add values(bla, bla, 20, 30).. 20 , 30 can't added in table because 20+30<>100.. code is: alter table `partita` check (`100` = (select (`possesso_palla_casa`+`possesso_palla_ospite`) `partita`)) but naturally wrong.. how can do? thank all!!! as commented mysql doesn't support check constraint. per mysql documentation says: the check clause parsed ignored storage engines you should rather use before insert trigger alternative below delimiter // create trigger sumcheck_before_insert before insert on bla_table each row begin if (new.value1 + new.value2 <> 100) signal sqlstate '45000' set message_text = 'can not insert data'; end if end; // delimiter ;

java - What's wrong with Add() constructor? -

this question has answer here: java: inherit constructor 5 answers i'm trying add 2 numbers using multithreading showing following error on compiling : " constructor add in class add cannot applied gives types; class input extends add{ required: int,int found: no arguments reason: actual , formal arguments lists differ in length import java.util.scanner; class add implements runnable{ thread t; int a,b,c; add(int a,int b){ this.a=a; this.b=b; t = new thread(this,"add"); t.start(); } public void run(){ c=a+b; system.out.println("exiting add thread."); } } class input extends add{ public static void main(string args[]){ scanner sc = new scanner(system.in); add o = new add(5,4); system.out.println("enter string: "); st

css - How to add custom font at wordpress -

the source of font is: /htdocs/wp-content/themes/elegance/fonts/pizza.otf i add css(style.css): @font-face { font-family:'pizza'; src: url('fonts/narkis.otf'); } and add also: html,body,div,form,fieldset,input,textarea,h1,h2,h3,h4,h5,h6,p,ul,ol,li{ vertical-align:baseline;font-size:100%;padding:0;margin:0;font-family:'pizza'; } its not working..

Choosing Google Cloud Storage object name when uploading a file using Python blobstore API -

i migrating blobstore google cloud storage in google app engine python app. use blobstore api when uploading gcs. ok, according gae python documentation regarding blobstore the flow works storing blobstore. client requests upload url, blobstore.create_upload_url(...) creates it, client uploads file via multipart post, , server redirects upload handler in gae application. the problem though got choose gcs bucket (it 1 of parameters of create_upload_url call) don't see how can choose file name. break down folders. inspiration comes google app engine blobstore google cloud storage migration tool filename broken browsing of gcs "folders" manageable. i know of 1 way of naming gcs file - forego blobstore api. instead client upload file gae handler, use lib.cloudstorage write file data gcs - exacly quoted migration tool does. i lose gcs goodies retries on errors during upload. the question: there way upload file directly gcs, while impacting way resulting gcs o

functional programming - Accessing call stack depth in Scheme -

in order demonstrate effectiveness of tail recursion, way access depth of call stack dynamically in scheme. is there way this? if not, there way in other major functional languages (ocaml, haskell, etc.)? racket allows store values in call stack. can use keep track of depth. here how it: #lang racket ;;; module holds tools keeping track of ;;; current depth. (module depth racket (provide (rename-out [depth-app #%app]) current-depth) (define (extract-current-continuation-marks key) (continuation-mark-set->list (current-continuation-marks) key)) (define (current-depth) (car (extract-current-continuation-marks 'depth))) (define-syntax (depth-app stx) (syntax-case stx () [(_depth-app proc args ...) #'(let ([p (with-continuation-mark 'depth (+ (current-depth) 1) proc)] [as (with-continuation-mark 'depth (+ (current-depth) 1) (list args ...))])

python - Django naturaltime() adds strange characters -

with django 1.8.2 when use naturaltime on timestamp ready following result: from django.contrib.humanize.templatetags.humanize import naturaltime naturaltime(datetime.datetime(2015, 6, 16, 19, 37, 38, 338598)) '2\xa0days ago' if downgrade earlier django (e.g. 1.6.2), result want: '2 days ago' does know why be?

css - How Can I Override Bourbon Styles in Modal Refill? -

i using bourbon modal reset . close button comes following styling: .modal-close { @include position(absolute, ($modal-padding /2) ($modal-padding /2) null null); @include size(1.5em); background: $modal-background; cursor: pointer; &:after, &:before { @include position(absolute, 3px 3px 0 50%); @include transform(rotate(45deg)); @include size(0.15em 1.5em); background: $modal-close-color; content: ''; display: block; margin: -3px 0 0 -1px; } &:hover:after, &:hover:before { background: darken($modal-close-color, 10%); } &:before { @include transform(rotate(-45deg)); } } this makes grey × in upper right of modal. however, change button says "save , close". i'm wondering best method of overriding these styles is. on properties margin , can set whatever want. on @include position(....); , not sure how can reset none , initial , or

android - native activity camera on lollipop with opencv -

it seems opencv can't use native camera on android 5.+ ( lollipop ). cf : http://code.opencv.org/issues/4185 is there other way grab pictures native activity , convert cv::mat ? or, maybe use jni call grab function in java c++ activity ? thank help charles you use jni call grab function in java c++ activity, this(threshold example): java code: //override javacameraview opencv function public mat oncameraframe(cvcameraviewframe inputframe) { mrgba = inputframe.rgba(); mgray = inputframe.gray(); processimage.threshold(mgray, mgray, 97, 0); return mgray; } // functions public static void threshold(mat srcgray, mat dst, int thresholdvalue, int thresholdtype) { nativethreshold(srcgray.getnativeobjaddr(), dst.getnativeobjaddr(), thresholdvalue, thresholdtype.ordinal()); } private static native void nativethreshold(long srcgray, long dst, int thresholdvalue, int thresholdtype); jni c++ code: jniexport void jnicall java_{package}_native

xml - XSLT - Trouble to filter parent nodes by its childs using a configuration node -

i have situation in xsl can't figure out how resolve. i have following xml, , want show main nodes have @ least 1 item enabled config/enable-items nodes. any hints? thanks in advance. xml: <xml> <main name="main section 1" id="1"> <item id="a"> </item> <item id="b"> </item> <item id="c"> </item> </main> <main name="main section 2" id="2"> <item id="d"> </item> <item id="e"> </item> <item id="f"> </item> </main> <config> <enable-items> <item id="a" /> <item id="b" /> </enable-items> </config> </xml> wanted output: main section 1: * * b p.s.: i've tried using key, defining key enable-items indexed id attribute, , doing