Posts

Showing posts from February, 2012

ios - Some emojis has a length of 3? (digits) -

i trying implement way of counting number of emojis in nsstring . have found way works emojis, struggling emojis, seems defined in different way others. for example hot beverage icon has unicode hex of u+2615 (codepoint 9749), zero digit has unicode hex of u+0030 u+20e3 (codepoint 3154147). i using nsstring category determine number of emojis: @implementation nsstring (emojis) - (bool)isemoji { const unichar high = [self characteratindex: 0]; // surrogate pair (u+1d000-1f77f) if (0xd800 <= high && high <= 0xdbff) { const unichar low = [self characteratindex: 1]; const int codepoint = ((high - 0xd800) * 0x400) + (low - 0xdc00) + 0x10000; return (0x1d000 <= codepoint && codepoint <= 0x1f77f); } else // not surrogate pair (u+2100-27bf) { return (0x2100 <= high && high <= 0x27bf); } } - (nsuinteger)numbersofemojis { nsuinteger __block emojicount = 0; [self en

python requests: easy way to replace http get request argument? -

i have http request so: url = 'www.somedomain.com/content?var=whatever&pageno=1' r = requests.get(url) i'd replace pageno=1 pageno=2 , requests humans, couldn't figure out how without parsing query pyhton dictionary using urlparse , change corresponding value, urllib.urlencode new query. notice i know can re.sub() , solve problem in 2 or 3 lines, think there must 'pythonic way'. i've been using scrapy in past few months , got nice request.replace method this, think i'm gonna suggest feature requests . you can utilize params argument of get() method. functionality described in quick start >>> payload = {'var': 'whatever', 'pageno': '1'} >>> r = requests.get("http://www.somedomain.com/content", params=payload) >>> print(r.url) http://www.somedomain.com/content?var=whatever&pageno=1 using method of passing parameters, can manipulate payload dicti

r - PerformanceAnalytics Numbers to Percent % -

i want know if possible make table output in r package % instead of numeric. table.annualizedreturns(indover, rf=0) sp500 annualized return 0.0732 annualized std dev 0.1951 annualized sharpe (rf=0%) 0.3752 so 1st 1 0.0732 see 0.07% the return value function data frame, question how make column of data frame print percentage sign. reproducible example follows. > require(performanceanalytics) > data(managers) > tb = table.annualizedreturns(managers[,1],rf=0) > tb ham1 annualized return 0.1375 annualized std dev 0.0888 annualized sharpe (rf=0%) 1.5491 now define new class , format function displays percent sign: > format.pc = function(x,...){sprintf('%0.2f%%',x)} > class(tb[,1])="pc" and now, if magic: > tb ham1 annualized return 0.14% annualized std dev 0.09% annualized sharpe (rf=0%) 1.55

How can i change background color in a while loop - processing -

i'm new processing , trying make simple program have arduino produces seriel input (according analogue read value). idea processing window open block color shown 30 seconds. in time readings arduino summed , averaged - creating average color. after 30 seconds colour change , new average (for next color) start being calculated. code have started write (for focusing on 1 30 second period of green). i realise there problems reading/summing , averaging (i havent researched these yet i'll put 1 side) - main question why isn't background green? when run program expect background green 30 seconds - happens is white 30 seconds changes green. can't figure out why! help! import processing.serial.*; serial myport; float gsraverage; float greenaverage; int gsrvalue; int greentotal = 0; int greencount = 1; int timesincestart = 0; int timeatstart; int count=0; color green = color(118,236,0); void setup () { size(900, 450); // list available serial ports //print

node.js - Insert Multiple records in nodejs in single Query -

i inserting dynamic records var sql = "insert test (name, email, n) values ?"; var values = [ ['test', 'demian@gmail.com', 1], ['test', 'john@gmail.com', 2], ['mark', 'mark@gmail.com', 3], ['pete', 'pete@gmail.com', 4] ]; conn.query(sql, [values], function(err) { if (err) throw err; conn.end(); }); here example working fine now data here var arr = category_ids.split(","); (var = 0; < arr.length; i++) { } how make dynamic array of values in loop thanks you need array of arrays, values in example provided. your example var arr = category_ids.split(","); var values = [ arr ]; or var value = [ category_ids.split(",") ];

php - How to display sundays in a month? -

i have been trying answer question , after r&d have come solution too $begin = new datetime('2014-11-01'); $end = new datetime('2014-11-30'); $end = $end->modify('+1 day'); $interval = new dateinterval('p1d'); $daterange = new dateperiod($begin, $interval, $end); foreach ($daterange $date) { $sunday = date('w', strtotime($date->format("y-m-d"))); if ($sunday == 0) { echo $date->format("y-m-d") . "<br>"; } else { echo''; } } try way: $begin = new datetime('2014-11-01'); $end = new datetime('2014-11-30'); while ($begin <= $end) // loop work begin end date { if($begin->format("d") == "sun") //check day sunday here { echo $begin->format("y-m-d") . "<br>"; } $begin->modify('+1 day'); }

What is the Big Oh of these two implementations of the same algorithm? -

i writing algorithm return true if string contains no duplicate characters, , false otherwise. have 2 different implementations: the first uses hashmap: public static boolean hasuniquecharsfast(string s) { char[] input = s.tochararray(); map<character, character> map = new hashmap<character, character>(); (char c: input) { if (map.get(c) != null) { return false; } else { map.put(c, c); } } return true; } the second in-place , compares each character every other character: public static boolean hasuniquechars(string s) { char[] input = s.tochararray(); //compare string (i.e. ignore chars @ same index) (int i=0;i<input.length;i++) { (int j=0;j<input.length;j++) { if (input[i] == input[j] && != j ) { return false; } } } return true; } is correct big oh of first imp

javascript - Get value of form text field with without submitting the form -

i have form on page , want able submit text box value (partnumber) query string in hyperlink without submitting form ? possible ? have done research , have tried document.getelementbyid("partnumber").value getting error "object required". code below. <form id="form3" name="form3" method="post" action="formpost?rmaid=<%=rmaid%>"> <input name="partnumber" type="text" id="partnumber" size="10" /> <a href="suggest.asp?partnumber=<%document.getelementbyid("partnumber").value%>"><span class="style11">suggest link</span></a> <input name="invoice" type="text" id="invoice" size="15" /> </form> i'll set new page open in pop window , list series of values in database need value selected come invoice field on original page. believe can done javascript new

php - Issues wih the Twitter API -

ok have been signing in twitter through api using php awhile. today have had nothing issues in getting connection! has changed twitter api??? twitter has been having issues. yesterday making twitter requests search , getting 1 less result asked for. &count=6 i'd receive 5 , of course other number. woke morning find had right number of results back.

arrays - Memory space consumption -

is there situation memory space taken linked list pointers more memory consumed array same problem if problem can solved both structures? a linked list dynamically sized data, inserts , removes. typically on heap. comparing array mean array uses strategy being oversized unused entries inserts, , being reallocated if arrays threatens overflow. so depends on actual array strategy , behavior of program, knowledge of it. however every entry actual data needs space too, maybe pointer , allocated object. @ linked-list overhead form of indexing, in database. memory more or less irrelevant. one should aware, instance linked list of booleans not clever.

javascript - How to remove "http://" from domain name inside view -

how can remove "http://" beginning of url inside view in angularjs app? i have urls in database like: http://example.com/ http://example.com example.com but need show example.com inside view. this deals http , https or other url. uses built-in url class, handle of things haven't thought of correctly. app.filter('domain', function () { return function (input) { try { var url = new url(input); return url.hostname; } catch (domexception) { // malformed url. return original (or else). return input; } }; }); urls correct , might not have thought of: http://example.com http://example.com:8000 http://me@example.com file://example.com https://example.com http://example.com/some-path http://example.com?some-query-url you may not need them now, using correct library function means app won't break unexpectedly in future when tries use else.

ios - Splash Screen Video is not playing -

i'm using video splash screen not playing,it shows black screen,here code self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; nsstring* moviepath = [[nsbundle mainbundle] pathforresource:@"hello" oftype:@"mp4"]; nsurl* movieurl = [nsurl fileurlwithpath:moviepath]; playerctrl = [[mpmovieplayercontroller alloc] initwithcontenturl:movieurl]; playerctrl.scalingmode = mpmoviescalingmodefill; playerctrl.controlstyle = mpmoviecontrolstylenone; playerctrl.view.autoresizingmask =uiviewautoresizingflexibleheight; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(movieplaybackdidfinish) name:mpmovieplayerplaybackdidfinishnotification object:nil]; [self.window addsubview:playerctrl.view]; [playerctrl play]; can try setting player view frame window bounds?

c - socket connect() vs bind() -

Image
both connect() , bind() system calls 'associate' socket file descriptor address (typically ip/port combination). prototypes like:- int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); and int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); what exact difference between 2 calls? when should 1 use connect() , when bind() ? specifically, in sample server client codes, found client using connect() , server using bind() call. reason not clear me. to make understanding better , lets find out bind , connect comes picture, further positioning of 2 calls , clarified sourav, bind() associates socket local address [that's why server side binds, clients can use address connect server.] connect() used connect remote [server] address, that's why client side, connect [read as: connect server] used. we cannot use them interchangeably (even when have client/server on same machine) becaus

Can I call a spreadsheet function from a custom function in SpreadsheetGear -

i using spreadsheetgear , have been given spreadsheet vba macro need convert custom function (as ssg can't handle vba code). macro calls excel functions (match, index) , can't see how call these functions within custom function. ideas if possible , how it? thanks you can evaluate excel formula strings using isheet. evaluatevalue (...) method. example: // a1:a3 on "sheet1" summed up. object val = workbook.worksheets["sheet1"].evaluatevalue("sum(a1:a3)"); // ensure numeric value if(val != null && val double) { double sum = (double)val; console.writeline(sum); } however, sounds using method inside custom function, should point out cannot use method sheet belongs workbook in iworkbookset being calculated. please review rules laid out in remarks section function. evaluate (...) method, pasted below, particularly ones bolded: the implementation of method must follow number of rules: the method must thread safe

if statement - error in if() argument is of length zero in R -

this code ` region<-"arlington" data<-read.csv("city_markets.csv") for(i in 1:length(data[[1]])){ if(grep(region,as.character(data[[3]][i]),ignore.case=true)==1){ for(j in 1:length(data)){ write(data[[j]][i],"analyzed.txt",append=true) } } } ` now i'm trying here i'm accessing csv's column(3rd one) , comparing region specified! keep getting error error in if (grep(region, as.character(data[[3]][i]), ignore.case = true) == : argument of length zero to detail bit comment , @adii_ 's : when use grep , result "position" of elements fulfill condition... "nothing" if there no match (hence error message). using grepl , you'll true or false, can use in if statement. as length(grep(...)) , result 0 if there no match, corresponding false if statement, or positive integer ( 1 in case because you're testing 1 element), if there match, c

Polymorphism Python -

i learning python , have question . after running code ,the result displayed "name bob , salary is50000 , work main.pizzarobot object @ 0x00000000028eecc0>>" i want "work" displayed each object in str rather calling obj.work() each object . in problem output should "name bob , salary is50000 , work bob makes pizza" thanks class employee(): def __init__(self,name,salary = 0): self.name = name self.salary = salary def giveraise(self,percent): self.salary = self.salary + self.salary * percent def __str__(self): return "name {0} , salary is{1} , work {2}".format(self.name,self.salary,self.work) def work(self): print(self.name ,"does stuff") class chef(employee): def __init__(self,name): employee.__init__(self,name,50000) def work(self): print(self.name ,"makes food") class pizzarobot(chef): def __init__(self,name):

java - App connects to the server but can not communicate -

i apologize in advance bad english the app able connect server java, hangs @ time of exchange of data. this client android code: @suppresslint("newapi") public class connection extends intentservice{ private string tag = "ciclo eventi"; private string user; private string pass; public connection() { super("connection"); } public void oncreate(){ super.oncreate(); strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build(); strictmode.setthreadpolicy(policy); } public void onstart(intent intent, int startid){ log.d(tag, "getdata"); bundle extras = intent.getextras(); user = (string) extras.get("user"); pass = (string) extras.get("password"); log.d(tag, user); log.d(tag, pass); onhandleintent(intent); } public int onstartcommand(intent intent, int flags, int startid){ onhandleintent(intent); return start_not_sticky; } @overr

android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams -

following numerous tutorials , example projects i've arrived @ following code should fill listview rows contain multiple values out of line object. being newbie programmer cannot life of me figure out hell code fails. appreciated! if left out important information please tell me , update question. the code starts inside fragment: @override public void onactivitycreated(bundle savedinstancestate){ super.onactivitycreated(savedinstancestate); intent = getactivity().getintent(); if (i.getserializableextra("chosenworkorder") != null){ workorder selectedworkorder = (workorder) i.getserializableextra("chosenworkorder"); articleslistadapter articleslistadapter = new articleslistadapter(getactivity(), r.layout.articles_list_row, selectedworkorder.getalllines()); listview articleslist = (listview) getactivity().findviewbyid(r.id.articleslist); articleslist.seta

osx - Why kexts are loaded by Boot Loader but not after Kernel gets the control -

i new hackintosh , studying boot process. as far know: efi binary "byte-code" uefi firmware runs kexts kernel mode device driver complied in machine specific code, loaded kernel, running in kernel mode kernel kexts injection dynamic loading of library in kernel mode my question is, why there relationship bootloader chameleon/clover , kexts? kexts should loaded kernel not bootloader, right? i see thing here. http://cloverboot.weebly.com/kexts.html?bcsi_scan_50b5cc4d2c82cc03=bg/x91fwptz2cvnl0wdfpvjdtdwsaaaaiomalg==&bcsi_scan_filename=kexts.html say hackintosh needs fakesmc.kext. not business of bootloader. bootloader needs put init code of mac os kernel in memory , passes control it. , should mac os kernel loads fakesmc.kext. isn't it? firstly pcs in past had legacy bios , no efi, apple never used legacy bios, efi. but has changed of modern pcs have builtin uefi there no need emulate efi. there 2 ways boot os x on hackintosh legacy bios

objective c - iOS how to draw text in a UILabel using a non standard alignment -

Image
this question has answer here: superscript cents in attributed string 1 answer i want put numbers in label alignment in image. none of label's alignment modes me. the decimal digits should above centre line , between top margin. other digits should aligned in regular fashion. don't know "professional" name thing or sort of api can help. can point me in direction or have example snippet? thanks use below code. have done using nsmutableattributedstring . nsstring *str = @"$899.00"; nsmutableattributedstring *attrstring = [nsmutableattributedstring new]; nsmutableattributedstring *attrsuperscript = [[nsmutableattributedstring alloc] initwithstring:str]; [attrsuperscript addattribute:(nsstring*)kctsuperscriptattributename value:@"-1" range:nsmakerange(0, [str length] - 3)]; [attrsuperscript addattribute:nsfonta

json - Test datatype on postgresql update trigger -

i use trigger detect if @ least 1 value has changed when update performed on table. the function : create or replace function update_version_column() returns trigger $body$ begin if row(new.*) distinct row(old.*) new.version = now(); return new; else return old; end if; end; $body$ language plpgsql volatile cost 100; alter function update_version_column() owner gamesplateform; the problem is, when column type "json", "is distinct" failed (standard comportement, explained in documentation). i search way perform same thing, if column in "json" type, want force "jsonb" cast accept comparison operator. is there way ? thanks ! found way : create or replace function update_version_column() returns trigger $body$ declare updated boolean := false; column_data record; begin column_data in select column_name::varchar, data_type::varchar

Java PrintWriter: Why do we handle FileNotFoundException if the file is automatically created if not found? -

in following sscce, not filenotfoundexception if delete file given location/path i.e. "d:\\eclipse workspaces\\samples , other snippets\\soapcallresults.txt" rather printwriter seems create file if not found. if printwriter creates file if not found, why try handle filenotfoundexception (compiler complains if don't surround try/catch or add throws clause) when never going thrown? package com.general_tests; import java.io.filenotfoundexception; import java.io.printwriter; public class printwriterfilenotfoundexceptiontest { public static void main(string[] args) { string myname = "what ever name is!"; printwriter printwriter = null; try { printwriter = new printwriter("d:\\eclipse workspaces\\samples , other snippets\\soapcallresults.txt"); printwriter.println(myname); } catch (filenotfoundexception e) { system.out.println("file not found exception!");

php - Removing data from database according with what user selects -

hy, i have form data passed php script , in conjunction user selection php processes query. instead of validating query in relation input stops @ first condition , not evaluates rest. bellow script $username=$_post['user']; $userid=$_post['id']; $studentname=$_post['studentname']; $studentsurname=$_post['studentsurname']; if(count($_post)>0){ if(isset($userid)){ echo 'var num'.$userid; $sql="delete user user_id=$userid"; $result=mysqli_query($conn,$sql); if(! $result ) { die('could not delete data: '.mysqli_error()); } echo "deleted data successfully\n"; /*or die('error'.mysqli_error); echo 'student deleted';*/ } else if(isset($username)){ echo 'var num'.$userid; $sql="delete user user_name='$username'"; $result=mysqli_query($conn,$sql); if(! $result ) { die('could not delete data: '.mysqli_error()); } echo "deleted data successfully\n&quo

three.js strange behaviour on transparent materials -

Image
am working three.js , created scene house , have lots of door/windows on wall , , inside rooms there living things chairs, sofas , on, of them seperate mesh , combined single house object , got neraly expecting , facing issue on materials having walls i have attached 2 image illustare problem, here explain getting pic 1: model looks nice long shot of camera, can see wall attached doors/windows inside room can see sofas pic 2: while room attached doors/windows on wall, other side wall disappeared looks transparent , can see doors/windows on wall am not sure wrong wall and code follows: function wall_fill(type,no_of_walls,wall_no,inner_filltype,inner_fill,outer_filltype,outer_fill,left_filltype,left_fill,right_filltype,right_fill,top_filltype,top_fill,bottom_filltype,bottom_fill,front_filltype,front_fill,back_filltype,back_fill) { var materials,inner_material,outer_material,left_material,right_material,top_material,bottom_material,front_material,ba

java - JavaFX 2 Window Icon not working -

i'm trying add icon javafx 2 application, ways have found don't seem work. image icon = new image(getclass().getresourceasstream("/images/icon.png")); stage.geticons().add(icon); the icon 32x32 in size. when try image icon = new image("http://goo.gl/kyeql"); it work, in netbeans , in runnable jar. i hope can fixed. the problem in icon itself. did load should, reason didn't display should. i remade icon trying use different sizes (16x16 512x512) , added them icon list. stage.geticons().add(new image(getclass().getresourceasstream("/images/logo_16.png"))); stage.geticons().add(new image(getclass().getresourceasstream("/images/logo_32.png"))); stage.geticons().add(new image(getclass().getresourceasstream("/images/logo_64.png"))); stage.geticons().add(new image(getclass().getresourceasstream("/images/logo_128.png"))); stage.geticons().add(new image(getclass().getresourceasstream("/imag

go - How to read a file line by line and return how many bytes have been read? -

the case : i want read log "tail -f" *nix when kill program can know how many bytes have read,and can use seek when program start again,will continue read log line line depend seek data in step 2 i want bytes when use bufio.newscanner line reader read line eg: import ... func main() { f, err := os.open("111.txt") if err != nil { log.fatal(err) } f.seek(0,os.seek_set) scan := bufio.newscanner(f) scan.scan() { log.printf(scan.text()) //what want how many bytes @ time when read line }//this program read line } thx! ==================================update========================================== @twotwotwo close want,but want change io.reader io.readerat , , want,i write demo use io.reader :` import ( "os" "log" "io" ) type reader struct { reader io.reader count int } func (r *reader) read(b []byte) (int, error) { n, err := r.reader

sql - MySQL; Return most frequent occurrence(s) where there may be more than one -

i have table student ids (sid) , classes (ccode) they're taking. i'm trying retrieve student ids of student(s) taking highest number of classes, query needs allow fact there might tie. i know highest number of occurrences of same sid indicate the 1 i'm looking if looking retrieve top record i'd go mysql> select sid, count(sid) numberofclasses -> student_classes -> group sid -> order numberofclasses desc -> limit 1; +------+-----------------+ | sid | numberofclasses | +------+-----------------+ | 2040 | 3 | +------+-----------------+ i've tried mysql> select sid, count(sid) numberofclasses -> student_classes -> group sid -> having numofclasses=3; +------+-----------------+ | sid | numberofclasses | +------+-----------------+ | 2040 | 3 | | 3040 | 3 | +------+-----------------+ which works because know value of highest number of projects working on 3, need way of putting max() funct

Unable to instantiate an object of XSSFWorkbook in Java servlet -

i'm trying work xssfworkbook in web application. ran sample application xssfworkbook plain java program (with public static void main(string args[]) ) - runs fine - excel sheet generated. however, when run same piece of code in java based web application - instance of xssfworkbook not instantiated. no exception thrown either! please help! the below code works fine me public void trackeruploadlistener(fileuploadevent event) throws exception { uploadedfile tracker = event.getuploadedfile(); xssfworkbook wb = null; inputstream stream = tracker.getinputstream(); wb = new xssfworkbook(stream); } here, listener called xhtml page.

java - pager Cannot resolved as a variable -

i'm trying make action bar tabs, got error:"pager cannot resolved variable..." thansk help. java code; package olcay.akgn.fibonaccicalculator; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbar; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; import android.support.v4.view.viewpager; import android.app.actionbar.tab; import android.app.actionbar.tablistener; import android.app.fragmenttransaction; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.os.build; public class mainactivity extends actionbaractivity implements tablistener { android.app.actionbar actionbar; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate);

spring - Elasticsearch camel end Point -

please let me know how create consumer elastic search endpoint using camel. consumer code i want create custom elasticsearch consumer code producer available elasticsearchproducer . consumer throwing exception.i want create own consumer component consumer code throwing exception , not consuming thing. public org.apache.camel.consumer createconsumer(org.apache.camel.processor processor) throws exception throws: exception thanks in advance help... :-) camel elasticsearch component not support consumer. how ever if query elasticsearch id, can follows string json = template.requestbody("elasticsearch://local?operation=get_by_id&indexname=twitter&indextype=tweet", "id"); if requirement else, have create own component.

javascript - get specific value from json file by Id -

im using $.get json file content working fine,currently want filter , item id 4 (the last one) ,how should ? in jquery doc didn't find hint it... http://api.jquery.com/jquery.get/ this code: $.get('tweets.json'); this json file content [ { "id": 1, "tweet": "omg, worst day ever, bf @bobbyboo dumped me", "usersmentioned": [ { "id": 10, "username": "bobbyboo" } ] }, { "id": 2, "tweet": "omg, best day ever, bf came me" }, { "id": 3, "tweet": "omg, worst day ever, don't ask" }, { "id": 4, "tweet": "@bobbyboo omg...just omg!", "usersmentioned": [ { "id": 10, "username": "bobbyboo" } ] } ] update currenlty when try following dont anthing in then(function (tweets) ,t

jquery - maintain image position while scaling video -

i have few see-through click elements on video.. when changing aspect ratio of browser positioning of elements messes causes click action not happen when click on animation. i use % reason still doesn't position correctly on multiple screen sizes. css: #vidklik1{ width: 8%; height: 30%; top: 148%; left: 16%; } html: <div class="popup"> <video preload="auto" autoplay="autoplay" loop="loop" id="background2"> <source src="background/background2.mp4" type="video/mp4"> </source> <source src="background/background2.ogv" type="video/ogg"> </source> <source src="background/background2.webm" type="video/webm"> </source> </video> <a href="#popup-box" class="popup-window"> <img src="images/k

Using the HTML5 <video> tag, the video plays when the image is clicked in iOS 7 and below, but in iOS 8.1 it plays when the app starts -

i implementing video feature in application using html5 <video> tag. want video play when image clicked. it's working in versions ios 7, in ios 8.1, video starts playing automatically after app initialization i implemented following way: <div style="margin-top:40px;"> <img src="images/play-video-screen.jpg" onclick="video()" value="loading video...." /> </div> <div> <video controls autoplay="true" id="welcomevideo" src="video.mp4" style="display:none;width:2px"> <source type="video/mp4" > </video> </div> <script> function video() { document.getelementbyid('welcomevideo').style.display="block"; var videoel = document.getelementsbytagname('video')[0]; var sourceel = videoel.getelementsbytagname('source')[0]; sourceel.src = 'v