Posts

Showing posts from April, 2015

ios - How To Connect To A Device Over IP Adress In Objective-C -

i high school student interested in theatre programming. attempting make app our theatre ipad connect our lighting console. ipad has app want bare minimum. trying make faceplate panel in app. familiar objective-c not sure how connect , control console on ip address app console manufactures does. how go doing this? example code? tutorials? thanks, thomas so bigger answer , more of general rule of thumb guide rather concrete solution. to connect device on ip, same connecting via internet, has discoverable, , have ports open. if can find both of things, better hope has api! if device has no api, shit out of luck unless want hack (which cannot do, thats how security works @ level tinkering at). so, if there api, consume it. here links apis/ rest http://www.restapitutorial.com/lessons/whatisrest.html http://en.wikipedia.org/wiki/representational_state_transfer http://www.webopedia.com/term/a/api.html if have api, use required get/post/put/patch/delete etc http c

python - django migration creates table with only one field -

i'm trying create django app named 'store' , when execute ./manage.py makemigration store ./manage.py migrate store migration applying correctly when viewing table in phpmyadmin has 1 field. my model code follows: from django.db import models class module(models.model): class meta: verbose_name = "module" verbose_name_plural = "modules" def __unicode__(self): return self.name def __str__(self): return self.name name = models.charfield(max_length=100, required=true) version = models.charfield(max_length=10,default='0.1') description = models.charfield(max_length=500,default="no description") and result of ./manage.py sqlmigrate store : begin; create table `store_module` (`id` integer auto_increment not null primary key); commit; i use django 1.7 on python 2.7 , mysql database. name = models.charfield(max_length=100, required=true) as can see fie

python - Calculating Integral of a linear function with respect to a lognormal distributed variable accurately -

Image
i iteratively calculate fixed point of following functional equation: where h know function , q lognormal distribution. let f* function solving functional equation. know f(z) /z constant. when calculating f numerically python ratio f*(z)/z monotonically increasing. quantify magnitude of error, calculate difference between last , first point of ratio. think source of problem stems numerical integration of function f : the integral on function f taken respect lognormal distribution stdv sigma , mean zero. numerically, calculate integral follows: integrand = lambda z: f(z) * phi.pdf(z) result, error = fixed_quad(integrand, int_min, int_max, n=120) the error calculate determined integration bounds int_min , int_max . initially, specify integration bounds be: int_min, int_max = np.exp( - 1 * sigma), np.exp( 1 * sigma) however, when change integration bounds cover 95% of probability mass of lognormal distribution, i.e: int_min, int_max = np.exp( - 2 * sigma), np.exp(

twitter bootstrap - Ember.js action won't play nice with data-toggle=dropdown -

i have action takes entire row of table. if user clicks on action, linked next page. have data-toggle=dropdown toggles drop down. my problem arises when try click data-toggle=dropdown , instead/before dropdown can toggle, linked next page. don't want this. want link-to action span across entire row, not conflict other buttons inside of row. <tr {{action 'actionthatlinkstonextpage' this.someid bubbles=false}}> <td> <a data-toggle="dropdown" aria-expanded="false" class="btn btn-sm pull-right btn-sm-big-glyph dropdown-toggle "> <div class="glyphicon fa-lg glyphicon-remove fa-size " data-toggle="tooltip" data-placement="top" title="disabled" role="tooltip" > </div> </a> </td> <td> </td> </tr> the problem when you're clicking dropdown toggle, event propagating d

Android - ListView images shuffled when scrolling -

i'm trying make listview dynamically loaded images, using asynctask download image , set listview. problem that, while scrolling down, images randomly changed. public class getallcustomerlistviewadapter extends baseadapter { private jsonarray dataarray; private activity activity; private static layoutinflater inflater = null; private static final string baseurlforimage = "http://192.168.254.1/contact/images/"; public getallcustomerlistviewadapter(jsonarray jsonarray, activity a) { this.dataarray = jsonarray; this.activity = a; inflater = (layoutinflater) this.activity.getsystemservice(context.layout_inflater_service); } @override public int getcount() { return this.dataarray.length(); } @override public object getitem(int position) { return position; } @override public long getitemid(int position) { return position; } @override public view getview(int position, view convertview, viewgroup parent) { // set convert view if null

android - Failed because: Invalid action error in Cordova app -

i encountering following error message when capturing photo using camera plugin cordova: "failed because: invalid action" i have tried debugging error not sure causing , running out of ideas! the tablet device testing on running android 4.4.4 (nexus 7). the strange thing not error when choosing photo gallery, when using device camera. gut feeling in recent update has changed. here code using camera functionality: /** * take picture camera */ capturephoto: function() { navigator.camera.getpicture(phonegap.onphotodatasuccess, phonegap.onfail, { quality: 50, targetwidth: parsefloat($(window).outerwidth() * 1.25), targetheight: parsefloat($(window).outerheight() * 1.25), savetophotoalbum: true, correctorientation: true, allowedit: true, sourcetype: camera.picturesourcetype.camera, encodingtype: camera.encodingtype.jpeg, destinationtype:

jsf 2.2 - JSF 2.2 Controller Validation - Doesn't seem to fire -

hi have contrived controller: @model @fieldmatch(first = "username", second = "usernameagain", message = "the email fields must match") public class hellocontroller implements serializable { private static final long serialversionuid = -8187960089787583270l; private string username; private string usernameagain; private static final logger log = loggerfactory.getlogger(hellocontroller.class.getname()); // final static validatorfactory factory = validation.builddefaultvalidatorfactory(); // private static validator validator = factory.getvalidator(); public string login() { // final set<constraintviolation<hellocontroller>> violations = validator.validate(this); // log.info(violations.tostring()); final boolean valid = isvalid(); log.info("{valid: " + valid + "},{username: " + username + "}, {usernameagain: " + usernameagain + "}");

code formatting - Roslyn - replace node and fix the whitespaces -

in program use roslyn , need replace node new node. example, if have code like public void foo() { for(var = 0; < 5; i++) console.writeline(""); } and want insert brackes for statement, get public void foo() { for(var = 0; < 5; i++) { console.writeline(""); } } i tried use normalizewhitespace, if use on statement, get public void foo() { for(var = 0; < 5; i++) { console.writeline(""); } } however, i'd have statement formatted correctly. hints how it? edit: solved using: var blocksyntax = syntaxfactory.block( syntaxfactory.token(syntaxkind.openbracetoken).withleadingtrivia(forstatementsyntax.getleadingtrivia()).withtrailingtrivia(forstatementsyntax.gettrailingtrivia()), syntaxnodes, syntaxfactory.token(syntaxkind.closebracetoken).withleadingtrivia(forstatementsyntax.getleadingtrivia()).withtrailingtrivia(forstatementsyntax.gettrailingtrivia()) ); however, answer sam

java - How can I check the mouse's position over a 2D array of images for a game? -

okay creating candy crush game replica in java. problem lies in trying create event listener clicking or hovering on objects. have tried different methods using imageicons , using event listeners using jlabels , using icons , trying determine if jlabel clicked. what trying use rectangles , hitboxes so: public rectangle mousehitbox(mouseevent e) { int x = (int)e.getlocationonscreen().getx(); //grab mouse x coordinate , set int int y = (int)e.getlocationonscreen().gety(); //grab mouse y coordinate , set int mouse.setbounds(x,y,1,1); //create mouse hitbox return mouse; //return mouse event } public rectangle gemhitbox() { (int = 0; < 8; i++) { (int j = 0; j < 8; j++) //for loops access 81 gem images { int x = gemimage[i][j].getx(); // x coordinate of specific array destination int y = gemimage[i][j].gety(); // y coordinate of specific array destination gem.setbounds(x,y,50,47); // gem hitbox

javascript - Three.js - How do I use the BoxHelper on an Object3D with children? -

i'd use three.boxhelper create bounding box object3d has children. motivation can render wireframe bounding box object, without diagonals on box's faces. looking @ source code boxhelper, looks doesn't take object's children account, problem app, since every object has children. is there way boxhelper include object's children? alternatively, there way use boundingboxhelper (which include children), , render without diagonals? if want create three.boxhelper object has children, can use pattern: // box helper boxhelper = new three.boxhelper( parent ); boxhelper.material.color.set( 0xffffff ); scene.add( boxhelper ); in render loop, may have this: boxhelper.update(); three.js r.85

Hbase can't get master address from zookeeper - even though zkcli shows hbase directories -

we have been repeatedly running issues zookeeper , hbase interworking. typical error is: hbase(main):001:0> list table error: can't master address zookeeper; znode data == null we have checked nodes exist in zookeeper using hbase zkcli ls command: [zk: localhost.localdomain:2181(connected) 1] ls /hbase [meta-region-server, backup-masters, table, draining, region-in-transition, table-lock, running, namespace, hbaseid, online-snapshot, replication, splitwal, recovering-regions, rs] in particular let @ /hbase/hbaseid: [zk: localhost.localdomain:2181(connected) 5] ls /hbase/hbaseid [] czxid = 0x89 ctime = mon may 12 01:42:49 pdt 2014 mzxid = 0x11dc mtime = tue jul 01 17:51:13 pdt 2014 pzxid = 0x89 cversion = 0 dataversion = 5 aclversion = 0 ephemeralowner = 0x0 datalength = 67 numchildren = 0 from limited understanding of zookeeper/hbase interaction se

python - Creating a Rectangle class -

i don't understand classes , great. rectangle class should have following private data attributes: __length __width the rectangle class should have __init__ method creates these attributes , initializes them 1. should have following methods: set_length – method assigns value __length field set_width – method assigns value __width field get_length – method returns value of __length field get_width – method returns value of __width field get_area – method returns area of rectangle __str__ – method returns object’s state class rectangle: def __init__(self): self.set_length = 1 self.set_width = 1 self.get_length = 1 self.get_width = 1 self.get_area = 1 def get_area(self): self.get_area = self.get_width * self.get_length return self.get_area def main(): my_rect = rectangle() my_rect.set_length(4) my_rect.set_width(2) print('the length is',my_rect.get_length()) print('the width is

javascript - Hiding overflow on HTML tag makes browser jump to top of the page -

when set style on html tag, in angularjs: angular.element($document[0].documentelement).css('overflow', 'hidden'); the page jumps top of page. how can prevent this? i trying display full page overlay, , when try scroll, background scrolls. doesn't scroll when set overflow: css style on html tag. has lead me problem. when hide document, you're telling browser not scroll. that's why you're being directed top of page, page in essence no longer extends beyond viewport. while not every browser send top of page (expected behavior here lock user page they're at), active tracking of hash (e.g. mypage.com/#showlogin/) angular uses routing cause page jump top of screen. edit: if want keep background doesn't scroll page, use property background-attachment : html, body { ... /* other code here */ background-attachment: fixed; }

java - RCP: How to sync state of MMenuItem and MToolItem -

i have handler linked both menu item , toolbar icon. if menu item selected, checkmark appear left of menu item. if toolbar button pressed in icon changes 'sunken' it's pushed in. if menu item checkmarked 'auto-push' toolbar button in (without firing toolbar button-pressed event). if button pressed in menu item 'auto-checkmark' is there way this? assume start here..; @execute public void execute( @named(iserviceconstants.active_shell) shell shell, @optional mtoolitem toolitem, @optional mmenuitem menuitem) { // menu triggered coming method if (menuitem != null ) { if(menuitem.isselected()){ ... } } // button triggered coming method if (toolitem != null ) { if(toolitem.isselected()){ ... } } } you need both mtoolitem , mmenuitem before first execution. can find mtoolitem via emodelservice in @postconstruct method. private mmenuitem menuitem; private mtoolitem toolitem; @postconst

javascript - Display paragraph text instead of [object Object] -

i making overlay pop when image clicked. overlay should have picture , paragraph in it. comes up, displays picture, not display paragraph has been hidden actual page css "display: none;" feature , shown again jquery after overlay comes up. instead, displays "[object object] paragraph should be. need show actual text of paragraph instead of registering there there... i have looked through jquery documentation , seems me closest looking for. before, getting nothing paragraph should be. however, have worked 3 hours on , stumped. have advice? html <div class="inscaritem target"> <a href="../insnat.jpg"> <img src="../insnat.jpg" alt="barrows carries nationwide insurance" /> </a> <p class="testertesty hide4target"> test!!! has passed! </p> </div> css #overlay { background: rgba(0,0,0,.9); width: 100%; height: 100%; position: fixed;

java - Does classloaders and class objects start in Young generation? -

here documentation using reference. know class information stored in perm gen space. perm gen space populated objects survive eden , tenured generations. correct conclude class objects start eden generation? please assume hotspot jvm discussion. not sure if answer depends on version. if does, love know well. the term permanent generation misleading. no object ever promoted out of or permanent generation. permanent generation treated different young , tenured generations objects can promote former latter. object starting in eden therefore never allocated permanent generation. thus, answer no. however, note java 8 on, permanent generation resolved , data stored in so-called meta space.

c++ - Pep/8 Assembly - Switch statement inside of loop -

i trying convert following c++ code pep/8 assembly doesn't seem work, , not know whether it's because of addressing modes or if there's larger problem. here example utilizes switch statement, not inside of loop - codepad link . believe having trouble making value in letter,s compared case value. book not touch on switches it's trial , error @ point. c++ int main() { char letter; int counta = 0, countb = 0, countc = 0; cin >> letter; { switch (letter) { case 'a' : counta++; break; case 'b' : countb++; break; case 'c' : countc++; break; } cin >> letter; } while (letter != 'x'); cout << "number of a's " << counta << endl << "number of b's " << countb << endl << "number of c's " << countc << endl; return 0; } pep/8

java - Inifinte Recursive loop I can't Solve? -

i developing program recursively generates frequencies of tones in scale. each frequency twelfth root of 2 higher previous one. program must use recursion (ugh, education). when use method, initial tone repeated on , on , on again. why that? public static void scale(double x, double z){ double y; if(z == x){ y = z * math.pow(2, (1/12)); system.out.println(y); scale (y, y); } else if(z >= (2 * x) - 1 || z <= (2 * x) + 1){ y = z; system.out.println(); } else{ y = z * math.pow(2, (1/12)); scale (y, y); } system.out.println(y); } why that? because of java's integer division. specifically, 1/12 becomes 0 , not 0.083333333 , because int must yielded. 2 raised power 0 1 , y same z . use double literals force floating-point division. 1.0/12.0

php - MySQL check if rows exists and delete it in the same query -

i following in 1 query, wandering if possible: $rowsq = $mysql->query("select * `table` (a='a' , b='b')"); if($rowsq->num_rows){ $mysql->query("delete `table` (a='a' , b='b')"); } i have seen similar thing exists query different table so: $mysql->query("delete `table` exists (select * `table2` table.id = table2.id)"); is possible on same table though , if have rewrite same conditions or there shorter way? you can use delete , in case row doesn't exists specified values, query return out doing thing. can avoid select delete table ='a' , b='b'

benchmarking - Hadoop 2.6.0 TestDFSIO benchmark -

so have set hadoop 2.6.0 cluster , want run benchmark test read write throughput. keep reading places can use testdfsio this, not able find way run program on hadoop version 2.6.0. know how run test, or alternative? hibench has implementation of dfsio. can find hibench clicking here .

multithreading - Why is my code slower using multiple threads in Java? -

so have program runs bunch of different calculations returns result when calculations done. originally code synchronous following: public class myapplication{ public static void main(string[] args) { docalculation(1); docalculation(2); docalculation(3); docalculation(4); docalculation(5); docalculation(6); docalculation(7); docalculation(8); /* print result */ } } i thought more efficient run these calculations in new threads have like, public class myapplication{ public static void main(string[] args) { list<thread> threads = new arraylist<thread>(); threads.add(docalculation(1)); threads.add(docalculation(2)); threads.add(docalculation(3)); threads.add(docalculation(4)); threads.add(docalculation(5)); threads.add(docalculation(6)); threads.add(docalculation(7)); threads.add(docalculation(8)); for

c++ - ON_NOTIFY not working in my dialog when I have ON_NOTIFY_REFLECT defined by the control -

in ctreectrl derived class, acting on tvn_itemexpanded: on_notify_reflect(tvn_itemexpanded, &ontvnitemexpanded) in control's parent dialog, want act upon same notification, tvn_itemexpanded, on_notify(tvn_itemexpanded, idc_element_tree, &ontvnitemexpanded) however, control class's ontvnitemexpanded method getting called, never dialog's. using both breakpoints , seeing desired behavior (or lack of desired behavior) in both methods verify control class's method being called, not dialog's method. but, if comment out on_notify_reflect ctreectrl-derived begin_message_map , dialog's method gets called!?! why can't notification go both control , dialog?!? on_notify_reflect overrides on_notify , can use on_notify_reflect_ex instead lets callback decide if message should go through parent or not. see message reflection windows controls more detailed explanation: if, in parent window class, supply handler specific wm_noti

python - Statsmodels version 0.6.1 does not include tsa? -

i'm trying hp-filter working using statsmodels (sm). the documentation here implies module sm.tsa exists 0.6.1 , following error: >>> import statsmodels sm >>> sm.__version__ '0.6.1' >>> sm.tsa.filters.hp_filter.hpfilter() traceback (most recent call last): file "<input>", line 1, in <module> attributeerror: 'module' object has no attribute 'tsa' >>> sm.tsa traceback (most recent call last): file "<input>", line 1, in <module> attributeerror: 'module' object has no attribute 'tsa' here's pip output: nat-oitwireless-inside-vapornet100-a-14423:prog2 foobar$ pip show statsmodels --- name: statsmodels version: 0.6.1 location: /usr/local/lib/python2.7/site-packages/statsmodels-0.6.1-py2.7-macosx-10.9-x86_64.egg requires: you need import statsmodels.api sm

Django: How to set a field's default value to the value of a field in a parent model -

say have following model class sammich(models.model): name = models.charfield(max_length=200) ratio_of_cheese_to_meat = models.floatfield(default=0.3) i'd able create new model has field pulls default ratio_of_cheese_to_meat of sammich class class delisammich(models.model): sammich = models.foriegnkey(sammich) type_of_meat = models.charfield(max_length=200) type_of_cheese = models.charfield(max_length=200) ratio_of_cheese_to_meat = models.floatfield(default=sammich.objects.get(pk=sammich.id).ratio_of_cheese_to_meat) which isn't working. one option override model's save() method , default: class delisammich(models.model): sammich = models.foreignkey(sammich) type_of_meat = models.charfield(max_length=200) type_of_cheese = models.charfield(max_length=200) ratio_of_cheese_to_meat = models.floatfield() def save(self, *args, **kwargs): if not self.ratio_of_cheese_to_meat: self.ratio_of_che

starting to make games for android -

i want start making games android. have experience android apps, , have made few cool apps. want start making games. can me because couldn't find tutorials, or @ least didn't good. need give me advice, links, tutorials, etc... don't give me basic, 2d games , things that. ok, it's beginning, in order avoid posting again similar question , spamming, please give me advanced game tutorials , advice. think , tell me help. in advance! since have experience android apps, recommend first make more of "easy" ones can become better @ easy ones, since once know how easy ones well, learn hard stuff better. assuming going use no code, easy drag , drop, can use gamesalad.com. if going use java making android games, should use https://www.udemy.com/android-tutorial/ it. website excellent tutorials , lots of information. preferred language of choice of course python, since python easiest making games. python, use https://play.google.com/store/apps/details?id=com

GNU-make check if element exists in list/array -

i have list defined in make file , user supposed set environment variable need find in list. there way using gnu make this? want outside recipe, before make starts building targets. qa check make sure user sets env. variable value within range/list. on terminal: setenv env_param x in makefile: params := b c if ${env_param} exists in $(params) true else false endif @madscientist's answer works. there way wrap if block foreach loop test multiple parameters? keys := params factors params := b c factors := x y z foreach v in ($(keys)) { ifneq ($(filter $(env_$(v)),$(v)),) $(info $(env_$(v)) exists in $(v)) else $(info $(env_$(v)) not exist in $(v)) endif } you can use filter function this: params := b c ifneq ($(filter $(env_param),$(params)),) $(info $(env_param) exists in $(params)) else $(info $(env_param) not exist in $(params)) endif read: "if result of searching env_param value in params not empty, run 'true&

java - admob is not show in my SDL game -

i have wrote sdl game , ported andorid and tried integrate admob failed androidmanifest <?xml version="1.0" encoding="utf-8"?> <!-- replace org.libsdl.app identifier of game below, e.g. com.gamemaker.game --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.libsdl.zomibeshooter" android:versioncode="1" android:versionname="1.0" android:installlocation="auto"> <!-- create java class extending sdlactivity , place in directory under src matching package, e.g. src/com/gamemaker/game/mygame.java replace "sdlactivity" name of class (e.g. "mygame") in xml below. example java class can found in readme-android.txt --> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_network_state"/> <ap

java - What's the best way to reduce latency on downstream in netty? -

i'm using netty 5.0 , find out when downstream action initiated non-io thread, takes few hundreds microseconds io thread take task. below measurement code. measure time in 2 places, 1 in non-io thread , 1 in io thread (actually, in encoder outbound handler). in non-io thread, latency around 200 ~ 300 microseconds while in io thread, latency 50 ~ 100 nano seconds. there anyway reduce latency of context switching sub microseconds? channelfuture f = b.bind(); ... channelpromise cp = f.channel().newpromise(); long currentnano = system.nanotime(); cp.addlistener(() -> (system.out.println(system.nanotime() - currentnano)); cp.channel().writeandflush(obj); i'm using disruptor pattern in other parts of codes , can object passing between threads below microsecond, want same in netty.

c# - Enlarge video using WPF MediaElement -

hi trying expand mediaelement watch larger videos, problem can not in way, manually in designer , not work, try manually min-height , min-width property video remains same size. by "expand" mean want video fill mediaelement . right small. source : <window x:class="wpfapplication1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="1028" width="525"> <grid> <mediaelement height="512" horizontalalignment="left" margin="12,12,0,0" name="player" verticalalignment="top" width="479" minheight="800" /> <button content="button" height="23" horizontalalignment="left" margin="157,566,0,0" name="button1" verticalalignment="to

java - How to insert text read strings into specific variables -

i having issues inserting each line of simple textfile specific variable want go to. example text file ordered (no spaces in text file between strings editor put them together) dallas 78 f north, 15 mph dallasimage denver 29 f south, 10 mph denverimage and want dallas in city variable, 78f in temperature variable, , on until text ends, @ moment goes city variable, prints there! know scanner has next line never used before got stuck here. import java.io.bufferedreader; import java.io.file; import java.io.filereader; import java.io.ioexception; public class textreader { public static void main(string[] args) { try { string city ="a"; string temp ="b"; string wind ="c"; string image = "d"; file file = new file("load.txt"); filereader filereader = new f

C picture rotation optimization -

this c experts out there.. the first function takes two-dimensional matrix src[dim][dim] representing pixels of image, , rotates 90 degrees destination matrix dst[dim][dim]. second function takes same src[dim][dim] , smoothens image replacing every pixel value average of pixels around (in maximum of 3 × 3 window centered @ pixel). i need optimize program in account time , cycles, how else able optimize following?: void rotate(int dim, pixel *src, pixel *dst,) { int i, j, nj; nj = 0; /* below main computations implementation of rotate. */ (j = 0; j < dim; j++) { nj = dim-1-j; /* code motion moved operation outside inner loop */ (i = 0; < dim; i++) { dst[ridx(nj, i, dim)] = src[ridx(i, j, dim)]; } } } /* struct used compute averaged pixel value */ typedef struct { int red; int green; int blue; int num; } pixel_sum; /* compute min , max of 2 integers, respectively */ static int min

r - correlation loop keep getting NA -

despite using 2 complete columns every element numeric , no numbers missing rows 2 thru 570, find impossible result other na when using loop find rolling 24-week correlation between 2 columns. rolling.correlation <- null temp <- null for(i in 2:547){ temp <- cor(training.set$return.spy[i:i+23],training.set$return.tlt[i:i+23]) rolling.correlation <- c(rolling.correlation, temp) } #end "for" loop rolling.correlation the cor()command works fine [2:25], [i:25], or [2:i] r doesn't understand when [i:i+23] i want r calculate correlation rows 2 thru 25, 3 thru 26, ..., 547 thru 570. result should vector of length 546 has numeric values each correlation. instead i'm getting vector of 546 nas. how can fix this? help. look happens when 5:5+2 # [1] 7 note : has higher operator precedence + means 5:5+2 same (5:5)+2 when want 5:(5+2) . use i:(i+23)

java - Use Float as Int (without conversion) in Scala -

i'm trying implement fast inverse square root algorithm in scala. algorithm involves exploiting binary representation of 32-bit floating-point number applying bitwise , integer operations binary representation, though int. in other words, must create int out of binary representation of float, not use cast operator. i remember doing similar while in java, , believe done using static method of integer. i'm new scala, though, , can't seem find such method. how 1 in scala?

html - Styling issue (using floats) -

i wonder why paragraph tag content fill in between 2 floated divs? want paragraph tagged content underneath header. also, why don't line returns show in paragraph tag? here's js fiddle: http://jsfiddle.net/yf3nyfk1/ html: <body> <div id="header-container"> <div id="header-wrap"> <div class="left logo logoimg"> <img src="http://i.imgur.com/dtmbhkq.png"/> </div> <ul class="nav"> <li class="contact">contact</li> <li class="about">about</li> <li class="portfolio">portfolio</li> </ul> </div> </div> <div> <p> lorem ipsum... </p> </div> </body> css: body { background: #000000; margin: 0; font-family: helvetica, arial, sans-serif; font-size: 12px; color: #ffffff; text-align: center

Handling unsuccesful websocket upgrade requests in Javascript Client -

i want have javascript client process http status code server returning when client makes websocket upgrade request , request unsuccessful. i have server returning http 400 indicate websocket upgrade unsuccessful. i using google chrome , when open developer console can see following message: websocket connection 'wss://' failed: error during websocket handshake: unexpected response code: 400 however, onerror handler not contain message, receives 1006 error not indicate closure occured result of getting http 400. how javascript developer handle handshake errors? provide client informative message when handshake error. i have put websocket error below, not seem contain can use indicate error result of websocket handshake error. websocket error: {"path":{"length":0},"cancelbubble":false,"returnvalue":true,"srcelement":{"binarytype":"blob","protocol":"","extensions&qu

ios - UIScrollView with UICollectionView Child -

i have scrollview , , inside scrollview contains collectionview . with 1 single swipe, scroll outer scrollview until inner scrollview comes in frame , stop outer scroll , scroll inner (all in 1 swipe). want pass scrolling outer inner on-the-fly. i able achieve effect must remove finger, , press finger down again , scroll other view: - (void)scrollviewdidscroll:(uiscrollview *)scrollview { //general scroll info cgfloat scrolloffset = scrollview.contentoffset.y; //if scrollview reaches top pass touch collection view //however must remove finger , press again in order scroll collectionview if (scrollview == _scrollview && scrolloffset >= 120){ [_scrollview setscrollenabled:no]; [_scrollview setbounces:no]; [_collectionview setscrollenabled:yes]; [_collectionview setbounces:yes]; [self.scrollview setcontentoffset:cgpointmake(0, 120) animated:yes]; }else if (scrollview != _scrollview && scrolloffset < 0){ [_scrollview setscrollen

javascript - Jquery selects too many elements on mouseclick -

i want id of element click. should give me id if has one. i have code alert me element id: $("[id]").click(function(event) { event.preventdefault(); var id_name = $(this).attr("id"); alert(id_name); }); but want foremost element's id. i have button inside div, both id-attribute. if click button, want id of button. however, script alerts me of both buttons id , div's id. why that/how can foremost element's id? thats because when click button, clicking parent element. add within function event.stoppropagation(); http://api.jquery.com/event.stoppropagation/

css - 100% height OR 100% width -

how make image fills tile set size no matter , keep aspect ratio? instance, if image wide enough expands tall enough overflow hidden , vice versa. have far if image needs adjust 100% height doesn't expand width beyond box , leaves image distorted. .box{ width: 100px; height: 100px; overflow: hidden; } .image{ min-width: 100%; min-height: 100%; } <div class="box"> <img class="image" src="/img.jpg"> </div> another alternative css way utilize cover background: url(images/bg.jpg) no-repeat center center fixed; background-size: cover; see source details: https://css-tricks.com/almanac/properties/b/background-size/

How to work with meteor and laravel in an appl? -

i tried build real-time web app. the major app functionality based on meteor.js.(node.js mongodb) but want let user management, billing system(stripe), static pages based on laravel(php + mysql). they share same user system, authentication. part of whole app. but have no idea how combine both, database schema. there seem little written architectures this. both meteor , laravel still relatively new. i'm thinking of same combination following architecture. aware of fact i'm trying combine pizza steak (which might prove tasty). what kind of app having architecture? first strengths , weaknesses (real short). meteor fast , provides excellent communication layer between client , server. lacks matured data layer. nosql db's (like: mongo) lack example proper support migrations , not documented mysql. although think there might bright future nosql, it's not choice reliable applications 'yet'. though did see mysql layers meteor, not closely larav

objective c - Automatic frameworks linking doesn't work -

Image
today learned @import statement can link frameworks automatically. okay, created project, added webview . throwing me error webview undefined. okay, wrote @import webkit — , error gone , webview methods available me. ...i ran application , crashed with *** terminating app due uncaught exception 'nsinvalidunarchiveoperationexception', reason: '*** -[nskeyedunarchiver decodeobjectforkey:]: cannot decode object of class (webview)' then i've added webkit.framework manually and... worked. what's point of @import statement? automatic linking turned on... import imports headers . thus, name webview becomes defined, along methods , other stuff in webkit, , code can compile . linking links code - code in webview lives , breathes , has being - , code can run . normally, if import framework using @import , both things happen. can compile code because of import, , can run code in framework because import performs automatic linking. but ins

sorting - java - compareTo method -

i have question compareto method in java. compareto method compares carowner objects , if calling object earlier in chronological time in comparison argument returns -1, if calling object later in chronological time in comparison argument returns 1, if calling object , argument same in chronological time returns 0. if argument passed in not carowner object (use instanceof or getclass determine this) or null, returns -1. and came code, doesnt seem working, have suggestion? public int compareto(object o) { if ((o != null ) && (o instanceof carowner)) { carowner otherowner = (carowner) o; if (otherowner.compareto(getyear()) > 0) return -1; else if (otherowner.compareto(getyear()) < 0) return 1; else if (otherowner.equals(getyear())) if (otherowner.compareto(getmonth()) > 0) return -1; else if (otherowner.compareto(getmonth()) < 0) return 1;

Can we make payment with "Do direct method" Paypal using Card number, Amount and expiry date only in PHP -

i have implemented paypal do direct method in site. working fine. but possible can payments following parameters: a) amount, b) card number, c) expiry date please suggest.. it depends on how account vetted when got approved pro. in cases, you'll have access fraud management filters in paypal profile. if adjust avs , cvv2 not require match can process card amount, name on card, card number, , expiration date. the dodirectpayment api require send billing address, can send bogus values params in cases don't have it. avs come mis-match, again, filters setup accept you'd go.

javascript - onblur functionality for TR -

what can simulate or use onblur functionality tr. here's jsfiddle http://jsfiddle.net/davomarti/4l859p5t/2/ <table> <tr id="view_1" onclick="showeditrow( '1' )"`enter code here`> <td>val1_1</td> <td>val1_2</td> <td>val1_3</td> </tr> <tr id="edit_1" style="display:none" onblur="showviewrow( '1' )"> <td><input type="text" value="val1_1"/></td> <td><input type="text" value="val1_2"/></td> <td><input type="text" value="val1_3"/></td> </tr> <tr id="view_2" onclick="showeditrow( '2' )"> <td>val2_1</td> <td>val2_2</td> <td>val2_3</td> </tr> <tr id="edit_2" style="display:none" onblur="sho

php - Get the height of a image no matter what mime type -

i not need resize image, trying accomplish gathering actual height of $img browser interpret it. allow user upload image reason images won't return dimensions, getimagesize(); $img = $_get['img']; unction remoteimage($url){ $ch = curl_init ($url); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_binarytransfer,1); curl_setopt($ch, curlopt_range, "0-10240"); $fn = $img; $raw = curl_exec($ch); $result = array(); if(file_exists($fn)){ unlink($fn); } if ($raw !== false) { $status = curl_getinfo($ch, curlinfo_http_code); if ($status == 200 || $status == 206) { $result["w"] = 0; $result["h"] = 0; $fp = fopen($fn, 'x'); fwrite($fp, $raw); fclose($fp); $size = getimagesize($fn); if ($size===false) { // cannot file size information } else { // return width , height li

objective c - touchesBegan not called after dismissing UIAlertView in Cocos2d v3 -

after showing , dismissing uialertview in ccscene touchbegan stops responding. ccbutton still respond touches , if tap ccbutton after dismissing uialertview touchbegan starts working again. here touchbegan doesn't register touches after alert until press ccbutton -(void) touchbegan:(uitouch *)touch withevent:(uievent *)event { cgpoint touchloc = [touch locationinnode:self]; nslog(@"touchbegan"); } create uialertview - (void)showalert { uialertview *alert = [[uialertview alloc] initwithtitle:@"name" message:@"enter name" delegate:self cancelbuttontitle:@"done" otherbuttontitles:nil]; [alert settag:1]; alert.alertviewstyle = uialertviewstyleplaintextinput; [alert show]; } alert dismissed - (void)alertview:(uialertview *)alertview diddismisswithbuttonindex (nsinteger)buttonindex { if (alertview.tag == 1) { uitextfield *textfield = [alertview textfieldatindex:0]; player.name =

javascript - Argument 'MasterController' is not a function, got undefined -

i'm trying 1 of pages in app display data, keep getting "argument 'mastercontroller' not function, got undefined." strange thing isolated code out of files , runs itself, moment put back, doesn't work anymore. i want app load transactions data when "old baskets" menu item clicked. appreciated. it's driving me insane!!! this html: <!doctype html> <html lang="en" ng-app="app"> <head> <meta charset="utf-8"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes"> <title>laundri</title> <link rel="stylesheet" href="lib/onsen/css/onsenui.css"> <link rel="stylesheet" href="styles/onsen-css-components-blue-basic-theme.css"> <link rel="stylesheet" href="styles/app.css"/> <scr