Posts

Showing posts from March, 2010

eclipse - import JavaFX project on Android Studio -

i made javafx program on eclipse works well, want convert program android app. used gradle eclipse , got file "build.gradle" import project on android studio importing "build.gradle" eclipse said. don't know how convert javafx program android app , don't know how use android studio. can me ? here's project structure on android studio : --puzzle_fx --.idea --copyright profiles_settings.xml --scopes scope_settings.xml .name compiler.xml encodings.xml gradle.xml misc.xml modules.xml vcs.xml workspace.xml --.settings org.eclipse.jdt.core.prefs --bin --org --puzzle --colors ccolors.class --commands commands.txt smartinput.class --controllers controller.class --fonts apple.ttf bit.ttf pixelmix.ttf pixelmix_bold.ttf wendy.ttf --fra

HTML5 Video not playing in iOS Simulator Safari -

Image
i'm using ios simulator test website on iphone , ipad. have video tag works in every other browser not ios safari (in simulator - don't have actual iphone/ipad). created video tag here: http://camendesign.com/code/video_for_everybody#video-code <!-- first try html5 playback: if serving xml, expand `controls` `controls="controls"` , autoplay likewise --> <!-- warning: playback not work on ios3 if include poster attribute! fixed in ios4.0 --> <video width="640" height="360" controls> <!-- mp4 must first ipad! --> <source src="testvideo.mp4" type="video/mp4" /><!-- safari / ios video --> <source src="testvideo.ogv" type="video/ogg" /><!-- firefox / opera / chrome10 --> <!-- fallback flash: --> <object width="640" height="360" type="application/x-shockwave-flash" data="player.swf">

sorting - How to use orderBy in AngularJS (1.2) to sort, without having incomplete entries jump around -

okay i'm doing basic crud angularjs. here's view: <table> <tr ng-repeat=="person in persons | orderby:lastname"> <td> {{person.firstname}} </td> <td> {{person.lastname}} </td> <td> </td> </tr> <tr> <td> <input ng-model="person.firstname"> </td> <td> <input ng-model="person.lastname"> </td> <td> <button ng-click="save(person)">save</button> </td> </tr> </table> the problem type new user inputs, position of row jumps around fits alphabetically. want happen, when user done typing , hits "save." you should update binding of scope variable on blur, should @ ng-model-options i'd suggest should go ng-model-options=

wpf - Shared definition in ResourceDictionary or CodeBehind? -

just wondering ... shared definitions (e.g. colors, brushes), better put in resourcedictionary (in xaml) or code-behind (c#)? assumption: usage of these definitions in both xaml , code-behind. for example colors definition, seems every tutorial read off internet put in resourcedictionary - <solidcolorbrush x:key="color1" color="#cccccc"/> . however, won't better if put in code-behind public static solidcolorbrush color1 = new solidcolorbrush(#cccccc); , accessing in xaml via x:static extension - {x:static local:mycolor.color1} ? in way, can nice intellisense in both xaml , code-behind. in addition, avoid hard coding of key in code behind - solidcolorbrush color1 = findresource("color1") style . edit: objective to: have nice intellisense in both xaml , codebehind unified definition ensure no chance of runtime error due hard-coding better performance so when designer access background="{staticresource color1}" in x

jquery - How to POST data using the 'save' method of the backbone.js -

i;m trying save form data using backbone 'save' method. i'm using post http method saving data server. data saved server, in network console, see post status shows cancelled, creates data. here js: var account = backbone.view.extend({ el: "#account", events:{ 'click button#save' : 'savelist' }, render: function(id){ value = new accountmodel([],{id:id}); }, savelist: function(event){ var values = $('#form').serializejson(); value.save(values, { success: function(value){ console.log(“success”) }, error: function(err){ console.log('sorry, record not saved' + err); } }); }); html: <form class="form" id="form"> <table> <tbody> <tr> <label>nam

sql - Block inserts using for update -

i trying prevent inserts happening using select update in oracle. instance suppose in 1 session (autocommit off, isolation level = serializable) address table contains no rows , in session1: session1: select * address addressid = 1 update now in session2: session2:insert address (addressid, street, city,zip) values (1, 'main','ny','12345'); commit; i have thought blocked. however, i'm finding insert happens. able commit it. in session1 again. session1: insert address (addressid, street, city,zip) values (1, 'main','ny','12345') this gives integrity constraint error before commit. (not serializable exception have expected). why happening? using oracle 12c. there couple of unexpected results. first why constraint error in session1 before commit? oracle should not see insert other session. secondly, shouldn't insert in session1 blocked due "for update" select? finally, there way block inserts par

oracle11g - Oracle listagg query -

this query result: weekenddate ccname phname ratio 08-feb-15 apple line 1 - day l&i work 0.45 08-feb-15 apple line 1 - day sorter 6.85 08-feb-15 apple line 1 - day tray fill 12.93 08-feb-15 apple line 1 - day wh general labor 5.6 08-feb-15 apple line 1 - day wh supervisor 1.48 15-feb-15 apple line 1 - day l&i work 0.42 15-feb-15 apple line 1 - day sorter 6.09 15-feb-15 apple line 1 - day tray fill 11.9 15-feb-15 apple line 1 - day wh general labor 5.42 15-feb-15 apple line 1 - day wh supervisor 3.46 22-feb-15 apple line 1 - day l&i work 0.43 22-feb-15 apple line 1 - day sorter 6.01 22-feb-15 apple line 1 - day tray fill 12.09 22-feb-15 apple line 1 - day wh general labor 4.9 22-feb-15 apple line 1 - day wh supervisor 1.71 my boss wants data sideways. is there way query result formatted this: ccname ph

box api - Is it possible to set the order of returned folder item's in the Box REST API? -

the response has order results returned in, possible set order in request? it possible set limit , offset when executing folder’s items, functionality seems incomplete if order can't supplied. as per documentation example, limit , offset url parameter can set. curl https://api.box.com/2.0/folders/folder_id/items?limit=2&offset=0 \ -h "authorization: bearer access_token" unfortunately, isn't possible customize order of items returned api. the limit , offset parameters used page through large arrays, since it's possible folder have thousands of items can't returned in single response.

sql - Dynamic PIVOT with Numbered Column Names -

i'm getting following when trying pivot table: country birmingham dallas new delhi --------------------------------------- india null null new delhi uk birmingham null null usa null dallas null however, i'm trying (the total amount of distinct cities per country): country city1 city2 city3 ---------------------------------------- india new delhi bangalore hyderabad uk london birmingham portsmouth usa dallas indianapolis houston this code i'm using: -- dynamic pivot declare @dynamicpivquery nvarchar(max) declare @colname nvarchar(max) --get distinct values of pivot column select @colname = coalesce(@colname + ',','') + quotename(city) (select distinct city countries) b order b.city --prepare pivot query using dynamic set @dynamicpivquery = n'select country, ' + @colname + ' countries pivot (max(city) city

jquery - How to display correct value on toolitp? -

i have following code assign value toolip, seem work somewhat. problem having when mouse on home shows last mousedover " music " instead of current mouseover. how can show correct text on mouse over js $(document).ready(function() { $(".nav#menu span ").mouseover(function() { var val = $(this).html(); console.log("spanval "+val) $(".nav#menu li a").attr('data-original-title',val); $('[data-toggle="tooltip"]').tooltip(); }) }); html <div ng-controller="" ng-click=""> <ul class="nav" id="menu"> <li> <a class="toggle-button-on" data-toggle="tooltip" data-placement="right" data-original-title=""><i class="fa fa-exchange">toggle</i></a> </li> <li>

c - perror usage in this case? -

i've written small program (with code so) printenv | sort | less , want add error-handling perror , checking return values. i've never done before suppose similar exception handling. need check errors execvp, fork, pipe , dup2. have code #include <sys/types.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> struct command { const char **argv; }; /* helper function spawns processes */ int spawn_proc (int in, int out, struct command *cmd) { pid_t pid; if ((pid = fork ()) == 0) { if (in != 0) { dup2 (in, 0); close (in); } if (out != 1) { dup2 (out, 1); close (out); } return execvp (cmd->argv [0], (char * const *)cmd->argv); } return pid; } /* helper function forks pipes */ int fork_pipes (int n, struct command *cmd) { int i; int in, fd [2]; (i = 0; < n - 1; ++i)

php - How to update a model with more conditions than an ID in Laravel? -

i'm new in laravel 5.0 , trying find user update him conditions status or expiration date. when use find method given user id ok update cause app\user instance possible update: $user->fill($newdata)->save(); but when need set conditions query, instance illuminate\database\eloquent\builder , not have fill method cause isn't app\user (isn't eloquent model): $user = \reverse\interest::find($id) ->where('status', '<>', 'deleted') ->where('expires_at', '>=', db::raw('now()')) so, $user->fill($newdata)->save() impossible... how find user id , more conditions , app\user instance update instead illuminate\database\eloquent\builder instance? just call first() , use where('id', ... : $user = \reverse\interest::where('id', $id) ->where('status', '<>', 'deleted') ->where('expires_at', '>=', db::raw

javascript - Using clickToggle and closing element when another is clicked -

i wrote code based off of felix kling's response click toggle . wondering if there better way of writing it, , how close element when clicked. i using play points of video on click , close them on secondary click. i have wrote function close on escape classes, slows down , breaks event completing. $(document).on('keydown', function(e) { if(e.keycode == 27) { var buttons = $("button"); if ( buttons.hasclass("open") ) { myvideo.currenttime = 2.8; myvideo.play(); settimeout(function() { myvideo.pause(); }, 540); buttons.removeclass("open"); } } }) var myvideo = document.getelementbyid("video"); $("#button-1").clicktoggle(function() { myvideo.currenttime = 2; myvideo.play(); $(this).addclass("open"); settimeout(function() { myvideo.pause(); }, 900); }, function() { my

javascript - Angular - Multiple column filters for table -

i have table want have input box below each table header filter corresponding column. have 2 questions: 1. between thead tag, how use "header" variable value enclosed ng-model? 2. between tbody tag, best approach specify column name in ng-repeat filter (filter:{ column_name: model_name })? <table class="table table-striped table-bordered"> <thead> <th ng-repeat="header in tableheaders">{{header}}<a ng-click="sort_by(header);"></a> <div> <input type="text" ng-model="search" ng-change="filter()" class="form-control"/> <!-- value ng-model should match header variable in enclosing ng-repeat --> </div> </th> </thead> <tbody> <tr ng-repeat="data in filtered = (list | filter:{ status: search} | orderby : predicate :reverse) | startfrom:(currentpage-1)*ent

gulp-changed does not overwrite files with differing content -

if make 2 files in 2 sibling directories different content: nvioli$ echo "a" > test1/file.txt nvioli$ echo "b" > test2/file.txt then use gulp output first 1 destination folder, , try overwrite second one, filtering gulp-changed using sha1digest comparator: var changed = require('gulp-changed'); gulp.task('test1', function(){ return gulp.src("test1/file.txt") .pipe(gulp.dest("dst")) }); gulp.task('test2', function(){ return gulp.src("test2/file.txt") .pipe(changed("dst"), {haschanged: changed.comparesha1digest}) .pipe(gulp.dest("dst")) }); nvioli$ gulp test1 [16:18:01] using gulpfile ~/git/node/gulpfile.js [16:18:01] starting 'test1'... [16:18:01] finished 'test1' after 12 ms nvioli$ gulp test2 [16:18:16] using gulpfile ~/git/node/gulpfile.js [16:18:16] starting 'test2'... [16:18:16] finished

Android - View.GONE bug in 5.1 -

there coach marks view overlay showing during first time start of app. after user sees overlay , performs action setting view's visibility view.gone. has worked 4.0.4 - 5.0.2 versions of android. seeing crashes in our logs several 5.1 users. crashes seem saying view being set gone being nulled out , when call getvisibility() on view null pointer exception. not setting view null seems android deciding view should null since it's visibility set gone. doesn't happen every time user uses 5.1 device seems happening when user leaves app while , comes it. error occurs on 5.1, other android versions work fine. is android 5.1 bug or need handle view's visibility differently? edit: here stack trace. view null , why getting nullpointerexception. however, not doing make view null. believe android 5.1 deciding view should null since visibility set gone, randomly sets view null. doesn't happen in other versions of android, in android 5.0.2 code works fine. java.lang.nul

localhost - Ionic mobile browser testing is not working -

i try use mobile browser testing ionic. i'm connected in same wifi iphone , checked ip-address following command: ifconfig |grep inet . when i'm running ionic server command ionic serve i'm not able open ionic app on iphone using ip-address , specified port ionic. have enable else on machine? tried different ports without success. this answer may late, hope useful has same problem in future. solved issue me put following command: ionic address , select ip of dev server(in case 192.168.0.2 ) instead of localhost option. when run ionic serve can succesfully connect mobile browser.

python - how to preserve leading zeros in Flask routing -

i'm building urls this, routing flask: http://hostname/nris/resource/00001234 http://hostname/nris/resource/99000025 the last segment 8 digit integer match string in database. leading zeros, if any, significant. i've implemented custom regex converter, based on does flask support regular expressions in url routing? . works fine long numeric field starts non-zero. here's routing code (loaded within /nris/ ): @app.route('/numish/<regex("[0-9]{8}"):resourcenum>/') def numish(resourcenum): return "resourcenum: %s" % (resourcenum) @app.route('/resource/<regex("[0-9]{8}"):resourcenum>/') def resource_page(resourcenum): return render_template('singlemap.html', propnris=resourcenum) when visit http://hostname/nris/numish/00000004 , see resourcenum: 00000004 but when display in template, that's shown on console 4, , database query performed in addsinglesitelayer() gets 4, not 00000004.

javascript - Select Options to trigger table appearance -

i have table 2 columns. have select option dropdown box. have 6 different values table row correspond color, green being good, red being bad, , on. want accomplish when user loads page values present. when user selects value dropdown box, value selected disappears. my javascript function select_mem() { if ($("select[name='status-type']").val() == "all") { $('.num-good').show(); $('.num-not').show(); $('.num-not-working').show(); $('.num-bad').show(); $('.num-blue').show(); } if ($("select[name='status-type']").val() == "good") { $('.num-good').show(); $('.num-not').hide(); $('.num-not-working').hide(); $('.num-bad').hide(); $('.num-blue').hide(); } if ($("select[name='status-type']&

Java reading and then modifying binary tree and then saving changed tree to a text file -

http://pastebin.com/72sgpe4v -animalguess class http://pastebin.com/u4rse5ue -animalnode class so goal of program have computer guess animal thinking of , if doesn't, user adds in animal thinking of , question distinguish animal previous animal. once user chooses not continue playing, program exits. when program exits, , started again, program not remember questions user put program during previous run. need program read in text file or without binary tree data in , write out new binary tree made user text file later use. can't find right place put in write out data text file. thought after line 13 in animalguess.java keep getting errors. i think should try iterating through contents of rootoftree after while loop ends , writing them file (right after line 14).

Stop WordPress from 301 redirecting /index.php to / -

i need able browse http://www.example.com/index.php , wordpress automatically 301 redirects http://www.example.com/ . is possible stop redirection homepage? here .htaccess file: # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> # end wordpress the redirection occurs in redirect_canonical function. there filter applied redirect url before redirection occurs: $redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url ); if hook filter should able disable redirection. add_filter('redirect_canonical', function($redirect_url, $requested_url) { if($requested_url == home_url('index.php')) { return ''; } }, 10, 2); i verified working adding above filter theme's functions.php file. note filter must attached before

c# - add more than one control from code behind? -

what want add more 1 control code behind website, know how add 1 control, want add 2 controls @ same time, when click on other button! here code, add second button! protected void unnamed2_click(object sender, eventargs e) { button b = new button(); (int = 0; < 2; i++) { b.id = i.tostring(); b.text = i.tostring(); b.width=250; b.height = 100; b.style.add("background-color", "red"); page.form.controls.add(b); } } the new button() needs in loop... otherwise create 1 instance. for (int = 0; < 2; i++) { button b = new button(); b.id = i.tostring(); b.text = i.tostring(); b.width=250; b.height = 100; b.style.add("background-color", "red"); page.form.controls.add(b); }

hadoop - How to output a sequence file in mapreduce program -

i have map-reduce job takes avro file input, mapper extends avromapper class. here driver program public static void main(string[] args) throws exception { //job configuration jobconf conf = new jobconf(seqfilegenerator.class); conf.setjobname("sequence file generator"); fileinputformat.setinputpaths(conf, new path("in")); fileoutputformat.setoutputpath(conf, new path("out")); avrojob.setmapperclass(conf, avroreadermapper.class); avrojob.setinputschema(conf, contentpackage.schema$); avrojob.setoutputschema(conf, pair.getpairschema(schema.create(type.string),schema.create(type.int))); jobclient.runjob(conf); } as shown in code, have use avrojob class define job. i'd program output sequence file looks have define schema output otherwise doesn't run. in other words, output has avro!! how can output sequence file in program?

graph - How would you replicate this graphic in R -

Image
i'm wondering how graph in r? i tought using geom_bar ggplot package. don't know how plot changing thickness , colors reflect growth years @ same time. i'd appreciate ideas. thank you. here steps start. nothing special, rectangles. there lot of information going on in chart, of in text along sides, meaning chart isnt effective. the useful info chart shows yearly change in colors. can below colored based on rectangle height. but +1 finding way visualize data. set.seed(1) nr <- 4 nc <- 50 mm <- matrix(sort(runif(nr * nc)) * 10, nr, nc) nn <- matrix(sort(runif(nr * nc), decreasing = true) * 10, nr, nc) mm <- do.call('rbind', l <- list(mm, nn))[order(sequence(sapply(l, nrow))), ] yy <- 50 mm <- rbind(mm, yy - colsums(mm)) nr <- nrow(mm) plot(0:nc, type = 'n', ylim = c(0, yy), bty = 'n', axes = false, ann = false) rect(s <- sequence(nc), 0, s + .95, mm[1, ], border = na, col = as.numeric(cu

ruby - Active Record Association not saving in database -

i have 2 models: class tool < activerecord::base belongs_to :user end class user < activerecord::base has_many :tools, dependent: :destroy end and created migration provide foreign key of model: class adduseridtotool < activerecord::migration def change add_column :tools, :user_id, :integer end end i have following form: <%= form_for @tool, :html => { :multipart => true } |f| %> <% if @tool.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@tool.errors.count, "error") %> prohibited tool being saved:</h2> <ul> <% @tool.errors.full_messages.each |message| %> <li><%= message %></li> <% end %> </ul> </div> <% end %> <div class="field"> <%= f.label :name %><br> <%= f.text_field :name %> </div> <div class="field"

adobe - Error occurred while creating TTS audio for <slide_name> -

this might 1 errors might hit when have installed captivate voices 8 , try first tts.it quite annoying there nothing wrong in here. problem? os: osx captivate version: 8.0.1 captivate voices ver: 8 this link helped me first point. fix simple took me lot of search , hope save someone's time re-direction

javascript - How to Disable "Auto-resume Login" / "Remember Me" functionality for Meteor Accounts -

meteor accounts auto-resumes login session default, pretty handy applications. however, in case, need disable functionality. best/proper way remove feature if browser window closed , reopened, login session not persist? thanks in advance.

How often is UML diagramming used "in the real world?" -

almost every 1 of programming classes has made use of uml, none have explained when or might used in professional setting. done every single file in project, or there rule of thumb of when might want use it? also, more commonly done hand (which i've dreaded) or using sort of generator? this question example of opinion-based , broad question no real problem solve behind , no 1 correct possible answer certainly in amount of millions of software developers there learned use uml , use it. , there either did not learn use uml or don't use whatever reason i recall in pre-agile era believed no "big" software can realized without thorough analysis , modeling phase , no "big" software contract can signed if business documents don't include uml -style pictures and in countries still true , government-owned agencies declare kind of documentation software contractor must provide, , of requirements uml picture form see also: wikipedia: ra

c# - How can I change an instance variable from within a static method? -

i implementing unity3d ads android game. i'm using helper class unity provides manage different events. if user watches video , completes it, reward user play money(candy). method called after video ad has been initialized: private static void handleshowresult (showresult result) { switch (result) { case showresult.finished: debug.log("the ad shown."); break; case showresult.skipped: debug.log("the ad skipped before reaching end."); break; case showresult.failed: debug.logerror("the ad failed shown."); break; } } in class comments says should customize method perform actions based on whether ad shown or not. if ad shown want update user's candy. here candymanager class updates candy user collects or earns in game: [system.serializable] public class candymanger : monobehaviour { // start public text

algorithm - Efficient way to filter a number of things -

there list of venues. each venue has price attached given, , latlon. user enters max distance , max price, , app returns list of venues fit criteria. distance needs calculated on query, can make sort of structure using price or given latlons. know how figure out in o(n) - traverse list of restauraunts, adding them result if fit criteria. is there way more efficiently? i'm thinking making bst using price key (which can calculated before runtime), cutting off section of bst that's on price limit, , iterating through in bst, still in o(n), right? one way think problem treat multidimensional range search problem. each venue can thought of point in three-dimensional space given longitude, latitude, , price. if want find venues within radius of given point price @ amount, you're searching points in cylinder given center , radius upper , lower bounds max price , 0, respectively. you might want consider using multidimesional search tree structure k-d tree or r-tree

javafx - change achorpane effect after closing another screen -

i have fxml file called principale.fxml contain buton. when click on stage opened , boxblur effect added anchorpane in principale.fxml. iwant set effect null anchorpane when close second stage here code: principale.fxml info.addeventhandler(mouseevent.mouse_clicked, new eventhandler<mouseevent>() { @override public void handle(mouseevent event) { parent home_page_p = fxmlloader.load(getclass().getresource("/view/information.fxml")); scene home_page_s = new scene (home_page_p); javafx.scene.effect.boxblur bxb = new boxblur(); ancr.seteffect(bxb); stage stage = new stage(); stage.initstyle(stagestyle.undecorated); stage.setscene(home_page_s); stage.show(); } catch (ioexception ex) { logger.getlogg

Trigger in oracle SQL - Validation? -

hello guys i'm trying create trigger validate data, i've got table called 'events' , need create trigger give me error when try add event in july. create or replace trigger concert_trigger after insert on concert when (event_date = 'july') begin alter table concert add constraint chk_concert check (event.date ='july') end; here trigger have started think way go i'm not sure if right. thanks, leprejohn since classwork requires use of trigger you'd want like create or replace trigger concert_bi before insert on concert each row begin if to_char(event_date, 'mon') = 'jul' raise_application_error(-20666, 'no concerts can scheduled in july'); end if; end concert_bi; here i'm assuming event_date actual date instead of character string; if bad guess change comparison appropriately. share , enjoy.

Update mysql database table with PHP -

my database has lot of columns customers info , of them duplicates. need update "sale" field of table depending on ip address (which known), the latest entry such ip address. here table: |sale | ip | date | +-----+-------------+----------+ |0 | 109.86.75.1 |2015-12-01| |0 | 109.86.75.2 |2015-12-05| |0 | 109.86.75.2 |2015-12-12| |0 | 109.86.75.4 |2015-12-13| let's assume need add changes customer ip = 109.86.75.2, need change sale 1 in third row, there 2 entries such ip, time of third row latest. table should after update: |sale | ip | date | +-----+-------------+----------+ |0 | 109.86.75.1 |2015-12-01| |0 | 109.86.75.2 |2015-12-05| |1 | 109.86.75.2 |2015-12-12| |0 | 109.86.75.4 |2015-12-13| i use such php code: <?php $servername=...; $username=...; $password=...; $dbname=...; $ipaddress="109.86.75.2"; $conn = new mysqli($servername, $username, $password, $dbname); $sql="update my_dat

ember.js - Generated Application Controller #needs does not include itself -

i'm migrating web app ember tools ember-cli , having issues. far i've been able handle of errors, not one. have auth controller. on several pages include needs:["auth"] , error i'm seeing when restarting server quite odd. referenceerror: (generated application controller)#needs not include `auth`. access auth controller (generated application controller), (generated application controller) should have `needs` property array of controllers has access to. i'm not sure error means necessarily, i'm able debug compiled script in firebug, it's not working when try adding needs:whatever auth controller itself. thanks in advance.

java - Convert sub-type to super-type -

i have abstract super class a, , subclass b extends class. public abstract class { } public class b extends { } i have method returns type a, object b public fetchtype() { a = new b(); return a; } when call fetchtype method, want object a. in case, might have cast b a. can please advise how do that? you cannot create object if type abstract. here class a abstract class, means never able create object a . this not allowed: a = new a();

How do I get the possible "self attributes" of a Python class? -

for example how can define properties of class object in python? how can define happens when add 2 objects? or multiply them? or divide them? or print them? or if call 1 number of arguments? i see things __mul__ , __add__ these called , rest? this called operator overloading. class human(object): def __init__(self, name): self.name = name def __add__(self, other): return '{0} {1}'.format(self.name, other.name) def __mul__(self, other): return self.name * len(other.name) def __str__(self): return self.name bob = human('bob') sam = human('sam') print sam + bob # calls __add__ print sam * bob # calls __mul__ print bob # calls __str__

java - Retrieving MAC Address Programatically - Android -

hey guys im having issue retrieving mac address of device programatically, before mentions other posts have read them such as: how find mac address of android device programmatically however tried using code own application , tested simple log.d, find returning nothing. message of "seeing if works shows" nothing else. presuming mac address null. log.d("seeing if works", macaddress2); the code of have done shown here: //set onclick listener mac address button getmac.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { wifimanager wifimanager = (wifimanager) getsystemservice(context.wifi_service); wifiinfo winfo = wifimanager.getconnectioninfo(); string macaddress2 = winfo.getmacaddress(); macaddress.settext(macaddress2); } }); which android version testing on? latest(10/2015) android m preview

angularjs - ngModel and How it is Used -

i getting started angular , ran directive below. read few tutorials , reading now, don't understand "require: ngmodel" does, because have no idea ngmodel overall. now, if not insane, it's same directive provides 2 way binding (the whole $scope.blah = "blah blah" inside ctrl, , {{blah}} show 'blah blah' inside html element controlled directive. that doesn't me here. furthermore, don't understand "model: '@ngmodel' does. @ngmodel implies variable on parents scope, ngmodel isn't variable there. tl;dr: what "require: ngmodel" do? what "model : '@ngmodel'" do? *auth service passes profile's dateformat property (irrelevant q) thanks in advance help. angular.module('app').directive('directivedate', function($filter, auth) { return { require: 'ngmodel', scope: { model : '@ngmodel', search: '=?search'

javascript - Using Google App Script to get values from sheets and display them in text box -

so, google updated google app script api , added lots of nice features, however, in process, depreciated lots of api. have been working on library database user interface place work on college campus, , when wanted update app new api, lot of things broke, , can't figure out how make them work again. what trying value google sheets file, , put value in text box on web app. cannot work work. in addition, discovered troublesome, , is, debugger seems not correct. know, bold accusation. let me try show you. code.gs function doget(e) { var html = htmlservice.createhtmloutputfromfile('index') .setsandboxmode(htmlservice.sandboxmode.iframe); return html; } function searchbooks(searchitem, searchtype){ var si = searchitem; logger.log(si); var st = searchtype; logger.log(st); var sheets = spreadsheetapp.getactivespreadsheet().getsheets(); var ss = sheets[0]; var itemdatarange = ss.getrangebyname("iteminformation"); var selecteditem =

java - When trying to print out a constructor, I get the constructor name and a time stamp -

my name chris! improve java programming skills, i'm trying make deck class array of cards, when printing constructor deck class, constructor name , time stamp , clueless why is. can help? public static void main(string args[]) { system.out.println("custom java card game- chris l."); system.out.println(); deck deck = new deck(); deck.addcards(); system.out.println(); system.out.println(deck); } that code main program , here deck class: public deck() //deck array of cards { size = 52; cards = new card[size]; //array of cards 52 // addcards(); } public void addcards(){ for(int k = 0; k < slength; k++){ (int m = 0; m < rlength; m++){ string s = suite[k]; string n = num[m]; int r = rank[m]; string str = integer.tostring(r); // string fin = "[" + s + "," + n + "," + str + "] \r"; // system.out.print(fin); car

Random Number Generator Biased To Numbers in the Middle of Range, Java, libGDX -

i designing game in libgdx drops different sized rocks user dodge. my question: how can create method takes in low , high int value, , returns random number. however, want random number biased toward middle of range (similar normal distribution). i method this: public int randbiasint(int low, int high) { } something sort of should work... public int getbiasedint(int min, int max) { int rand = math.random() * max; while (rand < min) { rand = math.random(); } int mid = (max / 2) - (min / 2); int halfmid = mid / 2; if (rand > mid) { rand -= math.random() * halfmid; } else { rand += math.random() * halfmid; } return rand; } not prettiest, know. should acceptable desire...

elasticsearch - Elastic Search - Exact phrase search with wildcards -

i looking on exact phrase search wild card. querybuilders.multimatchquery("java se", "title", "subtitle") .type(matchquerybuilder.type.phrase_prefix); the above query, returns following results. 1) java search 2) elastic java search trailing wildcard works. but, when search below query, querybuilders.multimatchquery("ava se", "title", "subtitle") .type(matchquerybuilder.type.phrase_prefix); it not return nothing matches "ava se". expecting same result above. leading wildcard not work. there anyway achieve this? thanks, baskar.s you need use ngram analyzer or edgengram better idea. once have done , index might bit heavy affix search work fine without wild cards.

c++ - Is there a way to display my prime number list output in 2 columns? -

i taking first programming class , first time posting. have been able find on site previous projects when got stuck, , hope doing right. i have completed program below display prime number between 0 , 100 intro c++ class. the thing kinda bothers me in single column, wanted go step , make nice , display numbers in couple columns. tried using "\t", can't work right. ideas on might add code? think using array have not covered in class , i'm not supposed use them yet. the challenge was: "use isprime function wrote in programming challenge 21 in program stores list of prime numbers 1 through 100 in file." and here code: #include <iostream> #include <iomanip> #include <cstdlib> #include <string> using namespace std; bool isprime(int); int main() { static int num1=0; cout<<"listed below prime numbers 1 through 100."<<endl<<endl<<endl; { num1++; if (isprime(num1)) { cout

Android OkHttp : Why I get the same response -

when use okhttp json url : request request = new request.builder() .url(url).build(); i same response (sometimes can new response). if use this: request request = new request.builder() .cachecontrol(new cachecontrol.builder().nocache().nostore().build()) .url(url).build(); i new response everytime. i want know why same reponse first method? caching in http http typically used distributed information systems, performance can improved use of response caches. http/1.1 protocol includes number of elements intended make caching work possible. because these elements inextricable other aspects of protocol, , because interact each other, useful describe basic caching design of http separately detailed descriptions of methods, headers, response codes, etc. caching useless if did not improve performance. goal of caching in http/1.1 eliminate need send requests in many cases, , eliminate need send full responses in many other cases.

java - InputMismatchException when scanning file of integers -

when run code, inputmismatchexception (see comment). why happen? file want read contains list of integers separated spaces. below main method. public static void main (string[] args) throws exception { scanner in = new scanner(system.in); system.out.println("enter file name: "); string fname = in.nextline(); system.out.println("enter starting x coordinate: "); int x = in.nextint(); system.out.println("enter starting y coordinate: "); int y = in.nextint(); coordinate startposition = new coordinate(x, y); in.close(); watermesa wm = new watermesa(fname); scanner fs = new scanner(fname); grid_width = fs.nextint(); // exception occurs here grid_height = fs.nextint(); // , possibly here too? int = 0; (int r = 0; r < grid_width; r++) { (int c = 0; c < grid_height; c++) { = fs.nextint(); grid[r][c] = i; jpanel pan

html - Div scroll when less than min-width -

i have 2 divs, sidebar , main pane. .main { position: absolute; min-width: 400px; top: 0; bottom: 0; left: 200px; right: 0; overflow: auto; } .leftsidebar { position:absolute; top:0; bottom:0; left:0; width: 200px; padding-left: 10px; overflow-x: auto; overflow-y: scroll; } i want main div have horizontal scrollbar when size less 400px, content gets cuts off when less. missing? if helps, here demo of this. changing width of window should ideally add scrollbar main div, puts scrollbar on entire window. solution: http://jsfiddle.net/nnt7ctjr/ by giving .main min-width forced stay @ dimensions , overflow outside of viewport, scroll bar appeared entire screen. so solution mimic effect within .main . created object span.content , gave min-width:400px; . text retain 400px dimension while .main div continues shrinking.

python - Formatting Dictionary -

so working dictionary nice information, , wan print out words in nicely formatted way means of function. i have this: norwdict = { 'et hus': { 'pron': 'hus', 'def': 'house', 'pos': 'noun', 'gen': 'neuter', } 'en blomst' :{ 'pron':'blomst', 'def':'flower', 'pos': 'noun', 'gen':'masc', } i want print looks like: printword(norwdict, 'blomst') en blomst (blomst), noun flower. what things do in order format in function def printword()? i'd use str.format . see: https://docs.python.org/2/library/string.html#formatstrings as is, work this: def print_word(your_dict, your_word): # need sort of logic go 'blomst' 'en blomst' key, = {k k in your_dict.keys() if your_word i

html - Background change effect by rotation on hover via CSS3 -

Image
i web developer. client's website need put effect on hover specific div shown in website . when hover on div background should change rotating. how can this. can ease effect background change using css3 transition. there way same without using jquery ? see scrrenshot jsbin i simulate provide animation without jquery. key achieve use parent & chidl relation , understand key point when animation play. .hover{ position: relative; width: 200px; height: 200px; background-color: #1cf; } .background{ position: absolute; width: 100%; height: 100%; color: #fff; text-align: center; line-height:10; background-color: #c33; transition: 0.3s; z-index: 2; font-size: 20px; } .content{ position: absolute; width: 100%; height: 100%; background-color: #fff; text-align: center; font-size: 20px; opacity: 0; line-height: 10; transform: scale(-1,1); transition: 0.3s; } .hover:hover .background{

C++ Random number generator, isnt random but always returns the same number -

hi im looking randnum generate number between 2-10, , number being taken away 15. right now, every time program executed, number taken away 15, (perseushealth) 7. how fix this, , make random? void desertpath() { int scorpianchoice; //the option player chooses. int maxhit = 10; //max hit scorpian can int minhit = 2; //min hit scorpian can int randnum = rand()%(maxhit + minhit) + minhit; int healthremaining = perseushealth - randnum; //health left in option1. if(scorpianchoice == 1) { cout << "you run under scorpians legs in hopes escape " << endl; cout << "you hit scorpians sting " << randnum << " hp!"; cout << "you have " << healthremaining << "/15 hp left!" << endl; cout << "you escape scorpian not without taking damage" << endl; } use srand initialize. srand((unsigned)time(0)); also, think have not put brackets correct