Posts

Showing posts from June, 2012

javascript - A circle element next to a fluid rounded element -

is following layout possible css? if not, there better solution current js solution? see fiddle complete example. +--------------------+ | | | | | | | | | | | | | | | | | | |--------------------+ |+----+ +----------+| container height in percentage, e.g. 20% of window || 1 | | 2 || button 1: circle based on container height |+----+ +----------+| button 2: fill available space , round corners +--------------------+ the basic issue first element needs circle, i.e. rounded square, based on height of container. , second element should fill rest of space same border-radius. following how solved js, not seem reliable on mobile devices. , project mobile-only. also, if layout dependent on js, cause other trouble when doing fancy transitions etc. css. fiddle: http://jsfiddle.net/n52x1ws1/3/

angularjs - Is there any way to fetch only date from new date() function without time -

suppose 1 value have mon jul 04 2016 18:12:03 gmt+0530 (india standard time) , want result jul-04-2016. how can in angular js. here's snippet working: var app = angular.module('app', []); app.controller('mainctrl', function ($scope) { $scope.data = new date(); }); <!doctype html> <html ng-app="app"> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"></script> </head> <body ng-controller="mainctrl"> date without format: <span ng-bind="data"></span> <hr/ > date format ("mmm-dd-y"): <span ng-bind="data | date: 'mmm-dd-y'"></span> </body> </html> you can check formats provided date api here .

How to open new tab in java wicket using code -

i have validate code first after clicking on button need open new page new tab in wicket. used target= "_blank" option did't work me. once have confirmation, can utilize popupsettings open page on different tab: popupsettings settings = new popupsettings(); settings.settarget(string.format("'%s'", urlfor(anotherpage.class, null))); ajaxrequesttarget.appendjavascript(settings.getpopupjavascript()); update: it's browser though, whether new window or new tab opened: open url in new tab (and not new window) using javascript

node.js - PM2 command not found -

i installed node.js , npm centos 7 server. have problems pm2. real problem don't have experiences in linux , don't know how change path. here folder structure. * bin * code * error_docs * httpdocs * lib64 * logs * tmp * var * chat(my node.js folder) * node_modules * pm2 * sockjs * server.js * dev * etc * lib * local * sbin * usr i entered folder typing cd chat , installed pm2 npm install pm2 . after tried use pm2 server.js typing pm2 server.js server returns "pm2 command not found". can use node.js without problem pm2 not working. how can solve this? install pm2 globally: run root: npm -g pm2 or if user sudo-er sudo npm -g pm2 and go user (or stay in root if created root user) , run it: pm2 start server.js

java - 'Void' type not allowed here error -

this question has answer here: “'void' type not allowed here” error (java) 6 answers import java.util.scanner; import java.util.arraylist; public class onlinestore { string[] books = { "intro java", "intro c++", "intro c++", "perl" }; string[] dvds = { "snow white", "cinderella", "dumbo", "bambi" }; double[] booksprices = { 45.99, 89.34, 100.00, 25.0 }; double[] dvdsprices = { 19.99, 24.99, 17.99, 21.99 }; arraylist < string > cartitems = new arraylist < > (); arraylist < double > prices = new arraylist < > (); java.util.scanner input = new scanner(system. in ); int userchoice; public void displaymenu() { system.out.printf("**welcome mustangs books , dvds store*

ios - Static able view cell font size is not changing -

i'm loading tableview static cells inside container view. cell style basic. i'm trying change font size. in storyboard appearing right. when running app in simulator, noticed font not same set in storyboard. notice: didn't create class table view controller because has static content. i'm developing on xcode 7.3 , ios 9 , later. any hints appreciated. cell.textlabel.font=[uifont fontwithname:@"helveticaneue" size:36] you have change in cellforrowatindexpath

regex to replace /swap the option value with the text in select -

i have ton of tedious options edit , while know several regex commands , tricks, i'm not able figure out how following: problem: business team wants me go in swap out name , value reverse so instead of: <option value="miller keisha s">keisha.miller@company.com</option> i want use notepad++ or whatever else , get <option value="keisha.miller@company.com">miller keisha s</option> i know $ end , ^ beginning forward , backslashes etc... so know want find in value=" , ends "> , replace starts "> , ends i looking @ other stackoverflow questions , https://www.regex101.com/ search for: <option value="([^"]+)">([^<]+)<\/option> replace with: <option value="$2">$1</option> demo

In Android SQLite db how to match particular columns values which have same id's in multiple tables of a database? -

i had dumped data sqlite json data getting. question have single database multiple tables want relate multiple tables using there id's.these 3 tables had created. this first table have product list, private static final string database_create_product = "create table if not exists " + "product_template" + " (" + "_id" + " integer primary key autoincrement," + "name" + "," + "list_price" + "," + "create_date" + "," + "default_code" + "," + "ean13" + "," + "image_new" + "," + "image_variant" + ");"; this second table have partner list, private static final string database_create_partner =

java - JAX-WS Thread safe -

i found questions regarding this, without concrete answer. have code bellow: 1: qname qname = new qname(uri, service_name); 2: service service = service.create(wsdl_document_location, qname); 3: testport1 port = service.getport(testport1.class); times: line 2 16 msec line 3 27 msec now, in situation time important, question is, possible have qname , service initialized once, , defined static field , port every time need make ws call or not? any other proposal? i use standard java jax-ws annotations. update: maybe solution use object pooling apache commons pool library , save created ports future use? qname holds strings internally , doesn't offer method change them after constructor has been called, can treat immutable class if not.

python - Having two serial keys in postgresql via sqlalchemy -

i have unusual challenge. i'm modifying table able join 2 other legacy groups of postgresql tables. one group pretty requires each record in table have unique integer. so, following field definition work: numeric_id = sql.column(sql.integer, primary_key=true) the other group of tables use uuid fields expected join requests. following field definition work: uu_account_id = sql.column(uuid(as_uuid=true), primary_key=true) but, clearly, can't have 2 primary keys. 1 of them needs not primary key. nice have both still automatically assigned when new record made. any suggestions? i'm sure can quick hack, i'm curious if there nice clean answer. (and no: changing other tables not option. way legacy code.) make uuid column primary key, usual. define other column having serial type , unique . in sql i'd write create table mytable ( mytable_id uuid primary key default uuid_generate_v4(), mytable_legacy_id serial unique not nul

java - Running Single cucumber-jvm .feature file from Gradle -

i integrating cucumber-java existing gradle java project, has focus on test automation. there no production code within project, making entire project makes little sense. what create gradle tasks or single gradle task -d property specifies cucumber .feature file run cucumber-jvm on. of examples i've seen show how cucumber-jvm run part of build process. instead, define task testcucumber(type: test) run single .feature file. how go doing this? i able work using javaexec task in gradle. javaexec { main = "cucumber.api.cli.main" classpath = configurations.cucumberruntime + sourcesets.main.output + sourcesets.test.output args = ['--plugin', 'junit:target/cucumber-junit-report.xml', '--plugin', 'pretty', '--glue', 'stepdefinitions', 'src/test/features/featurefilename.feature'] } this assuming step definitions defined within package called "stepdefinitions".

java - Implementing an ADT linked list from scratch -

i've got class project have build adt-based linked list scratch (meaning can't use standard java adts) , use sort bunch of state objects (that each contain linked list of cities ) alphabetically. backbone of code is, obviously, handmade orderedlinkedlist class, , i'm having lot of trouble figuring out how implement, speficially, findoradd method iterates through list and, if argument passed not in list, adds in appropriate spot (and returns element if it's there). of things i've read implementing linked lists don't deal in adts , it's difficult convert in mind , still wrap head around it. (admittedly incomplete) oll code , accompanying iterator: import java.util.iterator; public class orderedlinkedlist<e extends comparable<e>> implements iterable<e> { private e first; private e next; private e last; private e current; private e temp; private int size; public orderedlinkedlist() { this.fir

android - Get co-ordinates, height and width of currently visible image in imageview -

Image
i have implemented custom image view allows pinch zooming , panning of image. need store co-ordinates of image , scale can reproduced on other platforms without saving new image final touchimageview imgview = new touchimageview(this); imgview.setimageresource(r.drawable.an_img); final float [] values = new float[9]; img.matrix.getvalues(values); float transx = values[matrix.mtrans_x]; float transy = values[matrix.mtrans_y]; log.d("tag", transx + " : " + transy); / rectf rect = new rectf(); img.matrix.maprect(rect); log.e("rect::::: ", rect.height() + " : " + rect.width()); co-ordinates within image of view-able section of image (the point in circle on left of drawing)

java - Tomcat not detecting SessionDisconnectEvent on linux environment -

client registers on websocket , channel. when client disconnects disabling wifi or pulling out ethernet, server detects client disconnected through spring's sessiondisconnectevent (takes couple of seconds). this works fine on local windows environment, sessiondisconnectevent not being picked when tomcat hosted on linux environment. other applicationevents such sessionsubscribeevent detected. tried using different connectors in server.xml no luck. any ideas?

javascript - Adding a floating div to a table row by click -

Image
i have following table: on click of circled blue icon there should opened "floating" div item on right side. this div should responsive , aligned row. i did defining floating div absolute , using fixed pixel dimension. my problem if align floating div according relative location of row overhidden parent div. , if make absolute compared dom not responsive. any suggestions of how divs structure should like? please let me know if info missing? edit : here js-fiddle showing problem: https://jsfiddle.net/omriman12/3gv788o4/ i want red squere aligned row(try moving red squere right side of black box) try this, might asking this. .main_wrapper{ width: 79%; position:relative; display: inline-block; overflow: hidden; } .a1{ width: 100%; height: 50px; background-color: black; } .a2{ width: 100%; height: 50px; background-color: red; position: fixed; right: 0px; top: 8px; } .blue-wrapper { width:20%;

java - Update a response object of the end-point -

i generated automatically springmvc api using swagger. want update end-points manually. have folloiwng end-point: @apioperation(value = "estimation of ...", notes = "...", response = similarity.class, responsecontainer = "list") @io.swagger.annotations.apiresponses(value = { @io.swagger.annotations.apiresponse(code = 200, message = "similarity metrics", response = similarity.class), @io.swagger.annotations.apiresponse(code = 200, message = "unexpected error", response = similarity.class) }) @requestmapping(value = "/estimatesimilarity", produces = { "application/json" }, method = requestmethod.get) public responseentity<hashmap<string,double>> estimatesimilarity( @apiparam(value = "...", required = true) @requestparam(value = "term1", required = true) string term, @apiparam(value = "...", required = true)

probability - Simulate experiment with R Programming -

i new in r programming. need solve 1 problem in r. need simulate following experiment in r. poker hand consists of 5 cards dealt conventional pack of 52 cards, order of cards not being important. find probability given hand has @ least 1 king , @ least 1 queen. i know how find atleast 1 king not @ least 1 king , @ least 1 queen. atleast 1 king code : deck<- rep(1:13 , each=4) #here j=11 , q=12, k=13 nhands <- 1000 xk<- c(rep(-1, nhands)) for( in 1:nhands){ hand <- sample( deck , 5 , replace= false) numberofk<-0 for( j in 1:5){ # count kings if( hand[j] == 13){ numberofk <- numberofk +1 } } #print(numberofk) xk[i] <-numberofk #print(hand) } table(xk) /nhands can please me in coding required 1.. thanks the probability of hand of 5 cards contain @ least 1 king or 1 queen can written following, sample(deck, 5) gives hand of 5 cards while any(c(12, 13) ...) checks whether king or queen within hand , sum counts how many times such case happens

c# - Http.HttpRequestException to vagrant host -

i have rest api server on vagrant machine. , write client on c# (vs2015). have same code: using (httpclient client = new httpclient()) { client.baseaddress = new uri(_server); client.defaultrequestheaders.accept.clear(); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); httpresponsemessage response = null; try { response = await client.getasync(_action); } catch (httprequestexception e) { debug.writeline(e.message); } } trouble: exception thrown: 'system.net.http.httprequestexception' in mscorlib.ni.dll error occurred while sending request. if send request (non-vagrant) host, ok. question: how can solve this? thanks) updated stack trace exception thrown: 'system.net.http.httprequestexception' in mscorlib.ni.dll mess: error occurred while sending request. @ system.net.http.httpclienthandler.<sendasync>d__1.movenext() ---

c# - Bindingsource is not suspending binding -

i have form displays custom details, 1 section being list of bank accounts associated customer. list bound it's own bindingsource, when loading customer do: bscustomer.datasource = customer; bscustomeraccounts.datasource = customer.accounts; i have objectlistview bound bscustomeraccounts . far works fine. to edit particular account, double-click on , open separate form: using (var form = new customeraccountform(selectedaccount)) { dialogresult result = form.showdialog(this); if (result == dialogresult.ok) { selectedaccount= form.account; } } the problem when user clicks on cancel cancel editing of account in form. original bccustomeraccounts , therefore list still being updated. i've tried suspendbinding , raiselistchangedevents = false bindingsource still being updated. am missing something? it seems surprising @ first, think while didn't assign edited object list, why list item edited? the key point here: classes r

javascript - Trigger an ad for the first click on ANY part of the website -

there websites no matter click (background, random words, existing links, anything) ad pops up. example: first time click contact spam, if click contact again go "/contact" section. i wonder how possible , how made. like this: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> = 0; $(document).on('click','body',function(event){ if (i == 0) { event.preventdefault(); //insert code display ad here alert('spam here'); i++; } }); </script> <body> <div>blah blah blah</div> <a href = "//stackoverflow.com">link here</a> </body> after first click, i no longer = 0, therefore default action of body elements restored.

Play RTMP stream on Android with gstreamer -

i'm new in gstreamer. i'm trying create pipeline able play rtmp stream. googled lot, , understood, must recode video other format. pipeline: data->pipeline = gst_parse_launch("rtmpsrc location=\"rtmp://193.93.236.33:443/rtmp&file=lenina347 live=1\" ! glimagesink name=sink sync=false", &error); i understand should add plugins between rtmpsrc , glimagesink . question is: what shoud add? i found solution of problem. now, i'm using playbin play rtmp stream. playbin support playing rtmp out of box, it's important pass location property right link, i.e.: rtmp://hostname[:port]/path/rtmpfile . **important ** there must 2 slashes after hostname. noticed port optional.

sql - postgresql order by group -

i use below query rows 1,3,4,5,6 in first table, want know how order parenttagid order name final 2 arrays/rows 1,3,5 , 1,4,6 var query = 'select * "articletag" left outer join "tag" on ( "articletag"."tagid" = "tag"."tagid" ) "articleid" = $1 order "parenttagid" desc'; create table if not exists "tag"( "tagid" serial not null, "parenttagid" integer, "name" varchar, primary key ("tagid") ); tagid | parenttagid | name | 1 | | | 2 | | b | 3 | 1 | z | 4 | 1 | f | 5 | 3 | g | 6 | 4 | z | create table if not exists "articletag"( "articletagid" serial not null, "articleid" integer not null, "tagid" integer not null, foreign key ("articleid") references "article" ("arti

c - Trying to encrypt and decrypt code-beginner -

so bit maniuplation excercise im confused how convert letters numbers, think these arent binary dont know mean. can suggest approach? here's 2 examples of encryption: "cats" , "kittens". pairs: "ca ts" "ki tt en s_" (_ represents space) ints: 25441 29811 27497 29812 25966 29472 xor 31337: 6408 3610 4352 3613 7943 2377 the decimal quintet each couple of letters decimal representation of concatenated hex values of characters in ascii, eg: "ca" = 0x63 0x61 = 0x6361 = 25441 same story xor key 31337 = 0x7a69 indeed 0x6361 ^ 0x7a69 = 0x1908 = 6408 in decimal

ruby on rails - undefined method `name' for nil:NilClass for custom slug -

i have restaurant model use geocoder gather city, state, , neighborhood on before_validation callback. class restaurant < activerecord::base # attrs: :name, :address, :city_id, :neighborhood_id ... before_validation :geocode geocoded_by :address |obj,results| if geo = results.first obj.city = city.where(name: geo.city).first_or_create obj.city.update_attributes(state: state.where(name: geo.state).first_or_create) obj.neighborhood = neighborhood.where(name: geo.neighborhood).first_or_create obj.neighborhood.update_attributes(city: city.where(name: geo.city).first_or_create) obj.longitude = geo.longitude obj.latitude = geo.latitude end end end in city model i've put custom slug uses city's name , state's name belongs to. class city < activerecord::base # attrs :name, state_id belongs_to :state friendly_id :state_slug, use: :slugged def state_slug "#{name} #{state.name}" en

python - Pandas merge pivot_table and a dataframe -

how merge pandas pivot table , data frame combined column in pivot table in index , in data frame in column label pivot table perc odate 0001-255-255 2015-09-27 2015-09-28 2015-09-29 bts_name 0001_durgacomplex_nbsnl 100 100 100 100 0002_shivanagar_area_bdr 100 100 100 100 0003_old_city_bidar 100 100 100 100 0004_bidar_mw_station 100 100 100 100 0005_bidri_colony 100 100 100 100 dataframe ssaname bts_name make tech site_type taluka 0 bangalore 2882_brigade_road_iii huawei 3g nbsnl bts3 1 bangalore 2883_infantry_road_ii huawei 3g ip bts3 2 bangalore 2884_dvg_road huawei 3g nbsnl bts1

angularjs - using nginx to serve angular-seed basic project -

i've cloned angular-seed project, ran npm install , npm start, , worked fine. then wanted use different web server, not dev 1 comes npm, production one, see if can configure angular seed basic state (view1, view2) work nginx. i've had nginx.conf file different project know working on, , took , tried make work. serves index.html fine, when try switch view2 or view1 (from partial views) - nothing. navigates right address (i see updates address #/view1 ) content stays same. conf file: server { listen 80; listen [::]:80 ipv6only=on default_server; server_name localhost; charset utf-8; # max upload size client_max_body_size 75m; # frontend root folder root /myapp/app; location / { try_files $uri $uri/ /index.html?/$request_uri; } } the structure of angular-seed can found here: https://github.com/angular/angular-seed i know basic, i've tried different conf files , nonthing works. know order of files in location blo

reactjs - What is the use of Redux-Router in addition to reac-router? -

guys. when go through documentation of redux-router, cannot understand why need it? here documentation trying explain: react router fantastic routing library, 1 downside abstracts away crucial piece of application state — current route! abstraction super useful route matching , rendering, api interacting router 1) trigger transitions , 2) react state changes within component lifecycle leaves desired. it turns out solved these problems flux (and redux): use action creators trigger state changes, , use higher-order components subscribe state changes. this library allows keep router state inside redux store. getting current pathname, query, , params easy selecting other part of application state. as far can understand, trying redux router can keep router state inside redux store can route info more conveniently. but within react-router, can it. path="messages/:id", can use this.props.params.id params. can explain in scenario redux

c - Can not understand this pi calculate algorithm -

i saw pi calculate algorithm on website , looks that: #include <stdio.h> int a[52514],b,c=52514,d,e,f=1e4,g,h; main(){ for(;b=c-=14;h=printf("%04d",e+d/f)){ for(e=d%=f;g=--b*2;d/=g){ d=d*b+f*(h?a[b]:f/5); a[b]=d%--g;} } } it said code based on expansion,but not understand relative between code , expansion. pi= sigma( (i!) ^2*2^(i+1))/(2i+1)! (i=0 infinite) could me explain it?thanks. pi+3=sigma( (m!)^2 * 2^m * m / (2*m)! ) (m=1 infinite). algorithm's s pflouffe use it.

How many layout resource folders do i really need to cover all android devices -

Image
i have found many questions , answers on topic , have read through developer guidelines many different device sizes out , no doubt more new sizes in future, best practice cover of these? have seen people mention using layout-small layout-normal layout-large layout-xlarge, enough cover majority of devices out! have seen others not use them deprecated , instead should use layouts smallest width i.e layout-sw380dp layout-sw480dp , forth. in mind find self mixing layouts , honest gets confusing! take @ picture example i have many layouts, need of these? experienced android developers ask, how many , layout resource folders use target huge range of devices out there? usually keep auto-generated directories because "default" structure can create application many devices. if want create app uses more graphical details, should use created directory in screenshot edit: default structure = auto-generated directories new project android studio :)

java - CredentialHandler encoding in base64 with Tomcat 8 -

i'm trying configure credentialhandler in tomcat 8 (8.0.36). password in db hashed md5 , encode in base64 i'm trying following configuration in context.xml <realm> <credentialhandler classname="org.apache.catalina.realm.messagedigestcredentialhandler" algorithm="md5" encoding="base64"/> </realm> when present, encoding attributes ignored. , credentialhandler work when password hashed without encoding afterward. did missuse encoding attribute ? thanks, arthur

Getting json response for android from PHP -

i newbie in php, kindly pardon me if looks silly. still learning step step of online forums , stack community. i have form online code below: <?php define('dir_application', str_replace('\'', '/', realpath(dirname(__file__))) . '/'); include(dir_application."config.php"); ob_start(); session_start(); $msg = 'none'; $sql = ''; if(isset($_post['email']) && $_post['email'] != '' && isset($_post['password']) && $_post['password'] != ''){ if($_post['usertype'] == 'admin'){ //here admin $sql= mysql_query("select * admin a_email = '".make_safe($_post['email'])."' , password = '".make_safe($_post['password'])."'",$link); } else if($_post['usertype'] == 'teacher'){ //here teacher $sql= mysql_query("select * teacher t_email = '&qu

java - Hibernate query for multiple associations -

i have following structure in java. public class article { private long id; private source source; } public class source { private long id; private type type; } public class type { private long id; private string sourcetype; } how query articles type.id = somevalue using hibernate criteria. right can query until source class this criteria query = currentsession().createcriteria(article.class) .createalias("source", "s") .add(restrictions.eq("s.id", long.parselong(typeid))); try this criteria query = currentsession().createcriteria(article.class) .createalias("source", "s") .createalias("s.type","t") .add(restrictions.eq("t.id", long.parselong(typeid)));

html - Whatsapp: Un able to share current link with Javascript -

i trying share current link in whatsapp using following javascript , html <script language="javascript"> function wacurrentpage(){ return "whatsapp://send?text=check out: "+'http://' + window.location.hostname + window.location.pathname; } </script> <a class="btn btn-social-icon btn-whatsapp" href="javascript:wacurrentpage()" data-action="share/whatsapp/share"><i class="fa fa-whatsapp"></i> </a> i have have no idea why not working getting output in browser after pressing button: whatsapp://send?text=check out: http://bggressive.nl/test/index.html try this: <a class="btn btn-social-icon btn-whatsapp" href="javascript:window.location=wacurrentpage();">link</a> js: wacurrentpage = function() { return encodeuri("whatsapp://send?text=check out: " + 'http://' + window.location.hostn

ios - cellForItemAtIndexPath indexPath not called for multiple collection views in a single UIViewController -

i trying have multiple collection views in single view controller. have tried achieve using separate tags each collection views, seems me celforitematindexpath not being invoked. following code uiviewcontroller . import uikit class homeviewcontroller: uiviewcontroller { // mark: - iboutlets @iboutlet weak var backgroundimageview: uiimageview! @iboutlet weak var collectionview: uicollectionview! @iboutlet weak var friendscollectionview: uicollectionview! // mark: - uicollectionviewdatasource private var interests = interest.createinterests() private var friends = friends.createfriends() override func preferredstatusbarstyle() -> uistatusbarstyle { return .lightcontent } override func viewdidload() { super.viewdidload() self.collectionview.tag = 100; self.friendscollectionview.tag = 200; collectionview.registerclass(nsclassfromstring("interestcell"),forcellwithreuseidentifier:"cell"); friendscollectionview.regi

scripting - How do I specify the MATLAB editor keybindings programmatically -

i want setup keyboard keybindings windows default set , @ startup using startup.m because want setting set on large number of systems. the equivalent setting in preferences dialog is: matlab > keyboard > shortcuts > active settings: windows default set. proposal of startup.m after suever's answer see line 8 % todo set startup script in $home/documents/bin/matlab/startup.m in terminal % commands here run @ startup etc startup.m % todo set user path relative $home/documents/bin/matlab/ %userpath('/home/masi/documents/bin/matlab/') % todo how set userpath outside matlab script in terminal? % http://stackoverflow.com/a/38188945/54964 if ( not( com.mathworks.services.prefs.getstringpref('currentkeybindingset') == 'windows' ) ) com.mathworks.services.prefs.setstringpref('currentkeybindingset', 'windowsdefaultset.xml') end % event errors else touchpad scroll !synclient horiztwofingerscroll=0 matlab: 2016a system

css - iOS UIWebView totally fails to understand more than one @font-face? -

Image
notice simple css/html being displayed in local uiwebview: there's simulator showing it... notice there 2 @font-face definitions. but ... only second 1 works. if swap them around, second 1 works. so here ... @font-face { font-family:'aaa'; src: local('sourcesanspro-regular'), url('sourcesanspro-regular.ttf') format('truetype'); } @font-face { font-family:'bbb'; src: local('sourcesanspro-boldit'), url('sourcesanspro-bolditalic.ttf') format('truetype'); } only "bbb" works , other 1 seems "cancelled". here .. @font-face { font-family:'bbb'; src: local('sourcesanspro-boldit'), url('sourcesanspro-bolditalic.ttf') format('truetype'); } @font-face { font-family:'aaa'; src: local('sourcesanspro-regular'), url('sourcesanspro-regular.ttf') format('truetype'); } only "aaa" works , other 1 seems "cancelled&

javascript - Closures inside loops and local variables -

this question has answer here: javascript closure inside loops – simple practical example 32 answers i js novice , reading closures, common issues arise due misunderstanding how closures work , "setting handlers inside loop" pretty example. i've seen , understood ways around this, i.e, calling function passing loop variables arguments , returning function. tried take dip see if there other ways around , created following code. var i; var inparr = new array(); for(i = 0; < 10; ++i) { inparr.push(document.createelement("input")); inparr[i].setattribute("value", i); inparr[i].onclick = function() { var index = i; alert("you clicked " + index); } document.body.appendchild(inparr[i]); } it doesn't work guessed don't understand why. understand i captured , made available function expressions ge

Rails: Javascript for tracking sessions firing inconsistently -

i have js code in rails app fires tracking event mixpanel on new session. theoretically, before other event fired, should see "new session" event first. on visits, don't see "new session" event means it's not being fired on occasions. what's wrong below code? $(function(){ var currentlocation = window.location.hostname; var lastlocation = document.referrer; if (lastlocation.indexof(currentlocation) > -1) { } else { mixpanel.track("new session", {}); } mixpanel.track("page view", {}); }); if you're using turbolinks ready event not fired after first page load, need bind custom turbolinks events page:load like: var ready; ready = function() { var currentlocation = window.location.hostname; var lastlocation = document.referrer; if (lastlocation.indexof(currentlocation) > -1) { } else { mixpanel.track("new session", {}); } mixpanel.track("page view", {}); }

http - Why do my AngularJS custom Interceptor not working -

i have been following article http://www.webdeveasy.com/interceptors-in-angularjs-and-useful-examples/ make interceptor add server based token request. have made following code in js file. in below file sessionholder file stores token on login. hard-coding text. (function (module) { module.factory('sessionmanager', ['sessionholder', function (sessionholder) { console.log("reached sessionmanager"); var sessionmanager = { request: function (config) { //if (sessionholder.validation_capability) { config.headers['x-session-token'] = 'saurabh'; config.headers['baap'] = 'saurabh';//sessionholder.authorisationtoken; //} return config; } }; return sessionmanager; }]); }(angular.module("marketplan"))); where "marketplan" ng-app. now in app.js file, doing followin

typescript - Angular2 - Pipes and syntax -

im trying create lowercase pipe in angular2 , im running issues im getting syntax errors got ';' app/lowercase.ts import {pipe, pipetransform} '@angular/core'; @pipe({ name: 'lowercase1'}) export class lowercasepipe1 implements pipetransform { transform (value: string): string { if (!value) return value; if (typeof value !== 'string'){ throw new error('invalid pipe value: ', value); } return value.tolowercase(); } } app/app.component.ts import {component} '@angular/core'; import {lowercasepipe1} './lowercase'; @component({ selector: 'app', pipes: [lowercasepipe1], template: '<h1>{{"sample" | lowercase1 }} </h1>' }) export class app { console.info('lower case app') } app/index.ts import {bootstrap} '@angular/platform-browser-dynamic'; import {app} './app.component'; // bootstrap(app) here plunkr: http://pln

Java REST server the enterprise way -

i have web app uses php backend. server gets requests , sends data in json. in sense simple rest server. want reimplement server in java. technology/framework should use. more like, how enterprise solution like? the question of poor quality. can simple google search spring (spring boot: latest light weight 1 of spring) struts play sparkjava dropwizard and on popular java frameworks... each has own advantage. spring strongest , vast one. suggest spring if heavy application. else can go of them. see this all of them rest supported

java - Multiple RadioButtons with one selectable value -

so i'm have 2 radiogroups, 1 gender, 1 unit type. user has select value both radiogroups, value of first selected group affects value of secont group. for example, if user male , uses metric unit type 1 layout shown him. if he's male uses imperial unit, layout shown him. my question is, how have radiobutton onclick method inside of radiobutton onclick method? sorry, don't know how explain better. here's code: public void dialogbodyfatmuskarciradiobuttonkliknut(view view){ boolean checked = ((radiobutton) view).ischecked(); switch (view.getid()){ case r.id.radiobuttondialogbodyfatspolmuski: if (checked) public void dialogbodyfatradiometrickajedinica(view view){ boolean checked = ((radiobutton) view).ischecked(); switch (view.getid()){ case r.id.radiobuttondialogbodyfatspolmuski: if

Java 8 lambda null check usage -

i have scenario checking multiple attributes inside class null check.if not null , calling method create me new object , need capture instance against reference.i succesasfully able null check using maps unable write code me in capturing return object after invocation.can please ? private workflowpreference buildwfprefdetails(ccarreportpreferenceconfig ccarreportpreferenceconfig) { workflowpreference workflowpreference = new workflowpreference(); list<payloadentry> payloadentries = new arraylist<payloadentry>(); optional.of(ccarreportpreferenceconfig) .map(ccarreportpreferenceconfig::getrwprole) .map(rwprole::getrolename) .ifpresent(s -> workflowpreference.setkey(s)); optional.of(ccarreportpreferenceconfig) .map(ccarreportpreferenceconfig::getsequencenumber) .ifpresent(s -> buildpayloadentry("seq_num", s)); optional.of(ccarreportpreferenceconfig) .map(ccarreportpreferenceconfig::ge

java spring named query and property file -

how use named query. example: public interface extends base<someclass, long> { @query(value = "select sum(d.is_open) vw_view d d.value=?1", nativequery = true) someclass getvalue(long value); } how can save sql query properties file (not xml, not in java class) , send name parameter? could proceed example: this generic select query on basis of primary key query1=select {0} {1} {2} = {3} then can @ time of retrieving query can use this property = messageformat.format(query1,new string[]{"org_id","organization","primary-key","454545452"}); similarly can generalize queries , set values in java code. depends on level of generalization want.

Android: setOnClickListener for children of RelativeLayout -

i use relativelayout but children of layout not work settext , click , ... how fixed ? code : imageview imageview01 = (imageview) findviewbyid(r.id.imageview01); if (imageview01 != null) { imageview01.setonclicklistener(new onclicklistener() { public void onclick(view arg0) { log.i("error", "q" + 108); } }); } this code linearlayout child of relativelayout xml : <linearlayout android:id="@+id/lnrvideocontrol" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imageview android:id="@+id/imgplayvideo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.5" android:focusable="false" android:src="@drawable/play" /> <linearlayout android:layout_width="match_parent"

angularjs - Private video via REST api -

hi i'm trying implement auth protected audio/video stream in angular app via rest api. goal secure audio/video not shared other not logged users. tried single use token flow looks this: angular ask single use token after click play button post: file/1/token angular token , paste token url ?token=... stream request send server get: file/1?token=... server checks token , removes database if token right stream begin the problem came when click on timeline stream not buffered yet browser automatically sends request of course unauthorized because token has been removed. i want keep api stateless see kind of state forced html media. i love hear hints or solutions on problem. problem solved now. maybe it's not best solution covers requirements. decided use session breaks rest principles works. now getting token before post: file/1/token getting file provided token get: file/1?token=... the difference in controller open new php session, save token sessi

jsp - java.lang.NoClassDefFoundError: com/opensymphony/xwork2/ModelDriven -

i getting error while running login application in struts .every required jar installed saw many solutions of missing jar xwork-core-2.3.24.1 .i did solution still getting same error. i pasting struts.xml , web.xml file here: <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="webapp_id" version="2.5"> <context-param> <param-name> org.apache.tiles.impl.basictilescontainer.definitions_config</param-name> <param-value>/web-inf/tiles.xml</param-value> </context-param> <listener> <listener-clas

javascript - Uploading Image with Bootsrap Modal -

i have problem uploading image bootsrap modal. problem if have selected image, validation error "your upload form empty". here's form sript on view <div class="modal fade" id="modal_form" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button> <h3 class="modal-title">user form</h3> </div> <div class="modal-body form"> <form action="#" id="form" class="form-horizontal" enctype="multipart/form-data"> <input type="hidden" value="" name="id_berita"