Posts

Showing posts from 2014

php - Is this a valid setup for Websockets and JWT -

i'm trying create programming exercise setting simple push notification system. i'm not sure have right, , honest can't why other feels wrong. on paper, seems should work this: client requests page web server flag token. if token exists in database , isn't expired (using "expired at" timestamp), return otherwise generate new one. generate them using php's openssl_random_pseudo_bytes method. once response returned client, check if websocket , close if 1 exists. open new 1 token. at future time when event occurs, post request sent websocket server web server containing token destination user , message. if websocket server has active connection matching user's token, send message if not discard it. inform web server if successful or not. if unsuccessful, web server create notification on user's next login, message. is sufficient simple? there i'm missing, there potential problems? said, exercise if tried implement in production envir...

c# - NHibernate snchronize CrossRefrenced Properties -

i'm using nhibernate orm mapper. have 2 classes, classa , classb. classa has property of type classb , classb has property of type classa! these should backed 1 database column! , if fill property on 1 of classes, other should filled! possible nhibernate? mapping of classa references(x => x.classb, "classbid").cascade.saveupdate().unique(); mapping of classb hasone(x => x.classa).propertyref(x => x.classb).cascade.saveupdate(); what want is, classes synchronized, without reloading!

How to set font family with javascript ONLY- no access to jquery, html, or css, only js -

i building print products efi digital storefront using directsmile, variable data program plugs in indesign , digital storefront. complex formatting of variable data fields can done within directsmile javascript. i can add javascript formatting, there no css or html can work in conjunction js. add snippet of js variable data field, save , export file, , upload digital storefront. javascript > variable data field > directsmile document > zipped product > digital storefront right working on business card. displays phone numbers this: office 123.456.7890 cell 123.456.7890 fax 123.456.7890 where words office, cell, , fax supposed in 1 font (8pt archer bold) , numbers supposed in (8pt graphik light). needs defined in javascript don't know how. i'm new this, , research isn't panning out- every method i've found seems require access html/css, don't have. this javascript i've used in past format phone numbers preceding labels ("office...

batch file - SQL Server agent for scheduling SFTP using WinSCP under SSIS -

i have batch script generates winscp upload script upload file sftp location. when run batch file via command prompt - runs , loads it. called same thru ssis execute process task - runs , loads it. when put same on sql agent - tried following 2 options: using operating system (cmdexec) - cmd.exe /c "\.bat" added ssis package ssisdb , added job step. with both above options job showed successful run. file not uploaded! ideas on happening? here's batch script: echo off set winscp=c:\"program files (x86)"\winscp\winscp.com set stagingdirectory=\\<staging path>\ set scriptpath=\\<scriptpath>\uploadscript.txt set ftphost=xx.xx.xx.xx set ftpuser=user set ftppass=password set filename=test.xlsx set ftpflags= @rem ftpflags: -explicit echo deleting uploadscript if exists if exist %scriptpath% del /f %scriptpath% if exist %scriptpath% exit 1 echo generating winscp upload script >>%scriptpath% echo option batch abort >>%scriptpat...

ios - Create UIImage of whole UICollectionView content -

i have uicollectionview. no caching haven't needed apply far, have sum of 7 different images, possibly 40 cells. not experienced in method. -(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { uicollectionviewcell *cell=[collectionview dequeuereusablecellwithreuseidentifier:@"cell" forindexpath:indexpath]; uiimageview *collectionimageview = (uiimageview *)[cell viewwithtag:102]; uilabel *balllabel = (uilabel *)[cell viewwithtag:103]; uilabel *balllabelinfo = (uilabel *)[cell viewwithtag:110]; ballshot *selectedball = [self.statsview.visitballshotcollection objectatindex:indexpath.row]; nsstring *balldetail; nsstring *labelinfo; balldetail = [nsstring stringwithformat:@"foul"]; labelinfo = [nsstring stringwithformat:@"%@",[selectedball getfoultypetext:selectedball.foulid]]; collectionimageview.image = [uiimage imagenamed:selectedball.imagenamelarge]; balllabel.text =...

javascript - Run PHP script in background using jQuery -

so have php takes time runs in background. want code "command executed. invites pending." - , user see end. else in .php script done in background. i thinking somehow executing jquery , have stop loading script mid-execute of post. , use ignore_user_abort() here jquery code plan on using: jquery.ajax({ type: 'post', data: { ' mypostdata'}, datatype: 'html', url: 'myphp.php', success: function (d) { /* commands */ } }); the thing i'm missing having stop call after it's called upon, , need append div saying "invites pending." almost identical jquery's site example: alert( "initializing..." ); var jqxhr = $.post( "myphp.php", function(data) { alert( "working..." ); }) .done(function() { alert( "finished!" ); }) .fail(function() { alert( "error!!" ); }) });

python - Sqlalchemy searching dates -

i'm trying search between 2 dates sqlalchemy. if used static dates way. def secondexercise(): instance in session.query(puppy.name, puppy.weight, puppy.dateofbirth).\ filter(puppy.dateofbirth <= '2015-08-31', puppy.dateofbirth >= '2015-02-25' ).order_by(desc("dateofbirth")): print instance manipulating dates in python quite easy. today = date.today().strftime("%y/%m/%d") sixthmonth = date(date.today().year, date.today().month-6,date.today().day).strftime("%y/%m/%d") the problem is, don't know how implement parameter. this? for instance in session.query(puppy.name, puppy.weight, puppy.dateofbirth).\ filter(puppy.dateofbirth <= today, puppy.dateofbirth >= sixthmonth ).order_by(desc("dateofbirth")): sqlalchemy supports comparison datetime.date() , datetime.datetime() objects. http://docs.sqlalchemy.org/en/rel_1_0/core/type_basics.html?highlight=datetime#sqlalchemy...

hibernate - Bypass managed entities or not on JPA -

why jpa entitymanager execute mutable query e.g. update against db directly, choose execute select query first against persistence context (aka second-level cache) below (tested hibernate 5 )? it doesn't seem jpa spec has prescribed so. gain better performance @ risk of inconsistency? /* ... */ string name = em.find(person.class, 1).getname(); em.gettransaction().begin(); em.createquery("update person set name='new' id=1") .executeupdate(); em.gettransaction().commit(); // db updated entity not person p = em .createquery("select p person p id=1", person.class) .getsingleresult(); // stale entity returned assertequal(name, p.getname()); // true probably performance reasons, if jpql query matches entity loaded in entity manager in memory, specification does not require refresh entity in memory current state in db. in example, happens in background - person entitiy id 1 retrieved db (it exists in entitymanager cache) - per...

git - What is the difference between eol=lf and text in a .gitattributes file? -

according the documentation on .gitattributes , text enables end-of-line normalization: text setting text attribute on path enables end-of-line normalization , marks path text file. end-of-line conversion takes place without guessing content type. according same documentation, eol=lf normalize linebreaks: eol this attribute sets specific line-ending style used in working directory. enables end-of-line normalization without content checks, setting text attribute. the fact examples given mix them in same file seems imply there (perhaps subtle) difference between them: *.txt text *.vcproj eol=crlf *.sh eol=lf *.jpg -text also, there seems unambiguous statement same, or text shorthand eol=lf —though appears case. closest thing find such statement quoted above, says "effectively setting text attribute". word effectively seems back-pedal slightly, though it's not actually setting text attribute, more-or-les...

Pointers ignoring unsigned trait in C? -

i'm curious why following code returns negative numbers though every single variable , fuction initialization in program unsigned int. thought supposed positive?. #include <stdio.h> unsigned int main () { unsigned int ch = 0; unsigned int asteriskvalue = 0; while(ch!=27) { ch = getch(); if (ch == 224) { increasedecrease(&asteriskvalue); } printf("%d",asteriskvalue); } } void increasedecrease(unsigned int *value) { unsigned int upordown; upordown = getch (); if(upordown == 72) (*value)--; else if(upordown == 80) (*value)++; } i think results positive value, printing "%d" flag, tells printf interpret signed value, if casting on fly type: (signed)asteriskvalue try printing "%u" formatting instead of "%d".

java - How to use ksoap2 to call a web service -

i have been trying connect w3schools tempconvert web service andorid using ksoap2, result whenever calling method com.example.myproject.mytask@ the code have used is public class mytask extends asynctask<string, integer, string>{ private static final string soap_action = "http://www.w3schools.com/webservices/celsiustofahrenheit"; private static final string operation_name = "celsiustofahrenheit"; private static final string namespace = "http://www.w3schools.com/webservices/"; private static final string url = "http://www.w3schools.com/webservices/tempconvert.asmx?wsdl"; @override protected string doinbackground(string... params) { string response = null; soapobject request = new soapobject(namespace, operation_name); request.addproperty("celsius", "1"); //request.addproperty("strcommandparameters", params[1]); soapserializationenvelope soapenvelope = new soapserializationenvelop...

vb.net - pascal triangle gives overflow for 13 -

i wrote code output pascal triangle in multi-line textbook. program works fine inputs between 1 12 gives overflow error once value of 13 inputed. is there modifications can make enable program accurately give outputs 13 , higher? here code used: public class pascal_triangle private function factorial(byval k integer) integer if k = 0 or k = 1 return 1 else return k * factorial(k - 1) end if end function private sub btngen_click(sender object, e eventargs) handles btngen.click dim ncr integer dim i, j, k integer dim output string output = "" j = val(txtcolumn.text) k = 0 j = 0 k dim fact, fact1, fact2 integer fact = factorial(k) fact1 = factorial(k - i) fact2 = factorial(i) ncr = fact / (fact1 * fact2) txtoutput.text += str(ncr) & output ...

blank nodes - SPARQL: Selecting the nth blanknode -

take following graph: :foo :p _:b0 ; :p _:b1 ; :p _:b2 . _:b0 :p1 :apple ; :p2 :banana . _:b1 :p3 :cantaloupe ; :p4 :date ; :p5 :elderberry . _:b2 :p6 :fig . notice: :foo subject of 3 triples same predicate, :p . each of triples has blanknode object. is possible write sparql query selects triples _:b1 subject? edit: before proposing answer, please understand looking clever solution question, in sparql. assume triple store fixed (ie: nothing can done change data). graph show above contrived; each blanknode not have same number of p/o triples. if each had 1 triple however, following sparql query might suffice: select ?b1 { :foo :p ?bn . ?bn ?p ?o } limit 1 offset 1 obviously, concern here returning same blanknode each time. know it's set , inherently unordered, repeatable results ordering not guaranteed; honestly... fixed triple store, sincerely doubt dfa return different blanknode ordering between queries. clever ideas? you ...

Add click animation to a layout in android -

i have linearlayout showing menu few options. there way add click animation (like 1 listview has when tap on element) each element once tapped? i think looking rippleeffect . ripple animation material design api level 9+

html - jQuery.ajax Content from an end point which responds differently depending on the hash value in the url -

main question: how retrieve content url " http://www.example.com/index.html#foo " via jquery.ajax()? note: following works scripts, requesting: var script = document.createelement('script'); script.type= 'text/javascript'; script.src= 'http://www.example.com/script.js#foo'; $('head').append(script); and can build own request in plain old ajax way using the method found here : var xmlhttp = new xmlhttprequest(); var url="http://www.example.com/index.html#foo"; xmlhttp.open("get", url, true); xmlhttp.setrequestheader("content-type", "application/x-www-form-urlencoded"); xmlhttp.setrequestheader("content-length", 0); xmlhttp.setrequestheader("connection", "close"); xmlhttp.onreadystatechange = function() { if(xmlhttp.readystate == 4 && xmlhttp.status == 200) { alert(xmlhttp.responsetext); } } xmlhttp.send(); however, seems jquery.ajax ...

java - How can I use computeTax method to calculate tax a variable defined in main and then call the value of tax later in main? -

how can use computetax method calculate tax variable defined in main , call value of tax later in main? further assistance appreciated on of code see below well. import java.util.scanner; // date: sep 29, 2015 public class r8 { public static void main(string[] args) { // read steps before beginning. understand larger picture. // create new java project named r8, , make class named r8. // copy following code , paste inside the curly braces of main method: // // declare variables string restaurantname; string servername; double subtotal; double tax; double total; double taxrate = 0.05; double tiprate1 = 0.10; double tiprate2 = 0.15; double tiprate3 = 0.20; // // ask , receive input user // create scanner object, prompt user name of restaurant, , read in input variable restaurantname. restaurant can be more 1 word, "park sushi." scanner scanner = new sca...

javascript - Why angular doen't get value of ng-models of inputs, html inserted by $sce.trustAsHtml? -

i have code on controller: angular.module('reporteadorapp') .controller('sidebarctrl', ['$scope', '$http', '$cookies', '$sce', function ($scope, $http, $cookies, $sce) { $scope.codecontroles = '<div class="row"><div class="col-sm-12">' $scope.codecontroles += '<div class="form form-group"><label>' + asignarlistacontroles.nombrecontrol + '</label><select class="form form-control" ng-model="' + asignarlistacontroles.variable1 + '"></select></div>'; $scope.codecontroles += '</div></div>'; $scope.codigohtml = $sce.trustashtml($scope.codecontroles); }]); then in html: <div ng-bind-html="codigohtml"></div> i'm trying values of ng-models inserted on view, can't, angular returns undefinided. whats problem?!. if add input m...

Mount Google Cloud Storage Bucket to Instance -

how can mount google cloud storage bucket disk or folder standard path such ~/mybucket on google compute instance? everything in same project full access. with new beta gcsfuse possible. gcsfuse mybucket ~/path/to/mount https://cloud.google.com/storage/docs/gcs-fuse

regex - htaccess - combine rewrites into single -

i have couple of rewriterules i'd combine one. i'm not sure how it, though. think arounds need used? difference between 2 first match like: search/foo or search/foo/ and second match search/foo/10 or search/foo/10/ rewrites: rewriterule ^search/([a-za-z]+)/?$ index.php?page=search&query=$1&pn=1 [l] rewriterule ^search/([a-za-z]+)/([0-9]+)/?$ index.php?page=search&query=$1&pn=$2 [l] without using arounds, attempt ^search/([a-za-z]+)/?([0-9]+)?/?$ but think match undesirable this? search/foo10 edit: i'm tryin regex match following uris: search/foo search/foo/ search/foo/1 search/foo/1/ ^search/([a-za-z]+)(/)?([0-9]+)?\/?$ will work? might have make '/' match pattern , ignore $2.same can followed trailing '/' , ignore $4.

r - Multinomial multivariate adaptive regression splines MARS -

does happen know how run mars model multinomial response (0,1,2) in r or other softwares? have used earth package binomial 1 "binomial" family , works well. however, when comes multinomial response, seems there no option available that. hint appreciated. as far 've heard r / mars integration, salford systems has announced earlier in 2015/q1 extension system allow users access mars r -session. hope helps.

ios - How do I apply an animation around a button? -

Image
i have 30 sec of song being played when play button being played. want progress bar go around play button song being played. how this? play = add[indexpath.row] let playbutton : uibutton = uibutton.buttonwithtype(uibuttontype.custom) as! uibutton playbutton.tag = indexpath.row let imageret = "playbutton" playbutton.setimage(uiimage(named: imageret), forstate: .normal) playbutton.frame = cgrectmake(236, 20, 100, 100) playbutton.addtarget(self,action: "playit:", forcontrolevents: uicontrolevents.touchupinside) i'm assuming want this: it cashapelayer path circle. start strokeend of 0 , animate 1. can poll song's progress using nstimer at, say, 1-second intervals , calculate how of song has played, , set strokeend fraction.

Center position of logo in Action Bar Android -

Image
i want display logo @ centre of action bar. here's custom layout code: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/actionbarwrapper" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="horizontal" > <imageview android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/logo" android:layout_centerinparent="true" android:padding="8dp"/> </relativelayout> and in oncreate() i'm using as: getsupportactionbar().setdisplayoptions(actionbar.display_show_custom); getsupportactionbar().setcustomview(r.layout.custom_logo); getsupportactionbar().setbackgrounddrawable(new c...

ios - How to use method dataWithContacts in CNContactVCardSerialization? -

i trying nsdata object vcard representation of contact. code: let contactstore = cncontactstore() let fetchrequest = cncontactfetchrequest(keystofetch: [cncontactgivennamekey, cncontactfamilynamekey]) var contacts = [cncontact]() var vcard = nsdata() do{ try contactstore.enumeratecontactswithfetchrequest(fetchrequest) { (contact, status) -> void in self.fetchrequest.unifyresults = true self.contacts.append(contact)} } catch { print("error \(error)") } { try vcard = cncontactvcardserialization.datawithcontacts(contacts) } catch { print("error \(error)") } but, error: exception writing contacts vcard (data): property not requested when contact fetched. error nilerror. i understand error in access contacts, how fix it? i found solution , work: let contactstore = cncontactstore() var contacts = [cncontact]() var vcardfromcontacts = nsdata(...

selectnodes - jsTree "select_node" returns false -

i using jstree in angularjs , using "select_node" in "ready". method returning false. on code debugged, observed tree.instance._model.data doesn't have node this.get_node(obj); returns false. (below code snippet) select_node : function (obj, supress_event, prevent_open, e) { var dom, t1, t2, th; if($.isarray(obj)) { obj = obj.slice(); for(t1 = 0, t2 = obj.length; t1 < t2; t1++) { this.select_node(obj[t1], supress_event, prevent_open, e); } return true; } obj = this.get_node(obj); //here returns false if(!obj || obj.id === '#') { return false; } } i not sure why tree.instance._model.data doesn't have data @ time because works when refresh browser. any help? below code snippet. me.ontreeready = function (eve, tree) { tree.instance.deselect_all(); tree.instance.refresh(true, true); var response = tree.instan...

javascript - on redirecting to a previous html page the page should not refresh -

actually have 2 fields in "click.html".one "name" field , other "client_ip" field.i have entered name in "name" field , later on click of "client_ip" text box has redirected index.html. in index.html i'll select required client_ip's , redirect page again click.html.so selected client_ip fields placed in client_ip text box of click.html page. now after redirecting click.html,the name had entered in "name" text box vanishing because of page refresh while redirecting.but now,i want redirect click.html without refreshing click.html page.how can achieve ... my click.html: <html> <head> <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript" src="http://cdn.datatables.net/1.10.9/js/jquery.datatables.min.js"></s...

visual studio - unit test strange things -

i have class extend base class,the base class in dll. public class mymicroblogcache : relatedbase<thzuserinfo, microblogcachemodel, int> and in constructor,inject icache public mymicroblogcache(icache cache,.... in base class ,i use icache in method(for example void a() ) and write unit test,mock icache var cache = substitute.for<icache>(); cache.pagerelated<thzuserinfo, microblogcachemodel, int>("my", 2217, 0, 3, out all, true) .returns( x => { var list = new list<microblogcachemodel>(); list.add(new microblogcachemodel { id = 1, userid = 2217 }); list.add(new microblogcachemodel { id = 1, userid = 2217 }); list.add(new microblogcachemodel { id = 1, userid = 2217 }); return list; }); mock nsubstitute var cache1 = new mock<icache>(); cache1.setup(ca => ca.pagerelated<thzuserinfo, microblogcachemodel, int>("my", 2217, 0, 3, out all, true)) .returns( () ...

javascript - Register Knockout.js component viewmodel from module in typescript -

my viewmodel module has several classes, want register spesific class component's viewmodel. and says: component 'filter-table': unknown viewmodel value: [object object] this have in viewmodel module module filtervm { export class filterviewmodel { //some code } class filtertableviewmodel { } class attributetableviewmodel { } class layerattributeviewmodel { } } export = filtervm; and trying register import filtervm = require('scripts/app/components/attributetable/viewmodels/filterviewmodel'); ko.components.register('filter-table', { viewmodel: { require: filtervm.filterviewmodel }, template: { require: 'text!scripts/app/components/attributetable/views/filtertableview.html' } }); what wrong that? solved the problem here viewmodel: { require: filtervm.filterviewmodel } should viewmodel: filtervm.filterviewmodel

c# - How to deselect just the button `Select all` not all items? -

i have checkbox select all/deselect items checkedlistbox . fore have next code works: private void checkedlistbox2_selectedindexchanged(object sender, eventargs e) { if (checkedlistbox2.checkeditems.count == checkedlistbox2.items.count) checkbox1.checked = true; else if (checkedlistbox2.checkeditems.count != checkedlistbox2.items.count) checkbox1.checked = false; } but problem is, if have items checked (the button select all checked) , if make click on 1 item deselected (and button select all uncheck ). want when make click on 1 item deselect button select all not items? edit: here code : private void checkedlistbox2_selectedindexchanged(object sender, eventargs e) { string installerfilename = string.format("{0}{1}", appdomain.currentdomain.basedirectory, "installer.ini"); ienumerable<string> inilines = file.readalllines(installerfilename).asenumerable(); ...

sql - Copying table records after a specific file interval in Postgresql -

i have table records want copy db on remote server after specific interval of time. number of records in table high(in range of millions) , columns can range 40-50. i thought using pg_dump after time-interval sounds inefficient whole table dumped again , again. assume time interval 4 hours , life-cycle of db start @ 10:00. no. of records @ 10:00 - 0 no. of records @ 14:00 - n no. of records @ 18:00 - n+m no. of records @ 22:00 - n+m+l the script(shell) want write should select 0 rows @ 10:00, n rows @ 14:00, m rows @ 18:00, l rows @ 22:00. is there other way through copy rows have been added between time intervals in order remove redundant rows come if take pg_dump every 4 hours?

i want to initialize overflow attribute as none in BIRT tool -

Image
but if select none ,its showing hidden:inherited. please me in resolving issue. a value of "none" not supported , receive error if try change in xml. can add javascript change or remove value in dom.

how to get a json file located locally in angularjs -

hi using angularjs , want data locally built json file . tried using $http no luck. please tell alternate method $http.get("job.json") .success(function(response) { $scope.big=response; }); this method used , json code { "days": [{ "dayname": "sun,23 aug 2015", "date": "2015-08-23", "hours": "hoursarray(array24)" }, { "dayname": "mon,24 aug 2015", "date": "2015-08-24", "hours": "hoursarray(array24)" }, { "dayname": "tue,25 aug 2015", "date": "2015-08-25", "hours":"hoursarray(array24)" }, { "dayname": "wed,26 aug 2015", "date": "2015-08-26", "hours": "hoursarray(array24)" }] } you should use factory ...

SQLITE_ERROR: Connection is closed when connecting from Spark via JDBC to SQLite database -

i using apache spark 1.5.1 , trying connect local sqlite database named clinton.db . creating data frame table of database works fine when operations on created object, error below says "sql error or missing database (connection closed)". funny thing result of operation nevertheless. idea can solve problem, i.e., avoid error? start command spark-shell: ../spark/bin/spark-shell --master local[8] --jars ../libraries/sqlite-jdbc-3.8.11.1.jar --classpath ../libraries/sqlite-jdbc-3.8.11.1.jar reading database: val emails = sqlcontext.read.format("jdbc").options(map("url" -> "jdbc:sqlite:../data/clinton.sqlite", "dbtable" -> "emails")).load() simple count (fails): emails.count error: 15/09/30 09:06:39 warn jdbcrdd: exception closing statement java.sql.sqlexception: [sqlite_error] sql error or missing database (connection closed) @ org.sqlite.core.db.newsqlexception(db.java:890) @ org.sqlite.core.cor...

sql server - TSQL: Strange behavior using case statement -

i have scenario wherein have update customer table’s billing_start_month column based on start_month. i have been given start_month value in excel sheet along customer name. so, have created temp table , inserted customername , start_month values. in excel sheet start_month values contain other values eg: (if start_month month january, february etc update billing_start_month column 1, 2 recpectively, if start_month values contains values 1,3,4,5,7 need leave records without updating billing_start_month column of customer table). have 5 records in excel sheet has start_month values “1,3,4,5,7”. now updating customer table’s billing_start_month column using following query: update customer set billing_start_month = case when tmp.startmonth = 'january' 1 when tmp.startmonth = ‘february’ 2 end #temp tmp inner join customer c on tmp.customer = c.acc_name but on executing query getting check constraint fail erro...

javascript - Why does adding </script> in a comment break the parser? -

this question has answer here: why split <script> tag when writing document.write()? 5 answers why adding </script> in comment break parser? bug or there in documentation i've overlooked? i've tested in chrome, firefox, opera, internet explorer , produce same result. single-line comment: function foo(){ // </script> alert("bar"); }; foo(); multi-line comment: function foo(){ /* </script> */ alert("bar"); }; foo(); this happens because html parser defined w3c totally separated javascript parser. after <script> tag looks closing </script> , regardless it's inside comments or strings, because treats js code normal text.

c - sockaddr value changes unexpectedly after calling getaddrinfo() -

i programming udp client. want bind socket given port on client machine, same port used sends. sockaddr server using getaddrinfo, , same sockaddr pass call getaddrinfo. however, after second call getaddrinfo address of server machine changes, , end sending packet client machine client machine itself. the following code standalone example reproduces error: #include <stdio.h> #include <stdint.h> #include <unistd.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h> #define server_host "www.google.com" #define udp_port "4000" static struct sockaddr_in *destination_addr = null; static int client_port; int main(){ uint8_t bytes[5] = { 0xaa, 0xab, 0xac, 0xad, 0xaf}; //some data send uint16_t length = 5; int status; //initialize socket...

colors - How to add rainbow gradient to an Image in android -

Image
i want add transparent rainbow or spectrum gradient bitmap . in photoshop easy. want programmatically . have gone through lot of research. gradient has 1 starting color , 1 ending . how add rainbow color(multiple color) gradient in android. or there way add effect bitmap in android? given for can use translucent image desired gradient , put on top of image view in framelayout . capture bitmap of view. once layout ready use this answer capture bitmap it try convert view (framelayout) bitmap: public bitmap viewtobitmap(view view) { bitmap bitmap = bitmap.createbitmap(view.getwidth(), view.getheight(), bitmap.config.argb_8888); canvas canvas = new canvas(bitmap); view.draw(canvas); return bitmap; }

swift - iOS Todays Widget Extension - Animate UISlider -

i'm creating todays extension within ios. i'm trying animate value change on uislider added in todays extension. animation should proceed start value end value. i tried in 2 ways: first uiview animation func updatesliderview(beginstate:float, duration: nstimeinterval) { sliderview.hidden = false sliderview.setvalue(beginstate, animated: false) uiview.animatewithduration(duration) { () -> void in self.sliderview.setvalue(1, animated: true) } } second basic animation. func updatesliderview(beginstate:float, duration: nstimeinterval) { sliderview.hidden = false guard let _ = sliderview.layer.animationforkey("slider.animation.value") else { let animation = cabasicanimation(keypath: "value") animation.fromvalue = beginstate animation.tovalue = 1 animation.removedoncompletion = true sliderview.layer.addanimation(animation, forkey: "slider.animation.value") re...

sql - Take combobox SelectedIndex data and use in SELECT Query - VB.net -

i'm little desperate, hence why i'm here! i'm quite new programming , have been given assignment need use range of sql queries generate simple html report table. there user input, them selecting clinicid combobox , clicking button generate report. basically, have combobox have populated 'clinicid', below. have made sure selectedindex working. need somehow use in sql query method have provided below. public class frmreport1 'set lsdata clinics table dim lsdata list(of hashtable) 'on form load private sub frmreport1_load(sender object, e eventargs) handles mybase.load cboclinicid.dropdownstyle = comboboxstyle.dropdownlist 'instantiate new cliniccontroller object dim ccontroller cliniccontroller = new cliniccontroller 'load clinicid lsdata = ccontroller.findid() each clinic in lsdata cboclinicid.items.add(cstr(clinic("clinicid"))) next end sub 'selected index private sub cboclinicid_sele...

Android Studio Picasso gif loading image for placeholder -

how can display gif loading image in picasso placeholder? i want use gif in part code imageview = (imageview) rootview.findviewbyid(r.id.imageview); picasso.with(getactivity()).load("http://joehamirbalabadan.com/android/android/imghome/index1.png").placeholder(r.drawable.indexloading).into(imageview); imageview3 = (imageview) rootview.findviewbyid(r.id.imageview3); picasso.with(getactivity()).load("http://joehamirbalabadan.com/android/android/imghome/index3.png").placeholder(r.drawable.indexloading).into(imageview3); please check , improve code.. homefragment.java package com.example.administrator.mosbeau; import android.app.activity; import android.app.fragment; import android.app.fragmentmanager; import android.graphics.bitmap; import android.graphics.drawable.bitmapdrawable; import android.os.bundle; import android.support.annotation.nullable; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import androi...

SQL Server Group data by week but show the start of the week -

i have query select customer data , want keep evolution of number of customers. in week 1 have 2 new customers number 2. in week 2 receive 3 new customers, number of customers 5. i have following query this select last_updated_week, sum( num_customers ) on ( order last_updated_week rows between unbounded preceding , current row ) "number of customers" ( select dateadd(dd,datediff(dd,0,registration_date),0) last_updated_week, count(distinct customer_id) num_customers customers_table group dateadd(dd,datediff(dd,0,registration_date),0)) t but when run query, doesn't group data week. read datepart function, returns integer, need have actual date. can me? just replace dd in dateadd , datediff functions week