Posts

Showing posts from July, 2010

javascript - Get Video Duration jQuery -

i have question. trying duration of source. i want next: when page load need duration of source problem when want duration apparently not visible, can duration when press button. need know duration since start because need calculate position on video/audio , send through currenttime. i try "alert" result "nan". this code actually: $( document ).ready(function() { var asset = $('#asset')[0]; // obtiene el objeto var tipo = $('#asset').attr('class'); // video, audio, pdf var duracion = asset.duration; var porcentaje = $('#porcentaje').attr('data-percent'); var tiempo = (porcentaje*duracion)/100; asset.currenttime = tiempo; alert(duracion); // nan $("#guardar").click(function() { var avance = asset.currenttime; if(tipo == 'video' || tipo == 'audio'){ porcentaje = parseint((avance*100)/duracion); } else if(tipo =...

Javascript Date() is changing the date -

i'm pulling events google calendar. i'm able see event date: var date = when.split("t")[0]; console.log(date); this outputs 2016-01-07 . put array inside object: allevents.push({ eventdate:date, eventtime:time, eventtbd:tbd }); then, when go grab date again: $.each(allevents, function(i, v){ var eventdate = new date(v.eventdate); if(eventdate > startdate && eventdate < enddate){ console.log(v.eventdate); console.log("show date: " + eventdate); } }); for january, output: 2016-01-07 show date: wed jan 06 2016 19:00:00 gmt-0500 (est) for march, output: 2016-03-19 show date: fri mar 18 2016 20:00:00 gmt-0400 (edt) it's showing day before date showed... seems 5 hours off? need account this? how do so? the default timezone when parsing date utc. if want use client timezone can adjust date occurs @ right time in browser's timezone: var eventdate = new date(v.e...

javascript - Jquery scrolling effect -

i know place posting questions regarding code issues please can me out need scrolling jquery effect when on section if portfolio section active content start scrolling automatically in website section number 4 jquery have use @ http://stampsy.com . can me out, please? i'm confused question think want picture slide effect? if so, recommend using bootstrap carousel, should give need. edit: for section number 4 use css scroll effects.

scala - Labelling points for classification in Spark -

i'm trying run multiple classifiers on this telecom dataset predict churn. far, i've loaded dataset spark rdd, i'm not sure how can select 1 column label - in case, last column. not asking code, short explanation on how rdds , labeledpoint work together. looked @ examples provided in official spark github, seem use libsvm format. question: how labeledpoint work, , how can specify label is? my code far, if helps: import org.apache.spark.sparkcontext import org.apache.spark.sparkcontext._ import org.apache.spark.sparkconf import org.apache.spark.ml.classification.{randomforestclassificationmodel, randomforestclassifier} import org.apache.spark.ml.feature.standardscaler import org.apache.spark.mllib.classification.{svmmodel, svmwithsgd, logisticregressionwithlbfgs, logisticregressionmodel, naivebayes, naivebayesmodel} object{ def main(args: array[string]): unit = { //setting spark context val conf = new sparkconf().setappname("churn") val s...

Makefile: compile .o from .c files -

i not have experience makefiles, answer may obvious. however, not able find looking in gnu make manual or elsewhere on stackoverflow. have run issue few times, have made example project demonstrate it. i have directories: src/ .c files build/ library being built obj/ .o files (one being compiled different project) what looks like: $ ls -l total 0 drwxrwxr-x+ 1 sam none 0 jan 5 15:43 build drwxrwxr-x+ 1 sam none 0 jan 5 15:43 obj drwxrwxr-x+ 1 sam none 0 jan 5 15:42 src my makefile: cc=gcc cflags=-wall sources=$(wildcard src/*.c) source_objects=$(patsubst src/%.c,obj/%.o,$(sources)) objects=$(wildcard obj/*.o) hashsrc=/cbib/libhash/src/hash.c target=target.a all: $(target) $(target): $(objects) ar rcs $@ $^ obj/%.o: src/%.c $(cc) -o $@ $^ $(cflags) obj/hash.o: $(hashsrc) $(cc) -o $@ $^ $(cflags) the rule obj/%.o: src/%.c catches .o files in obj/ directory. want catch files listed in source_objects, , compile them corresponding files in sr...

php - How to set NULL if REGEX doesn't has any matches? -

i have regex returns numbers string: $str = "this 1 str, 2"; $numb = preg_replace("/[^0-9]/","",$str); echo $numb; // output: 12 but if string doesn't containing number, return nothing. want returns null if string isn't containing number. this: $str = "this 1 str"; $numb = preg_replace("/[^0-9]/","",$str); echo $numb; // current output: // want: null note: null isn't string, should this: $numb = null; how can that? you can't just using regex (since preg_replace returns string or null if encountered error) . need check variable , assign null if needed: $numb = $numb ?: null;

javascript - Why is my partial not rails rendering properly? -

i want add comments without having refresh page in app. however, partial no load js functionality implementing. i getting no errors in log or console, , comment shows once refresh page, not happen without refresh. also, when write js append last comment win_com id, code works. i'd html dynamically show current state of comment partial via js rather append last comment. appreciated! here's code: comments_controller.rb: def create @window = window.find(params[:window_id]) @comment = @window.comments.build(comment_params) @comment.user_id = current_user.id if @comment.save respond_to |format| format.html { redirect_to post_path(@post) } format.js end end end views/windows/show.html.erb: (part of larger view) <div class="row col-md-7" id="win_com"> <h4>user comments</h4> <%= render partial: '/windows/comment', collection: @comments %> </div...

c# - how to create events on dynamic `textboxes` -

i managed create textboxes created @ runtime on every button click. want text textboxes disappear when click on them. know how create events, not dynamically created textboxes. how wire new textboxes? private void buttonclear_text(object sender, eventargs e) { mytext.text = ""; } this how assign event handler every newly created textbox : mytextbox.click += new system.eventhandler(buttonclear_text);

Glassfish MySQL JNDI Lookup fails -

on glassfish 4.1.1 admin interface have setup jdbc resource named jdbc/mysql linked jdbc connection pool named mysql (modified domain.xml manually first). ping on connection pool successful. far good. i modified web.xml , added: <resource-ref> <description>db connection</description> <res-ref-name>jdbc/mysql</res-ref-name> <res-type>javax.sql.datasource</res-type> <res-sharing-scope>shareable</res-sharing-scope> </resource-ref> and glassfish-web.xml: <resource-ref> <res-ref-name>jdbc/mysql</res-ref-name> <jndi-name>jdbc/mysql</jndi-name> </resource-ref> but in j2ee war, when do: initialcontext ctx; datasource ds; ctx = new initialcontext(); ds = (datasource) ctx.lookup("java:comp/env/jdbc/mysql"); the result lookup failed. removing java:comp/env/ did not help. any hint appreciated! thank you. regards john ok, got work. resource enabled , m...

mysql - Enemy Movement in PHP -

i'm working on making battle simulator of sorts , i've hit big road block. i'm trying create simple ai( or close ai can ) moves closer on 5x5 grid . the problem i'm not sure how begin script. thought if in tile " 1 " , enemy in tile " 25 " , enemy can pick surrounding tiles it's next move, 19,24 or 20 logically want pick 19 since it's lowest number of group, closing gap. realized if moving top left or bottom right there difference of 6, if moving top right or bottom left there difference of 4. has left me " coder's block ". , possible solutions awesome. thanks in advance! edit: i guess i'm not being specific enough, i'll try again. have php file image of overview of trees , grass , have drawn 5x5 grid on it. each cell 55x55 pixels , each cell it's own individual div overlays on top of image. in mysql database have table labeled location column id,name,and tile number. updated database put me on tile...

java - How can I know if a task submitted to executor threw exception? -

if run thread in executorservice there way know thread did not throw exception when started execution? as per the javadoc , can submit runnable the executor using submit() executorservice service = executors.newsinglethreadexecutor(); future f = service.submit(new runnable() { @override public void run() { throw new runtimeexception("i failed no reason"); } }); try { f.get(); } catch (executionexception ee) { system.out.println("execution failed " + ee.getmessage()); } catch (interruptedexception ie) { system.out.println("execution failed " + ie.getmessage()); } this method work when exceptions unchecked. if have checked exceptions, rethrow them wrapped in runtimeexception or use teh callable instead of runnable interface.

c# - Parallel BFS rush hour solver -

so, uni have assignment have make serial implementation of rush hour solver parallel. solver uses bfs implementation. here part of default bfs implementation: // initialize empty queue queue<tuple<byte[], solution>> q = new queue<tuple<byte[], solution>>(); // default, solution "no solution" foundsolution = new nosolution(); // place starting position in queue q.enqueue(tuple.create(vehiclestartpos, (solution)new emptysolution())); addnode(vehiclestartpos); // bfs while (q.count > 0) { tuple<byte[], solution> currentstate = q.dequeue(); // generate sucessors, , push them on queue if haven't been seen before foreach (tuple<byte[], solution> next in sucessors(currentstate)) { // did reach goal? if (next.item1[targetvehicle] == goal) { q.cl...

javascript - What is the %< ... >% syntax called? -

saw animaterotate : true, animatescale : false, legendtemplate : "<ul class=\"<%=name.tolowercase()%>-legend\"><% (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillcolor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>" }; and i'm wondering <% ... %> syntax because i've never seen before. i'm supposing it's way of embedding javascript in javascript strings? , can link me documentation on how use it? they're called directives , exist in server-side programing language. they have different tags can perform specific task in html environment. e.g can declare variables,import libraries,call methods, , perform sort of business logic.

c# - Why does this not print everything on the same line? -

watch video ( https://www.youtube.com/watch?v=bfdp3_tf7ks ) 2:47 understand predicament. it supposed print backwards on same line. namespace understandingarrays { class program { static void main(string[] args) { string zig = "you can want out of life if " + "you enough people want out of life."; char[] chararray = zig.tochararray(); array.reverse(chararray); foreach (char zigchar in chararray) { console.write(zigchar); console.readline(); } } } readline() blocks until program reads '\n', program prints out single character , waits hit enter (which causes terminal go next line). because of this, end getting single character on each line. you use console.readkey(boolean) (and not display) next keystroke. you can move console.readline() outside foreach loop, prints , waits newline.

c - Converting integer to string with atoi/sprintf -

this not whole code sum easy see. have no problem convert string integer cannot convert integer string. program crashes. here code. @ line itoa . #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define sizex 49 #define sizey 6 int main() { size_t x, y; char *a[50][7]; char name[50][100]; char surname[50][100]; char in[50][100]; char yob[50][100]; char usname[50][100]; char pass[50][100]; char totamount[50][100]; (x = 0; x <= sizex; x++) { a[x][0] = name[x]; a[x][1] = surname[x]; a[x][2] = in[x]; a[x][3] = yob[x]; a[x][4] = usname[x]; a[x][5] = totamount[x]; a[x][6] = pass[x]; } printf("\nplease enter name of new user\n"); scanf(" %s", a[0][0]); printf("please enter surname of new user\n"); scanf(" %s", a[0][1]); printf("please enter identity number...

excel vba - Today function equivalent in VBA in combination with countifs -

i having problem using countifs formula in excel / vba. have got formula working perfect in excel ideally want use in vba form. here formula in excel works treat: =countifs(sheet1!a:a,"place",sheet1!k:k,"<"&today()) will count names places in past =countifs(sheet1!a:a,"place",sheet1!k:k,">"&today()) will count names places current i have 5 different places in column , hundreds of different dates in column k. above formulas work in excel , return correct values. have spent hours trying work in vba userform keep getting various errors. first part not problem &today function falls apart. can see &today function not available in vba , &date seems recommendation. have tried still no where. i'm missing trick (or several) here , working in vba rather using current formulas in excel. returned results displayed in textboxes on form. all ideas , feedback welcome! second edit ==============================...

c# - Updating my application avoids me to get my old files -

i developing desktop application using c# winforms. creating files , folders on directory application runs at. deploying application using click once approach. problem everytime update application creates new root folder run at. , won't able use files anymore. workarounds that? thinkin of creating folder @ "c:\mycompany\myapplication" reachable , breakable. happy hear other advises or knowledges favor me :) you should store files , folders in user's application data folder. can path folder statement: string appdatapath = system.environment.getfolderpath(environment.specialfolder.applicationdata); you should create folder in path application , store there. there of course other solutions, point should not use application folder, since indeed change everytime publish, and bad practice several other reasons (data backup, etc.).

Networking-KVM-2hosts-2vms-lan_router -

i have 2 hosts running opensuse 42.1 connected dlink router via eth0, accessible on 192.168.0.1 , using networkmanager: - vboard/eth0 assigned via router dhcp ip 192.168.0.199 - rihana/eth0 192.168.0.198 using kvm on both hosts, have 2 opensuse vms ( vmvboard, vmrihana) 1 on each host. i configured on both hosts virbr0 network identically, in range 192.168.100.0/24 , dhcp range 192.168.100.128-254 , nat on physical device. vm can ping kvm host on both side, vm's cannot talk each other across router network. config used work on opensuse 13.2, not using network manager... what doing wrong? is there me configuration: networking 2 hosts, router , 2 vm's, 1 on each host ? thanks lot in advance ideas. bridged network hosts , vms in few clicks : using wicked. set dlink router settings via firefox/chrome url: 192.168.0.1 user:admin pass: blank ip on 192.168.0.1 subnet mask 255.255.255.224 ( 30 usable ips) enable dhcp: unchecked note: might easier first r...

sdl - C Space Invaders enemy movement -

i have write clone of space invaders game university in c language using sdl library graphics.i new c , programming in general struggle lot. have 1 row of enemies , i'm trying make move correctly. functions movement of aliens, check collision right/left wall(which sdl_rects near window edges) , if happens, enemies move 1 line lower in opposite direction. problem works okay ten enemies except first one. each time when collision left wall occurs first alien sort of moves away bit others instead of moving in 1 block want to. noticed if change first loop in move_aliens function start i=11 , i--, same thing happen enemy in last column. still dont know how fix it. appreciate if tell me i'm doing wrong, give me idea or sollution :). uploaded video of whats happening http://sendvid.com/dt1reizc void move_down (gamestate *game) { int i=0; for(; < hmaliens; i++) game->alien1[i].y += 25; } int collided(int a1, int b1, int a2, int b2, int width1, ...

elisp - make emacs rgrep default to last search term rather than word at point -

in emacs, there way make rgrep default searching last term passed rather word @ point? want former rather latter. looked @ rgrep, silent on point. if pick through source code, find can want setting variable find-tag-default-function . redefine function grep-tag-default , or associate property major mode via put . here's solution sets variable: (setq find-tag-default-function 'last-grep-tag) (defun last-grep-tag () (if grep-regexp-history (car grep-regexp-history) ""))

How do you create remote project dependencies in Gradle -

so in maven 1 of things can create project dynamically downloads bunch of other projects , uses them components local build. how done in gradle? can use pull down custom tasks , build them automagically. our build huge , monolithic. break-down thing, also.

css - Keep layout in ul list after intertitle -

i work on questionnaire (i have fixed input mask) , have opportunity align format in separate css file. i face issue list layout based on structure of ul headers : when adding intertitle , structure of buttons not follow layout/width of ul titles anymore , hence inconsistent . is there solution problem, i.e. can add css commands in list or separate file enable me keep consistent structure of buttons below intertitle ? please find attached link list of questionnaire reference: http://ww2.unipark.de/uc/hollnder_goethe_universit__t_fra/4568/ospe.php?ses=e82a8e8bd5f573f68972ae65c373fbed&syid=243842&sid=243843&act=start&preview_mode=1 (code: 80a4231323d632d5 if asked: "bitte geben sie ihre gültigen zugangsdaten ein") any solution problem super helpful! many thanks! best, christian

visual studio - Typescript accept intellisense selection on space or continuing typing -

Image
currently in visual studio 2013 web essentials have press enter or tab accept selected intellisense item. i more used pressing space or continuing type when working in c#. there way enable such feature while editing typescript? i able modify behaviour using resharper.

Is there a better way to use asynchronous TCP sockets in C++ rather than poll or select? -

i started writing c++ code uses sockets, i'd asynchronous. i've read many posts how poll , select can used make sockets asynchronous (using poll or select wait send or recv buffer), on server side have array of struct pollfd, every time listening socket accepts connection, adds array of struct pollfd can monitor socket's recv (pollin). my problem if have 5000 sockets connected listening socket on server, array of struct pollfd of size 5000, since monitoring connected sockets way know how check if recv socket ready, looping through items in array of struct pollfd find ones revents equals pollin. seems kind of inefficient, when number of connected sockets because large. there better way this? how boost::asio library handle async_accept, async_send, etc...? how should handle it? what heck, go ahead , write answer. i going ignore "asynchronous" vs "non-blocking" terminology because believe irrelevant question. you worried performance whe...

xml - find first instance of a date using regex -

i'm trying find/replace xml file of tide data in submlimetext2 , i'm stumped multiple instances of same date. here's sample of data: <item> <date>2016/01/01</date> <time>06:16 am</time> <predictions_in_ft>8.2</predictions_in_ft> <predictions_in_cm>250</predictions_in_cm> <highlow>h</highlow> </item> <item> <date>2016/01/01</date> <time>12:31 pm</time> <predictions_in_ft>3.0</predictions_in_ft> <predictions_in_cm>91</predictions_in_cm> <highlow>l</highlow> </item> <item> <date>2016/01/01</date> <time>06:13 pm</time> <predictions_in_ft>6.6</predictions_in_ft> <predictions_in_cm>201</predictions_in_cm> <highlow>h</highlow> </item> what i'm trying preserve first instance of date, remove subsequent dates arrive @ this: <...

raspberry pi - Python 3 Artificial Intelligence: Offline STT and TTS -

so have been programming python awhile now. have made simple ai chatbots in python communicate via text. want move next level, kind of personal companion ai. goal put on raspberry(i have portable charger, microphone, , speaker compatible pi) , make offline ai talking to, taking notes, remembering info, etc. know way incorporate offline stt , tts engines python program. (most of stt , tts engines i've found online via google, amazon, etc.) in advance. i have check offline stt. tried run these below , see comments. you can @ them according purposes. online wit.ai https://wit.ai/ can used in commercial product. build brand-unique, natural language interactions bots, applications, services, , devices. https://api.ai/ https://docs.api.ai/docs/languages offline cmusphinx http://cmusphinx.sourceforge.net cmu sphinx speech recognition engines. cmu sphinx - speech recognition toolkit - offline speech recognition, due low resource requirements can used on mobil...

Stack multiple images in python pillow -

i trying image stacking in python pillow. take large number of images (say 10), , each pixel, take median value this: http://petapixel.com/2013/05/29/a-look-at-reducing-noise-in-photographs-using-median-blending/ . right now, can in incredibly brute force manner (using getpixel , put pixel), takes long time. here have far: import os pil import image files = os.listdir("./") new_im = image.new('rgb', (4000,3000)) ims={} in range(10,100): ims[i]={} im=image.open("./"+files[i]) x in range(400): ims[i][x]={} y in range(300): ims[i][x][y]=im.getpixel((x,y)) x in range(400): y in range(300): these1=[] these2=[] these3=[] in ims: these1.append(ims[i][x][y][0]) these2.append(ims[i][x][y][1]) these3.append(ims[i][x][y][2]) these1.sort() these2.sort() these3.sort() new_im.putpixel((x,y),(thes...

ios - How to transfer Provisioning Profile from one team to another? -

Image
when view accounts in xcode, saw 2 teams in apple id account: where can manage team of account such delete, add , etc? how can transfer provisioning profile free personal team agent team? how can delete provisioning profile in free team? thank you. assuming admin or user agent, go developer.apple.com , log member center. on first screen click "people" tab on top left. lets manage people on team. to best of knowledge can't transfer provisioning profiles. signed using specific developer's credentials. you'll need create new ones under paid developer account. again top level of developer's member center, click on "certificates, identifiers , profiles." there click on profiles under ios. if select individual profile there button @ bottom delete it.

group check box in php and send to email -

i using sample php conatct form http://www.html-form-guide.com/contact-form/php-contact-form-tutorial.html , want use check box in form , receiving last checked 1 in email. find out should use array check boxes like: input type="checkbox" name="chk_group[]" value="value1" />value 1<br /> input type="checkbox" name="chk_group[]" value="value2" />value 2<br /> input type="checkbox" name="chk_group[]" value="value3" />value 3<br /> and should use following loop in code: <?php if (isset($_post['chk_group'])) { $optionarray = $_post['chk_group']; ($i=0; $i'<'count($optionarray); $i++) { echo $optionarray[$i]."<br />"; } } ?> unfortunately tried because sample contact form using little bit strange me got errors. i appreciate if 1 can me solve problem. thanks remove single quotes around...

youtube - Constricting WebView in React Native to certain part of page -

Image
i attempting constrict webview of youtube urls show video (and not rest of youtube page). how do this? have figured out of props of webview gain deeper understanding of following props: automaticallyadjustcontentinsets bool contentinset {top: number, left: number, bottom: number, right: number} here have far: of course, don't want see youtube search tab - , change dimensions of webview so. how can better done? here code custom component of each video 'card': <touchablehighlight style={styles.touchcard} underlaycolor={'transparent'} onpress={this.props.onpress} > <view style={styles.card}> <webview scrollenabled={false} style={styles.videopreview} url={this.props.source} renderloading={this.renderloading} rendererror={this.rendererror} automaticallyadjustcontentinsets={false} /> ...

Are semicolons in JavaScript functions declarations ever necessary -

is ever necessary add semicolon @ end of function definition following function helloworld() { //some code }; //note semicolon here @ end ever necessary? ever i have friend swears optional. think never optional have never read being optional @ end of function. have never seen 1 ever "except him". semi colon optional. var hellworld = function (){ }; // semicolon here optional because defining variable ok , optional semicolons delimit expressions. can add amount of semicolons after one, since they'd delimiting empty statements. function() { // works. };;;;;;;;;;;;;;;;;;;;; that semicolon after function not "optional", it's plain redundant. as optional ones, because javascript add semicolons before newlines in situations 1 needed. these should write explicitly. you'll bitten lack of auto-semicolon sooner or later.

Eclipse IDE: Where is Android Remote Device Settings? -

i using up-to-date version of eclipse (and adt) , have not been able find add remote android device debugging. i'm hoping use youwave avd emulator slow on pc. in past i've been able add host , port of own choosing remote device though can no longer find this. any appreciated. you can't within eclipse. ive been working on plugin not ready yet. use command line. adb connect 192.168.1.5:5555 you see within eclipse.

jquery - Javascript "global" variable issue -

this question has answer here: javascript asynchronous return value / assignment jquery [duplicate] 2 answers var desc; $.ajax({ url: "data/step2.xml", datatype: "xml", success: function(data){ $(data).find('date').each(function(){ var day = $(this).find('day').text(); var date = $("#txtdate").datepicker("getdate"); date = (date.getdate()+"-"+date.getmonth()+1+"-"+date.getfullyear()); if (day==date){ $(this).find('availability').each(function(){ var prod = $(this).find('product').text(); var time = $(this).find('starttime').text(); if (prod==label){ ...

r - Summarising results of repeated hypothesis tests -

i generating 2 sets of data normal distributions using rnorm(30, 10, 5) . testing hypothesis means equal, using t.test , , repeating process 1000 times estimate type 1 error rate. my code follows: for(i in 1:1000) { print(t.test(rnorm(30, 10, 5), rnorm(30, 10, 5), alternative="two.sided", var.equal=true)$p.value < 0.05) } however, returns countless true , false . i can manually count true s, there easier way? they're not countless. there 1000 of them ;) instead of printing result screen, should keep track of in vector. a simple change want: sig <- logical(length=1000) for(i in 1:1000) { sig[i] <- t.test(rnorm(30, 10, 5), rnorm(30, 10, 5), alternative="two.sided", var.equal=true)$p.value < 0.05 } now can tabulate results: table(sig) ## sig ## false true ## 956 44 a simpler approach use replicate : table(replicate(1000, t.test(rnorm(30, 10, 5), rnorm(30, 10, 5), alternative...

ruby on rails - currency drop down -

i have 3 tables specified fields/columns in braces: country (name,currency_id) currency (name) user (name ,country_id,currency_id) and requirement while creating user selecting upon country, default currency need display first , remaining currencies displayed in next selection row. ex: if select usa in country drop down in currency drop down usd need display first , remaining currencies in next my idea user belongs country default currency country currency , has option select other currencies also. please me out please have @ blogpost. can populate next dropdown based on selected value first one, or change order of values. http://marcofranssen.nl/knockout-that-cascading-dropdown/

html - Full video background height of video is extending beyond 100%; -

video not 100% extending beyond 100% ? used absolute positioning video's height 110% instead of 100%? html, body { width: 100%; height: 100%; margin: 0; padding: 0; } section { width: 100%; height: 100%; } section video { position: absolute; top: 0; left: 0; min-width: 100%; min-height: 100%; } you need set max-width of video. can combine max-width , min-width width , same height. try code section video{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

Javascript setTimeout performance vs manual check -

i'm writing webgl game , curious if better performance wise implement game's events checking if should occur @ every update of requestanimationframe (using date.now() ) or setting timeouts (using settimeout() ). note events 100ms apart. my major concern settimeout not waste cpu when idle (waiting next event) , if check @ every update ill doing computations wouldn't happen if using settimeout if need events, create events , use eventlisteners. if need check @ every call of raf condition has changed perform action, checks in raf loop. note : don't need , should avoid creating new date object @ each call ; there timestamp passed argument of requested function through raf, use this. function update(timestamp){...}; requestanimationframe(update); using settimeout @ high rate make useless call timedout function pushed on top of stack of tasks perform. embedding checks @ top of raf loop good.

How do I convert column of unix epoch to Date in Apache spark DataFrame using Java? -

i have json data file contain 1 property [creationdate] unix epoc in "long" number type. apache spark dataframe schema below: root |-- creationdate : long (nullable = true) |-- id: long (nullable = true) |-- posttypeid: long (nullable = true) |-- tags: array (nullable = true) | |-- element: string (containsnull = true) |-- title: string (nullable = true) |-- viewcount: long (nullable = true) i groupby "creationdata_year" need "creationdate". what's easiest way kind of convert in dataframe using java? after checking spark dataframe api , sql function, come out below snippet: dateframe df = sqlcontext.read().json("my_json_data_file"); dataframe df_dateconverted = df.withcolumn("creationdt", from_unixtime(stackoverflow_tags.col("creationdate").divide(1000))); the reason why "creationdate" column divided "1000" cause timeunit different. orgin "creationdate" ...

java - Audio/FFT Library Design -

i have library records real time audio , computes real time fft data audio. client must call start method start recording, , stop method end recording. my design question concerning best way data client. have considered following approaches: have method called getdata(int size) client call periodically after have started recording. return size audio samples, or data available. thought client run asynctask periodically call more data. problems approach is less efficient, , more complicated client, allow them have more control on when , how data receive. have client pass in output stream start method send data have it. simpler more restrictive. similarly, instead of output stream, have client pass in sort of structure arraylist , shared between , push data onto. lastly, have thought having start method return output stream (or arraylist similarly) client read from. from client's point of view, prefer , why? or there other alternatives overlooking? input appreciated...

java - File Fetching from file directory rather than HTTP URL -

previously, code developed fetch file content http url " http://storage.googleapis.com/abc ". but, requirement has got changed , demands instead of using http url link, should need use file directory location of server. (i.e., /var/puru/abc ). so, there proper or significant way , fulfill requirement without much-doing changes existing code drastically? i have provided code sample here, provide file url(baseurl) using http url actually. private url getfileurl(string filename) throws malformedurlexception { try { date dateobj = dateformatter.parse(date); calendar cal = calendar.getinstance(); cal.settime(dateobj); return new url(baseurl, cal.get(calendar.year) + "/" + filename); } catch (parseexception e) { e.printstacktrace(); } return null; } please suggest, , guide me.

objective c - How to initialize NSMutableArray in iOS -

in app there huge number of array lists. that's why have added arrays in 1 main array list, , have initialized them using "for" loop. i getting error inside "for" loop: "fast enumeration variables can't modified in arc default". nsmutablearray * mainarray = [[nsmutablearray alloc] initwithobjects:namearray, idarray, masteridnamearray, masteridarray, nil]; (nsmutablearray * array in mainarray) { array = [[nsmutablearray alloc] init]; } yes, can not modify values of array in fast enumeration, i.e. for(x in array) . object x becomes constant , hence through warning. however can use for(int i=0; i<[mainarray count]; i++) loop achieve this. but, wait: why want initialize after adding array. this: //first create arrays have, //namearray //idarray //masteridnamearray //masteridnamearray //then add them in mainarray nsmutablearray *namearray = [nsmutablearray array]; nsmutablearray *idarray = [nsmutablearr...

asp.net mvc - Working on view with two forms on one controller in mvc 5 -

i have 1 drop down box. based on selected item of dropdownbox want generate form below on same view, please find code below. [httpget] public actionresult binddropdown() { viewbag.doctype = new selectlist(db.doctypemasters, "id", "doctypename"); return view(); } [httppost] public actionresult binddropdown(string doctype) { string doc = doctype.trim(); return view(); } this view code @model c3cardkyc.models.doctypemaster @{ viewbag.title = "binddropdown"; } <h2>binddropdown</h2> <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $('#myidandname').change(function () { var doctype = $("#my...

ios - Call function that throws and attempt to cast the returned value, abort silently if either fails -

i'm guard ing call method may throw (a coredata fetch request), , @ same time i'm casting returned value specific type of array: guard let results = try? managedcontext.executefetchrequest(fetchrequest) as? [mymanagedobjectclass] else { // bail out if fetch or cast fails: return } the way understand that, because i'm using guard/try?/else (instead of do/try/catch ), else block (i.e. return statement) above executed if either of following occurs: the fetch request fails (and throw s) the fetch request succeeds casting of returned value [mymanagedobjectclass] fails. the code above works, after control passes guard check, variable results ends being of type [mymanagedobjectclass]? (" optional array of mymanagedobjectclass "). so if want -say- loop through array elements i have first unwrap it: if let results = results { // now, 'results' of type: // "(non-optional) array of mymanagedobjectclass" ele...

vb.net - How can I allow to enlarge and shrink of a window only certain steps? -

i have windows form floating layout. in layout, there several elements of same size. form can free scaled @ moment. problem can rise large open space on right edge. i want ensure user can drag window size in steps. solution should work on both axles. thanks in advance

Angular 2 Difference between @view and @component template -

this question has answer here: angular 2.0. difference @view @component 4 answers in angular 2, i'm looking explanation on difference between @component ({ selector: 'test-component', template: '<div>hello world</div>' }) and @component ({ selector: 'test-component', }) @view ({ template: '<div>hello world</div>' }) i have tried creating 2 components 2 different approaches , both seem behave same. clarification helpful. i think should have @ question: angular 2.0. difference @view @component . in fact, it's same since view optional in future, able define several views same component. hope helps you, thierry

javascript - Ionic carousel resize issue with $http call -

i using plugin in ionic create carousel ( https://github.com/ksachdeva/angular-swiper ) has demo simple repeat. replaced repeat own using $http , has created problem in delay loading images causes slider break until resized. html looks this: <ks-swiper-container autoplay="500" initial-slide="1" speed="5000" loop="false" show-nav-buttons="false" slides-per-view="2" space-between="20" pagination-clickable="false" override-parameters="{effect: 'coverflow',coverflow: {rotate: 0,stretch: 0,depth: 100,modifier: 1,centeredslides: true,slideshadows : false}}" on-ready="onreadyswiper(swiper)"> <ks-swiper-slide class="swiper-slide" ng-repeat="feature in featured track feature.id"> <img imageonload="" ng-src="{{feature.thumbnail_images.thumbnail.url}}" width="100%"> <h6 ...

Hyperlinks sent tp @Facebook.com accounts changed to broken fbsbx.com redirect links -

almost hyperlink in email sent @facebook.com address broken fbsbx.com redirect link. if change fbsbx.com in link facebook.com, link works, it's domain. example, when email myself link: http://news.cnet.com/8301-17938_105-57504786-1/the-weird-world-where-3d-printing-and-art-collide/ when click through incoming facebook message it's become: http://fbsbx.com/l.php?u=http%3a%2f%2fnews.cnet.com%2f8301-17938_105-57504786-1%2fthe-weird-world-where-3d-printing-and-art-collide%2f&h=raqeqccgn&s=1 takes me "not found" page. so far haven't been able find work-around. this problem me given emergency apps allows people notify friends or emergencies via facebook message. facebook messages contain links live session, facebook breaking links. send links sending them @facebook.com emails. messages through, links broken. fixing crucial app.

sed language translation script - improving efficiency for long texts -

here's issue. i'm spanish translator, , have lengthy spanish-english glossary file -- 50k entries. additionally, have stop-word glossary of on 1k entries. want strip these entries texts plan translate. so, built sed script that, in turn, builds 2 more sed scripts glossaries, stripping, , leave me untranslated text (so don't have solve same problem twice). works well, problem takes long time on long texts, upwards of 15 minutes. inevitable, or there more efficient way this? here's main script: #!/bin/sh before="$(date +%s)" #wordstxt=$(wc -w < $1) #mintime=$(expr "$wordstxt / 200" |bc -l) #maxtime=$(expr "$wordstxt / 175" |bc -l) #echo "estimated time process: between $mintime , $maxtime seconds." sed ' s/\,/\n/g # strip commas s/\?/\n/g # strip question marks s/\*/\n/g # strip asterisks s/\!/\n/g # strip exclamation marks s/:/\n/g # strip colons s/\-/\n/g # strip...

c\c++ - Functions with unions as arguments to meet specific requirements -

i'm engineering library provide functionality 1 device. device has common operations different algorithms accomplish these operations. want 1 function prototype 1 particular operation, not bunch of them, instead of: alg1_foo(); alg2_foo(); ... i want this: foo(alg); but don't want pass alg separate argument, because functions have lot of arguments without it, have arguments identification and/or authorization of device, in argument, out argument (at least 1 of them), think annoying add alg separate argument. so idea provide solution one: foo(const someunion& some_union); where: union someunion { algid alg_id; alg1::somestruct alg1_some_struct; alg2::somestruct alg2_some_struct; someunion(alg1::somestruct some_struct) { alg1_some_struct = some_struct; }; someunion(alg2::somestruct some_struct) { alg2_some_struct = some_struct; }; }; and structures of particular algorithms this: namespace alg1 { struct somestruct { static const algid a...

r - GoogleVis garbled characters output -

Image
my ggvis outputs have garbled characters. imagine there mismatch between encoding settings of system (windows 7 -windows iso8859-1 (i live in western europe) , encoding of gvis page (utf-8, firefox or chrome). i tried change language preferences of r -studio (system -> utf8) without success. have idea? r version 3.2.2 (2015-08-14) platform: i386-w64-mingw32/i386 (32-bit) running under: windows 7 x64 (build 7601) service pack 1 locale: [1] lc_collate=french_france.1252 lc_ctype=french_france.1252 you need setup system locale. windows needs done this: sys.setlocale("lc_ctype","en_gb.utf-8")

amazon web services - Can bash script be written inside a AWS Lambda function -

can write bash script inside lambda function? read in aws docs can execute code written in python, nodejs , java 8. it mentioned in documents might possible use bash there no concrete evidence supporting or example something might help, i'm using node call bash script. uploaded script , nodejs file in zip lambda, using following code handler. exports.myhandler = function(event, context,callback) { const execfile = require('child_process').execfile; const child = execfile('./test.sh', (error, stdout, stderr) => { if (error) { callback(error); } callback(null,stdout); }); } you can use callback return data need.

plsql - Dynamically use select into statement -

what wrong following function? create or replace function getnamebyid(myid in number) return number query varchar2(500); myname varchar2(20); begin query :='select users_name :myname users_table users_id = :myid'; execute immediate query using out myname, myid; dbms_output.put_line(myname); return(myname); end getnamebyid; if instead of query use: select users_name myname users_table users_id = 81; the execution succeeds the problem when add " :myname " error @ execution.. is not possible use while doing dynamic sql? edit: solved! create or replace function getnamebyid(myid in number) return varchar2 query varchar2(500); myname users_table.users_name%type; begin query :='select users_name users_table users_id = :myid'; execute immediate query myname using myid; dbms_output.put_line(myname); return(myname); end getnamebyid; you cannot bind table names in oracle dynamic sql. need put table name...

Android listview infinite scrolling using Retrofit -

i need current project. requirement make listview paginated , load other data when scrolled down facebook , twitter apps do. this i've tried far: mainactivity listview.setonscrolllistener(new infinitescrolllistener() { public boolean onloadmore(int page, int totalitemscount) { // triggered when new data needs appended list // add whatever code needed append new items adapterview customloadmoredatafromapi(page); // or customloadmoredatafromapi(totalitemscount); return true; // if more data being loaded; false otherwise. } }); private void getdata() { if(connectiondetector.hasnetworkconnection(getactivity())) { restadapter restadapter = new restadapter.builder() .setendpoint(home_domain) .setloglevel(restadapter.loglevel.full) .build(); webservices service = restadapter.create(webservices.class); service.getrecords(...