Posts

Showing posts from April, 2010

How to include typescript openlayers 3 external module? -

i want try setting simple map in openlayers using typescript: https://github.com/borisyankov/definitelytyped/blob/master/openlayers/openlayers.d.ts i take file, put /typings/openlayers/openlayers.d.ts i have app.ts file @ top in root directory put: import { map } "olx"; in tsconfig.json, i've included path openlayers.d.ts file. gettting olx not defined when use tsc command npm's typescript package. all going drawing simple openlayers3 map, hope not deviate javascript if possible. first install openlayers: npm install openlayers then install types openlayers dev env: npm install --save-dev @types/openlayers to import tried: import * ol 'openlayers'; then can invoke in openlayers this: new ol.map();

android - Recycleview in coordinatorlayout -

i trying create relativelayout has coordinatorlayout , linearlayout @ bottom , found strange behavior can't resolve. layout <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.coordinatorlayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/sender" android:background="@android:color/white" android:fitssystemwindows="true"> <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent"

javascript - How to pass the chosen dropdown value to ng-repeat orderby -

i have created normal dropdown box.in need pass selected value ng-repeat orderby filtration. this dropdown <select name='filter_range' id='filter_range' onchange='filter()'> <option value='mrplow'> mrp low high</option> <option value='mrphigh'> mrp high low </option> <option value='qtyhigh'> qty low high </option> <option value='qtylow'> qty high low </option> </select> angular js <div ng-app="myapp" ng-controller="mycontroller"> <div ng-repeat = "grp_val in sample | orderby:'mrplow'" <label>{{grp_val.product}}</label><br> </div> </div> now how can pass selected value ng-repeat orderby:' '? i example same problem here: angular.module('orderbyexample', []) .controller('examplecontroller', ['

jquery - How to get html() from element excluding another element? -

sorry real stupid question. not work either way. <html> <head> <script src='js/jquery.js' type='text/javascript'></script> <script type='text/javascript'> $(document).ready(function() { var htmlcontent = $('.content').not('.dontgrab').html(); alert(htmlcontent); // returns }); </script> </head> <body> <div class='content'> before <div class='dontgrab'>don't grab</div> after </div> </body> </html> tried $(".content *:not('.dontgrab')").html(); // returns null please help. thanks. this should it: var clone = $('div.content').clone(); clone.find('.dontgrab').remove(); var html = clone.html();

ios - TwitterKit didEncounterError (withMessage Invalid parameter not satisfying- error) -

i've seen question asked once before on stackoverflow there not satisfactory answer i'm asking once more. [[twitter sharedinstance] loginwithcompletion:^(twtrsession *session, nserror *error) { if (session) { setting.isconnecttwitter = yes; } else { setting.isconnecttwitter = no; nslog(@"error: %@", [error localizeddescription]); } }]; when run , try logging in through twitter, seems work, after few seconds, error "twitterkit didencountererror (withmessage invalid parameter not satisfying- error)" appears. i followed twitter login tutorial quite literally , i'm frustrated error. appreciated!

Change keys value in foreach PHP -

it possible change "keys" values in foreach php? example have database this: http://i.imgur.com/fjawqgx.png and want data, , display in: foreach ($array $key => $value) { ... } how can change "keys" if don't want display, example "u_group" "group"? ps. sorry bad english ^ ^" create language array, keys $key , value proper text. e.g: $langs = ['u_group' => 'group', 'u_other' => 'other']; foreach ($array $key => $value) { echo 'user ' . $langs[$key] . ': ' . $value; }

javascript - Calculating the highest element in a list and applying this value to all on resize (jQuery) -

i wrote function calculate height value of highest element in list , apply value elements in list. works, not on windows resize. how force function running on resize? here code: var heightequalizing = function () { var element = $('.tm-whatwedo li'); var elementheights = element.map(function () { return $(this).height(); }).get(); var maxheight = math.max.apply(null, elementheights); element.height(maxheight); console.log(maxheight); }; $(window).resize(heightequalizing); $(document).ready(heightequalizing); $(window).on('resize', function(){ heightequalizing(); }); update: maybe misunderstand? in fiddle window resize event fires function: http://jsfiddle.net/jessikwa/r1obmfh2/

java - ExpandableListView only showing one parent -

among other view s, trying programmatically add expandablelistview linearlayout . this, using simpleexpandablelistadapter . there supposed ten parent elements, each single child element. encased in onpostexecute of asynctask , if matters. here java: arraylist<hashmap<string,string>> parentlist = new arraylist<>(); arraylist<arraylist<hashmap<string,string>>> childlist = new arraylist<>(); (int k = 0 ; k < 10 ; k++) { hashmap<string,string> parentmap = new hashmap<>(); parentmap.put("item", + ":" + k + "source"); parentlist.add(parentmap); arraylist<hashmap<string,string>> childitemlist = new arraylist<>(); hashmap<string,string> childmap = new hashmap<>(); childmap.put("item", + ":" + k + "data"); childitemlist.add(childmap); childlist.add(childitemlist); } /* build expandable list */ simpleexpandabl

c++ - On what days does the thirteenth occur? USACO -

is friday 13th unusual event? that is, 13th of month land on friday less on other >day of week? answer question, write program compute frequency 13th of each month lands on sunday, monday, tuesday, >wednesday, thursday, friday, , saturday on given period of n years. >time period test january 1, 1900 december 31, 1900+n-1 >given number of years, n. n positive , not exceed 400. here's have: #include <iostream> #include <fstream> #include <string> #include <vector> using namespace std; int main(){ ifstream fin("fridayin.txt"); ofstream fout("fridayout.txt"); int n; fin >> n; int current_year, end_year = 1900 + n - 1, current_day = 1; //set current_year, end_year, , current_day 1(monday) int daycounter[7] = { 0 }; //this record how many times day occurs on 13th int current_month = 1; int day; (current_month = 1; current_month <= 12; current_month++){ (curr

python - Internal Server Error with Nginx and uWSGI -

i'm trying host app using nginx on linode.com i'm stuck on uwsgi config. i've used "getting started" guide , "wsgi using uwsgi , nginx on ubuntu 12.04 (precise pangolin)" guide , i've succesfully deployed nginx (got nginx welcome message in browser). although above tutorial ubuntu 12.04 i've used 14.04. the problem starts when got uwsgi configuration , 'hello world' python app. going location / in browser returns failed load resource: server responded status of 500 (internal server error) , nothing gets logged in server error.log. location /static works though , serves files without hitch. i've tried many things , looked extensively fix on google , stackoverflow nothing, , i'm kind of frustrated right now. thank help. here config files (i've hidden domain , ip): /etc/hosts 127.0.0.1 localhost 127.0.1.1 ubuntu xx.xx.xx.xxx mars # following lines desirable ipv6 capable hosts ::1 localhost ip6-lo

git - How to prevent losing .gitignore when checking-out older branches? -

if in master , stuff want safe git ignored, then: git checkout <oldbranch or commit> but old branch doesn't have ignored files arrgh! untracked files added etc , vulnerable reset --hard etc. is there more elegant fix here other than: git checkout master .gitignore #maybe write hook every checkout of <oldbranch or commit>? or manage copying .gitignore .git/info/exclude ? adding rules in .git/info/exclude 1 way, remains local workaround: won't pushed .gitignore file would. the best option remains create .gitignore in checked out branch: git checkout abranchwithoutgitignore git checkout master -- .gitignore git add .gitignore git commit -m "add .gitignore master" then cherry-pick commit other branches.

undefined method 'each' Ruby on Rails -

apologies in advance, newbie trying head around rails. my view @ bottom works when use: def show @posts = post.all end however in controller have: def show @posts = post.find_by_category_id params[:id]; end in view have <%= @posts.each |post| %> <%= post.title %> <% end %> some please explain why error. should use. category_id foreign key on post table. look @ http://api.rubyonrails.org/classes/activerecord/findermethods.html#method-i-find_by finds first record matching specified conditions find_by_ return 1 post, not collection. not able use each.

python 3.x - Changing float with decimal point into words -

how change input float (for example 50300.45) words in form of voucher (fifty thousand 3 hundred , 45/100 dollars) in python? to spell out money represented decimal string 2 digits after point: spell out integer part, spell out fraction: #!/usr/bin/env python import inflect # $ pip install inflect def int2words(n, p=inflect.engine()): return ' '.join(p.number_to_words(n, wantlist=true, andword=' ')) def dollars2words(f): d, dot, cents = f.partition('.') return "{dollars}{cents} dollars".format( dollars=int2words(int(d)), cents=" , {}/100".format(cents) if cents , int(cents) else '') dollars in ['50300.45', '100', '00.00']: print(dollars2words(dollars)) output fifty thousand 3 hundred , 45/100 dollars 1 hundred dollars 0 dollars here's inflect module helps convert integer english words . see how tell python convert integers words

App Widget not listed in google now launcher widget list in Nexus 5 (Android 5.1.1) -

i have app has widget along it. works fine devices except nexus 5. widget not listed in widget list of nexus 5's google launcher. have tested installing app on nexus 7 (android 5.1.1) same google launcher , widget shows in list. i have seen similar bug filed google launcher, here mentioned on device reboot widget showing up. strangely though doesn't work me. have installed custom launcher(nova launcher) , tested scenario , widget shows without problem. here code below config xml <?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minwidth="350dp" android:minheight="133dp" android:updateperiodmillis="3600000" android:previewimage="@drawable/ic_launcher" android:initiallayout="@layout/ana_app_widget" android:resizemode="none" android:widgetcategory="home_screen|keyguard&

c# - How long does variable assignment take? -

i've come across code made liberal use of variables var self = this; code nicer. while don't think assignments these going significant @ in piece of code, i've wondered how long assignment above take. with said: how long take, assuming isn't optimized away? how times compare between different languages- e.g. c#, java, , c++? common value types (including pointers)? 32 / 64-bit architectures? edit: erased part "noticeable difference". meant part side-question, many people have seen , started downvoting me premature optimization (in spite of me highlighting bottleneck part in bold). the code: var self = this; isn't creating new instance of object 'this', referencing pointer object 'this'. @ machine level there 1 pointer since c# compiler optimizes these types of reference out. "how long takes" zero. so, why 'this'? because makes code easier read.

google cloud platform - Trouble Mapping A GA Client ID to a BigQuery fullvisitorID -

i in midst of controlled test verifying link between google analytics & bigquery data. in theory bigquery fullvisitorid supposed equivalent client id. said, following controlled test completed: i visited internal website custom source/medium of "nate/nate" obtained ga client id cookie (values 1535662810) i expected client id map fullvisitorid in bq unfortunately, when query bigquery data set using following query fullvisitorid 6595621548070533271. can comment on difference being observed? select fullvisitorid [98843070.ga_sessions_intraday_20150716] trafficsource.medium = 'nate'

node.js - How to write a Npm Script Command that works cross platform -

i'm trying write postinstall command works openshift install bower dependancies. i've managed working great. "scripts": { "postinstall": "home=$openshift_repo_dir bower install" } i'm trying improve command can run following command locally on windows pc. npm install it throws error: ps d:\dev\cgb14\code\trunk\solution\app> npm install > warcher_app@1.0.0 postinstall d:\dev\cgb14\code\trunk\solution\app > home=$openshift_repo_dir node_modules/.bin/bower install 'home' not recognized internal or external command, operable program or batch file. npm err! windows_nt 6.3.9600 npm err! argv "d:\\program files\\nodejs\\\\node.exe" "d:\\program files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "ins tall" npm err! node v0.12.4 npm err! npm v2.10.1 npm err! code elifecycle npm err! warcher_app@1.0.0 postinstall: `home=$openshift_repo_dir node_modules/.bin/bower install` npm err! exit

What Spring Rest Annotation handles a page load event? -

i'm looking @ of spring rest annotations, want triggered when page loaded? of these, or else entirely. using rest model view whatever approach. org.springframework.data.rest.repository.annotation.handlebeforesave (implements java.lang.annotation.annotation) org.springframework.data.rest.repository.annotation.repositoryeventhandler (implements java.lang.annotation.annotation) org.springframework.data.rest.repository.annotation.handleafterdelete (implements java.lang.annotation.annotation) org.springframework.data.rest.repository.annotation.handlebeforerenderresources (implements java.lang.annotation.annotation) org.springframework.data.rest.repository.annotation.handleafterlinksave (implements java.lang.annotation.annotation) org.springframework.data.rest.repository.annotation.handlebeforelinksave (implements java.lang.annotation.annotation) org.springframework.data.rest.repository.annotation.handleaftersave (implements java.lang.annotation.annotation

image processing - android camera2 process each frame and display its preview -

i use https://github.com/googlesamples/android-camera2basic , try modify in way access each frame before drawn on surfaceview. understood, should add additional surface (imagereader.getsurface()), , read frame in callback: private final imagereader.onimageavailablelistener monimageavailablelistener = new imagereader.onimageavailablelistener() { @override public void onimageavailable(imagereader reader) { log.d("img", "onimageavailable"); mbackgroundhandler.post(new imagesaver(reader.acquirenextimage(), mfile)); } }; the problem callback gets called when image capture user , not on eacg frame sent preview screen camera. here tried add: private void createcamerapreviewsession() { try { surfacetexture texture = mtextureview.getsurfacetexture(); assert texture != null; // configure size of default buffer size of camera preview want. text

java - How do I store data in a wrapper class from a method deep in the stack? -

i have class (xmlbuilder) builds xml doc. within process parse data make fit in xml model. capture data related parsing. have wrapper class (xmlbuilderwrapper) designed capture parsed data. my question is: how access wrapper class parser (or vice versa) store data? don't want return data through stack if can it. i assuming using form of recursion. can pass reference of wrapper parameter. don't have return anything. instantiate wrapper before first call of builder , pass reference parameter. changes make wrapper occur on same object, no matter how deep in stack. also, if understood correctly, wrapper class isn't wrapper. more model.

excel - How to build an inventory from transactions in access -

i trying determine cost of goods each , date in inventory including interest payments based on transactions in system. receive information regarding transactions ms sql server , limited ms access , excel analyze data. i have built query gives me following fields: goodscode | transactiondate | transactionquantity | transactionprice | transactiontype and further input have interestrate the output looking is: goodscode | transactiondate | inventorybalance | unitcost i able reproduce problem single in excel adding variables took inputs previous , current row in following way (with t being current row , t-1 previous row): inventorychange(t) = if(transactiontype = "sale" or "salereturn"): + transactionquantity(t) else: - transactionquantity(t) inventorybalance(t) = inventorybalance(t-1) + inventorychange(t) dayspassed(t) = transactiondate(t-1) - transactiondate(t) inventorycost(t) = inventoryvalue(t-1) * ((1+interestrate)^dayspassed(t) -

c# - How to convert from wma to mp3 using NAudio -

please note not duplicate of other question linked. uses classes couldn't find, detailed in question below. i'm trying convert wma files mp3. need solution can integrate code base, not rely on external resource, using ffmpeg isn't option. i've been trying naudio, without success. one problem there seem 2 versions of naudio around, , neither seems complete. 1 nuget doesn't include wmafilereader class, there's no way (that can see) read wma files. version on github includes wmafilereader class, doesn't seem include mp3writer class, nor wavelib class i've seen in many examples. so, know how can job? i've wasted hours trying different code samples, none of them seem work either version of naudio can find. ideally, in memory, if have write temporary disk files, it's not end of world. edit discovered there more naudio nuget packages extend basic one. there 1 lame , 1 wma, after installing them, can't code work. seems simpl

javascript - Changing to an Error Class -

i need validate length of string in inputbox. if string invalid trigger onblur event. when event triggered, must turn label of object associated trigger red. however, there css class exist contains style, need change class class. prefix value being passed in. here sample code. var input = $(this).val(); var findlabel = document.getelementbyid`enter code here`(prefix+'findlabel'); if(input.length < min || input.length > max){ //alert check values testing alert('value selected country '+selectedcountry+' must between '+min+' , '+max+' characters'); } example <div class="value_s123" id="a1values123" style="float:left;"> <span class="avalue" id="a1value"> <label class="classoff" id="a1valuelabel">some value</label> <span style="white-space: nowrap;"> <input id="a1catchvalue&qu

javascript - Setting Combobox Value for RowEditing Editor in Extjs -

i kinda facing interesting problem combobox behaving weird. i have grid 3 columns id , name , associated part. i have enabled rowediting plugin , editors id textfield(editid), name textfield(editname) , associated part combobox(editpartcombo). i have button called update. when select row in grid , press update, rowediting starts @ exact position. editid , editname shows default values has been selected editcombo populates blank. code on update button: { text: 'update part', handler: function(btn){ var grid = btn.up('grid'); var selection = grid.getselectionmodel().getselection(); if(selection.length > 0){ alert(selection[0].get('id_part')); ext.getcmp('editpartcombo').setvalue(selection[0].get('id_part')); var rowediting = grid.getplugin('roweditplugin'); var rowno = grid.store.indexof(selection[0]); rowediting.canceledit(); rowediting.startedit(rowno, 1); } else{ ext.msg.alert('error' , 'please

android - how to use of update operation sqlite? -

i have problem sqlite update operation, please me how fix database handler update data : public int updateaccountcalc(accounts accounts) { sqlitedatabase db = this.getwritabledatabase(); contentvalues values = new contentvalues(); values.put(key_id, accounts.getid()); values.put(key_nama, accounts.getnama()); values.put(key_email, accounts.getemail()); values.put(key_bb0, accounts.getbb0()); values.put(key_bb1, accounts.getbb1()); values.put(key_bb2, accounts.getbb2()); values.put(key_bb3, accounts.getbb3()); values.put(key_lila, accounts.getlila()); // updating row return db.update(table_name, values, key_id + " = ?", new string[] { string.valueof(accounts.getid()) }); } and code use : db.updateaccountcalc(new accounts(0, nama.tostring(), email.tostring(), bb, 0, 0, 0, lila)); i have inserted value of bb, never

jQuery pass to input value -

i'm trying pass id hidden input value. id returning right value not passing target input value $('.delete-customer').click(function(){ var cust_id = $(this).children().attr('id'); var target = $('#remove-item').val(); $(target).text(cust_id); }); hidden input: <input id="remove-item" type="hidden" name="cid" value="" /> $('.target-val').val(cust_id); http://api.jquery.com/val/

ios - How to allow user to crop a fixed frame of an image iPhone -

Image
i trying find way allow user select part of image he/she wants use. crop size fixed, user can't adjust how big or small want photo. in mind, screen display photo rectangle on it, user move around his/her touch. press "ok" , image cropped wherever rectangle was. right code is: (uiimage *)imagebycropping:(uiimage *)imagetocrop torect:(cgrect)rect { cgimageref imageref = cgimagecreatewithimageinrect([imagetocrop cgimage], rect); uiimage *cropped = [uiimage imagewithcgimage:imageref]; cgimagerelease(imageref); return cropped; } this code automatically crops image center without giving user chance crop him/herself. i'm thinking along lines of this: in above image, user moves picture around in background until part within box want keep, while cropping rest. can zoom in , out on photo pinching.

objective c - MKMapView pin animation and annotation -

i'm using google places api find restaurants nearby (based on current location using core location manager); currently, i'm able drop pins. use searchbarsearchbuttonclicked method, , inside of dispatch_async block, call method parse through serialized data , attribute values properties of pin class (class mkannotation). i'd animate pin drops, , display annotations...for reason had them working before won't show when click on pins. view controller.h @interface myviewcontroller : uiviewcontroller <cllocationmanagerdelegate, mkmapviewdelegate, uisearchbardelegate,nsurlsessiondelegate> { cllocationmanager *locationmanager; } @property (strong, nonatomic) mkmapview *mapview; @property (strong, nonatomic) uisearchbar *searchbar; @property (strong, nonatomic) uiimageview *logo; @property (strong, nonatomic) uitoolbar *toolbar; @property (strong, nonatomic) nsstring *places; @end view controller.m -(void)searchbarsearchbuttonclicked:(uisearchbar *)

c# - Entity Framework error, only when deleting "multiple" Parent then Child row -

Image
i'm building , mvc project using entity-framework 6 (code first). my database data models (code first): public class parentnode { public int parentnodeid { get; set; } public string someparentdata { get; set; } //fk [required] public int childnodeid { get; set; } public virtual childnode childnode { get; set; } } public class childnode { public int childnodeid { get; set; } public string somechildishdata { get; set; } //references table/model public virtual icollection<parentnode> parentnodes{ get; set; } } the issue: deleting multiple childnodes i won't rely on cascade delete parentnode->childnode has many 1 relation. in case need delete 1 childnode, first delete parentnode childnode () deleting 1 childnode done this: deleting 1 childnode: no problem (if 1 present in list) deleting multiple childnodes: fk null reference error occurs { ... foreach(parentnode parenttodelete in parentnodelist) { db.entry(

php - How to load eden with composer? -

i want write application uses parts of mailer part of eden library. i have required via composer.json : "require": { "eden/mail": "^1.0", ... it seems though library isn't autloaded properly, call eden via eden('mail')->smtp(...) function leads to: php fatal error: call undefined function kopernikus\massmailer\service\eden() in ~/src/massmailer/src/kopernikus/massmailer/service/edenmailerfactory.php on line 20 the quick setup guides handles case one-file approach via: include('eden.php'); eden('debug')->output('hello world'); //--> hello world i don't want add huge libary file , include manually. autoloading seems works fine, have use class directly instead of going eden() function: use eden\mail\smtp; yourclass { $smtp = new smtp( $host, $user, $pass, $port = null, $ssl = false, $tls = false ); } th

Why Does the R Interpreter Continue to Excute Code After an Error? -

when send block of r code interpreter in rstudio (or tinn-r or other environment) if there's error on line 1, lines 2, 3, 4 ... still execute. why default behavior? seems contrary how programming languages work , dangerous in sense if line 1 produces error alter subsequent lines of code do. it's particularly bad in long scripts have lot of printed output because can miss error message amidst regular output. there reason, either logical or historical, why r works way? , possible change behavior , ensure interpreter stop upon encountering error? consider r code error: print("starting") b+sdlkfjsflkj print("hello world") if select code , copy interpreter, describe continue past error: > print("starting") [1] "starting" > b+sdlkfjsflkj error: object 'b' not found > print("hello world") [1] "hello world" a simple solution causes stop @ error storing in script , running source : source

Grails 2 vs Grails 3 -

i'm rather new grails , i'm start new grails project. i'm confused version go based on tools not being ready support newest version. i've read version 3 complete rewrite ground gut says should version go considering project brand new, i'm discovering none of tools ready version 3. i able version 3 intellij out grails support , same goes ggts. with being said, don't know how run app in ggts since grails-runapp doesn't work with ggts, used following tutorial https://tedvinke.wordpress.com/2015/04/10/grails-3-released-installing-gradle-and-groovy-2-4-support-in-eclipseggts/ i've been able figure out how app run. know how this? my questions are how run grails 3 app in ggts. is recommended use grails 3 @ point or should use grails 2 if use grails 3, recommended ide? with intellij had run going grails-app/init project run main. correct way it? as of grails 3 don't need special ide run grails 3 application. need right-click on

angularjs - Using ui-router and ocLazyLoad to load a controller and set the partial to it -

i'm complete angular noob , trying fancy stuff quickly, forgive me if dumb question. i've created website uses routing, , i'm using ui-router routing instead of standard angular router. theory still same - have index.html page in root of website "master" or "host" page, , loginview.htm, partial, exists in separate directory. the maincontroller project loaded in index.html page. referencing controller not cause error or problem. what i'd do, in order keep code manageable , small, have custom controller partial page lazy load when load partial, , associate partial page newly loaded controller. makes sense, right? don't want load controllers default, because that's waste of time , space. so structure looks (if matters anyone): root --app/ ----admin/ ------login/ --------loginview.html --------logincontroller.js --maincontroller.js index.html this logincontroller code. testing purposes, have made maincontroller code match exactly.

javascript - Click not registering on Image element -

i'm trying click register on image tag coordinates of image click position svg element on top of it. far understand, way have code should account bubbling events, i'm not 100% certain. can me understand i'm doing wrong, information might missing it? of now, nothing runs. $(".playing-field").on("click", "#picture", function(e) { var offset = $("#picture").offset(); var relativex = (e.pagex - offset.left); var relativey = (e.pagey - offset.top); console.log(relativex, relativey); }); i forgot add html before... <div class="playing-field"> <img id="picture" src="assets/images/image.jpg"> <svg class="speechbubbles" width="100%" height="100%" preserveaspectratio="xminymin meet"> </div> i tried code in jsfiddle without css, , works, when add css, doesn't. i'm not familiar css rules, can tell me why interfere clic

javascript - Min of a couple of values which must not be 0 -

i need minimum of a , b , c , d . when 1 or more of them 0 fall out of comparison. solve if / else cascade kind of ugly. there cleaner way solve this? math.min alone doesn't work because result in 0 when ever 1 of variables 0. can put them in array , drop 0 in array? there math.min arrays? bestprice: ember.computed('a', 'b', 'c', 'd', function() { var = this.get('a'); var b = this.get('b'); var c = this.get('c'); var d = this.get('d'); return math.min(a, b, c, d); }), example: a = 0 b = 10 c = 20 d = 30 bestprice: 10 how this? prices: ember.computed.collect('a', 'b', 'c', 'd'), bestprice: ember.computed('prices', function() { var nonzero = this.get('prices').filter(function (x) { return x > 0; }); return math.min.apply(null, nonzero); }),

php - Token mismatch exception only on every first attempt laravel 5.1 -

every time log in application first time after hour or or on every new device token mismatch exception. when try again right after problem goes away. using 755 on storage/framework/sessions -- have same problem on local vagrant scotch box 1.5 box onmy digital ocean lamp. ideas? the problem csrf token has expired , browser need new token make post request. expiration time default in laravel 2 hours. i have same problem , trying solution https://laracasts.com/discuss/channels/general-discussion/crsf-checked-before-auth update: you need update render method in app/exceptions/handler.php , handle exception: tokenmismatchexception code example /** * render exception http response. * * @param \illuminate\http\request $request * @param \exception $e * @return \illuminate\http\response */ public function render($request, exception $e) { if ($e instanceof \illuminate\session\tokenmismatchexception) { return

reactjs - Get the list of compiled modules? Exclude React from bundle? -

how list of compiled modules bundled browserify + babelify? i've set simple bundling process gulp. i noticed bundle becomes big. don't have lot of 'useful' code. libraries have following on page: react, react-router, validator , eventemitter, immutable. bundle 1.5mbs. map file separate. there way minimize size? i tried exclude react with: bundlestream.external(['jquery', 'react']); i saw jquery excluded , size smaller now. still see react modules in output. update so, problem used few react components added via npm. 1 of pointing 'react' , other 'react/addons' . figured manually going through code. not sure tool me that. strip had add both browserify bundle: bundlestream.external(['jquery', 'react', 'react/addons']); one thing mention though goal load libraries cdn , use theirs globals in code. i've written simple browserify transform function explained here change require('react')

Django Admin - SubModels on Parent Form -

i have django model called product . want add 1:n relation in product choose images of product, , on product admin form want user add images. i tried manytomany relation it's not want because don't want user visit 2 forms product create products, images create images , products again select images of product have. anyone has ideia? sorry if not clear, , let me know if need more informations. models.py : class image(models.model): """ generic image model """ name = models.charfield(max_length=100, blank=false, verbose_name=_("name")) image_file = models.imagefield(blank=false, upload_to=image_upload, verbose_name=_("file")) def __unicode__(self): return u'{}'.format(self.name) def post_url(self): return os.path.join(settings.media_root, 'images', self.__class__.__name__) class meta: verbose_name=_("image") verbose_name_plu

r - Can I use readLines in mapreduce job in Rhadoop? -

i'm trying read text or gz file hdfs , run simple mapreduce job (actually map job) got error seems readlines part doesn't work. i'm seeking answers of whether can use readlines function in mapreduce. ps. there no problem if use readlines function parse hdfs files outside of mapreduce job. thanks. counts <- function(path){ ct.map <- function(., lines) { line <- readlines(lines) word <- unlist(strsplit(line, pattern = " ")) keyval(word, 1) } mapreduce( input = path, input.format = "text", map = ct.map ) } counts("/user/ychen/100.txt") not - mapping function expects dfs formatted data come in. rewrite function this, formatting in input step: counts <- function(path){ ct.map <- function(.,line) { word <- unlist(strsplit(line, split = " ")) keyval(word, 1) } mapreduce( input = to.dfs(readlines(path)), map = function(k,v

jquery - Getting "undefined" from a javascript array in .each loop -

i've seen number of similar questions posted none of them have been able me closer solution. i have data coming in me ecommerce api: (keep in mind, have no control on how data being sent me can't change @ "source.") object { url: "http://pathtomyimage.jpg", name: ""} name: ""url: "http://pathtomyimage.jpg" __proto__: object__definegetter__: __definegetter__() { [native code] }__definesetter__: __definesetter__() { [native code] }__lookupgetter__: __lookupgetter__() { [native code] }__lookupsetter__: __lookupsetter__() { [native code] }constructor: object() { [native code] }hasownproperty: hasownproperty() { [native code] }isprototypeof: isprototypeof() { [native code] }propertyisenumerable: propertyisenumerable() { [native code] }tolocalestring: tolocalestring() { [native code] }tostring: tostring() { [native code] }valueof: valueof() { [native code] }get __proto__: __proto__() { [native code] }set __proto__: __proto__

ios - removing padding/gap from displaying ppt on UIWebView -

Image
in example, between slides of ppt file, there gray padding/gap don't want. want upcoming slide reside directly below current slide without in between. prefer solution swift. in webviewdidfinishload() do this webview.stringbyevaluatingjavascriptfromstring("var slides = document.getelementsbyclassname('slide');var count = slides.length;for (var = 1; < count; i++) {var oldtop = slides[i].style.top;var newtop = parseint(oldtop) - 5 * + 'px';slides[i].style.top = newtop;}")

java - Standard/Uniform way to locate files inside and outside JAR file? -

what uniform or standard way locate , access files inside , outside jar files. i have injarclass() defined in jar file contains configuration text files. extend class in host project have more configurations. let have inside jar : config/default.conf then in host project : class myclass extends injarclass { .... } and : config/test.conf then run : xenv=test java myclass the whole configuration process happens inside injarclass(), based on environment xenv. see injarclass() have access both : <jar>/config/default.conf <host_app_dir>/config/test.conf so repeat question there uniform way access both, if directory structure mirror each other. if place both current directory , .jar file in classpath: xenv=test java -classpath .:myjarfile.jar myclass you can this: string configfile = "/config/" + system.getenv().getordefault("xenv", "default") + ".conf"; inputstream config = myclass.cl

bit manipulation - set most significant bit in C -

i trying set significant bit in long long unsigned, x. using line of code: x |= 1<<((sizeof(x)*8)-1); i thought should work, because sizeof gives size in bytes, multiplied 8 , subtract 1 set final bit. whenever that, compiler has warning: "warning: left shift count >= width of type" i don't understand why error occurring. the 1 shifting constant of type int , means shifting int value sizeof(unsigned long long) * 8) - 1 bits. shift can more width of int , apparently happened in case. if want obtain bit-mask mask of unsigned long long type, should start initial bit-mask of unsigned long long type, not of int type. 1ull << (sizeof(x) * char_bit) - 1 an arguably better way build same mask be ~(-1ull >> 1) or ~(~0ull >> 1)

java - String/File comparison and highlight their differences -

i want compare 2 strings , highlight exact differences, until using stringutils.difference , requirement highlight exact difference beyond compare , other differencing tool. thought of using bc script java , generating report in html, later extract data or show is, occurred bc proprietary software , have ask them buy software (because using bc.exe in script command) question is 1) there way call beyondcompare java , use other manner (that isnt illegal). perhaps library? 2) if not other gpl tool provides byte byte comparison, more precise if "a+b" , "a-b" "-" should highlighted(not line of change, found gpl tools provide that, wrong). 3) there effective algorithm implement , achieve intended behaviour. long post, please kind.. :|

Android RingtoneManager media path for custom ringtones not playing anymore -

i upgraded old nexus device latest , mediaplayer wont play custom ringtone paths im retrieving way of ringtonemanager picker. i have 2 media's example: content://media/internal/audio/media/86 --this 1 not play, custom ringtone ( mp3 downloaded , added /media/audio/ringtones/) and content://media/internal/audio/media/54 --this 1 plays im trying play both mediaplayer api in android. both media paths returned me ringtonemanager follows: intent intent = new intent(ringtonemanager.action_ringtone_picker); // activity stack history, 1 time deal // intent.setflags(intent.flag_activity_no_history); intent.putextra(ringtonemanager.extra_ringtone_title, "please select ringtone"); intent.putextra(ringtonemanager.extra_ringtone_type, ringtonemanager.type_all); intent.putextra(ringtonemanager.extra_ringtone_show_default, true); //intent.putextra(ringtonemanager.extra_ringtone_include_drm, true);

Different Values for MD5 between Ruby and JavaScript -

i need able run md5 hash on same file clientside javascript app , on server ruby. currently cannot both hashes identical. on client, i'm using jquery file upload upload file s3 bucket. using crypto hash file in callback: file = data.files[0] filename = file.name; md5 = cryptojs.md5(cryptojs.enc.hex.parse(data.files[0].tostring())); this gives me: ee9cd5bf4272fc35bd57d184553bd25b in ruby, it's module digest::md5 module used gem doing hashing: digest::md5.file(file).to_s this gives me: 4d51c9a4d3fd076489d6c96614ebce61 i have no control on ruby side of things, why might checksum generated crypto different? note can test locally, using same api: path = 'path/to/file.jpg' digest::md5.file(f).hexdigest # 4d51c9a4d3fd076489d6c96614ebce61 the file large jpg (~ 1.8meg) update: in response @kxyz's answer, results using different encoders crypto-js are: cryptojs.md5(cryptojs.enc.hex.parse(data.files[0].tostring())); // ee9cd5bf4272fc35bd57d184

ios - Make NSTimer continue after closing and opening the game -

i making clicker game , need have nstimers continue after closing application. looked first not find suitable answer swift. think can use userdefaults not sure how apply it. sorry if duplicate question, know there lot of information on this. var timervar = nstimer.scheduledtimerwithtimeinterval(4, target: self, selector: selector("selectorname"), userinfo: nil, repeats: true) func selectorname(){ var scoredefault = nsuserdefaults.standarduserdefaults() scoredefault.setvalue(score, forkey: "score") scoredefault.synchronize() score+=1 scorelbl.text = "\(score)" } you can't pause , continue timer. have invalidate , create new one. record time @ moment start timer, , when pause it, figure out amount of elapsed time , use figure out how time remains. create new timer amount of remaining time calculated.

How to control camera flash light with camera2 API -

i want control flash light of smartphone (galaxy s6) using camera2 api. i checked available codes this, try { cameramanager mmanager = (cameramanager) getsystemservice(context.camera_service); string [] cameraid = mmanager.getcameraidlist(); cameracharacteristics cameracharacteristics = mmanager.getcameracharacteristics(cameraid[1]); toast.maketext(getapplicationcontext(),cameraid[0]+cameraid[1],toast.length_long).show(); boolean flashavailable = cameracharacteristics.get(cameracharacteristics.flash_info_available); if (flashavailable) { mmanager.opencamera(cameraid[0], new mystatecallback(), null); toast.maketext(getapplicationcontext(),"flash available",toast.length_long).show(); } else { //todo: throw exception toast.maketext(getapplicationcontext(),"flash not available",toast.length_long).show(); } } catch (exception e) { e.printstacktrace(); } but, toast message : flash not available.

android - Icon animation on the new NavigationView -

i trying switch new navigationview drawer. when did (and working fine), lost animation of menu icon icon when drawer sliding. how can have on navigationview? here code: toolbar = (toolbar) findviewbyid(r.id.app_bar); toolbar.setnavigationicon(r.drawable.ic_menu_white); setsupportactionbar(toolbar); mdrawer = (navigationview) findviewbyid(r.id.navigation_drawer); if (mdrawer != null) { mdrawer.setnavigationitemselectedlistener(this); } mdrawerlayout = (drawerlayout) findviewbyid(r.id.drawer_layout); thanks in advance! after doing lot research, solved adding following: @override protected void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); // sync toggle state after onrestoreinstancestate has occurred. mdrawertoggle.syncstate(); } hope helps.

sql - Please assist with case when statement -

i assistance creating case when statement in query. i have following query trying modify case when hotelexpenses between convert(varchar(10), getdate(),121) , convert(varchar(10),dateadd(mm,6,getdate()),121) , engagementexpenses between convert(varchar(10), getdate(),121) , convert(varchar(10),dateadd(mm,6,getdate()),121) , travelexpenses between convert(varchar(10), getdate(),121) , convert(varchar(10),dateadd(mm,6,getdate()),121) 'yes' else 'no' end combinedflag i add additional condition lets hotelexpenses, when hoteexpenses > $100.00 , engagementexpenses >100.00 , travelexpenses > 100.00 , if of above conditions have met in addition case statement flag should 'yes' or else 'no' end abc now in scenarios conditions meet hotelexpenses not other 2 flag should yes if hotelexpenses>100.00 , remaining 2 <100.00 . (makes sense?) if 3 matches date criteria , not meet amount flag