Posts

Showing posts from March, 2014

html - How to place text around image which is pasted by :before? -

i making block image , text after layout not working. trying float:left , image still upper text. maybe not working because using flexbox mostly? here html: <div class="info info-1"> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. proin nisi ligula, dapibus volutpat sit amet, mattis et dui. nunc porttitor accumsan orci id luctus. phasellus ipsum metus, tincidunt non rhoncus id, dictum lectus. nam sed ipsum lacus sodales eleifend. vestibulum lorem felis, rhoncus elementum vestibulum eget, dictum ut velit. nullam venenatis, elit in suscipit imperdiet, orci purus posuere mauris, quis adipiscing ipsum urna ac quam.</p> </div> and css: .info { cursor: pointer; background: lightgrey; margin: 10px 15px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; } .info p { margin: 0px; font-weight: normal; font-size: 12px; } .info p:before { content: url("http://cs6043

Safe to pass current $scope from controller to angularjs service function -

within angular controller attaching websocket service. when controllers scope destroyed want remove subscription. is safe pass current scope service subscription function can auto remove on scope destroy? if dont each controller attaches socket listener has remember clean up. basically safe pass current $scope service function or there better way of doing this? i had similar need in project. below object returned in angularjs factory (which initializes websocket). onmessage method automatically unsubscribes callback if pass in associated scope in second argument. io = onmessage: (callback, scope) -> listeners.push callback if scope scope.$on "$destroy", => @offmessage callback offmessage: (callback) -> listeners.remove callback the javascript equivalence below. var io = { onmessage: function(callback, scope) { var _this = this; listeners.push(callback); if (scope) { scope.$on("$destroy", function(

ms access - Select from another database table which have ] in her path -

with access 2002, fail escape ] character in database path in query : select * [ms access;database=d:\bd].mdb;].[mytable]; what i've tried , doesn't work : select * ["ms access;database=d:\bd].mdb;"].[mytable]; select * [ms access;"database=d:\bd].mdb";].[mytable]; i didn't found in msdn documentation escaping path : http://msdn.microsoft.com/en-us/library/office/ff194542.aspx (i don't want use link tables because query in fact export data excel or db select * [text;database=d:\;hdr=yes].[csvfile.csv] mytable;) try query.. select [otheraccessdb].* [otheraccessdb] in 'd:\bd].mdb' or if ] isn't required... select [otheraccessdb].* [otheraccessdb] in 'd:\bd.mdb'

javascript - array filtering does not work as expected -

i have array of objects , wanna filter them based on size, color , collar. everything works expected whenever uncheck checkbox when re-check again brings unwanted objects. var database = [ {id:0o1, size: "xl", color:"red", collar: "v-neck"}, {id:0o2, size: "s", color:"blue", collar: "regular"}, {id:0o3, size: "xxl", color:"red", collar: "scoop"}, {id:0o4, size: "l", color:"green", collar: "v-neck"}, {id:0o5, size: "xl", color:"blue", collar: "turtle-neck"}, {id:0o6, size: "l", color:"red", collar: "v-neck"} ]; window.onload = function () { var vneckcollarcheckbox = document.queryselector('#vneck-collar-checkbox'); var xlsizecheckbox = document.queryselector('#xl-size-checkbox'); var redcolorcheckbox = docume

mysql - Automatically calculate a database field from another table with a foreign key relation -

i have 2 tables: table column a-id , double field column total amount, table b foreign key column a-id , amount column. i want total amount in table change automatically, depending on field. is behavior possible implement? essentially, i'd field hold query runs every time add/delete/update row in table b. i'm using phpmyadmin (if it's relevant). i've tried using following queries: take current total amount , put them in variable named i. make changes in table b. update new total amount in table a. however, hasn't been efficient. don't that. calculate values on-the-fly in single query. need join tables that select *, a.amount + b.amount total_amount tablea inner join tableb b on a.a_id = b.a_id

ggplot2 - R ggplot geom_jitter duplicates outlier -

Image
q1. plotting dataset using ggplot's geom_boxplot. however, when trying plot data points using geom_jitter(), outlier have in data duplicated. other data points fine. problem? sample code: peakperiod_24h <- c (31.05820, 23.83500, 24.36254, 25.31609, 24.21623, 23.90320) condition <- rep("hl",6) data_hl <- data.frame(condition, peakperiod_24h) p <- ggplot(data_hl, aes(x=condition, y=peakperiod_24h, fill=condition)) p + geom_boxplot()+ geom_jitter(width = 0.3)+ theme_bw()+ coord_flip()+ geom_hline(aes(yintercept=24.18), colour="brown1", linetype="dotted", size = 1.4)+ scale_y_continuous(limits=c(), name = "period length")+ ggtitle("boxplots\nhabitual light")+ scale_fill_manual(values = c("gray60"))+ theme(plot.title = element_text(size=14, face="bold", vjust = .5), axis.title.y = element_blank(), axis.text.y = element_blank(), axis.title.x = element_text(size=12, face

Must I create an activity for each page of my book reader app in android -

i creating app in android loads text(html) , images, app book. have listview search box on top. on selecting item, (which page) app loads user read. stuck in have created activity each page. wanted reuse 1 activity named displayactity , activity contains webview display content. somehow still android newbie must in many pages have , create many activities number of book pages? no. when user elects switch pages, update content in existing displayactivity . example, if displayactivity shows content via webview , update webview newly-selected page.

sql execution plan - SQL chain AND operator, all executed? -

i wondering if in sql request using several , statement, every , executed or triggered when previous , ok? in example : select * my_table when > 5 , b < 10 if condition > 5 not respected, test b < 10 triggered? or in java triggered when > 5 valid? thanks ;) bye ! in general, sql engines implement "short-circuiting", meaning execution of conditions stops when final value known. however, pretty unimportant. first, cannot depend on order of evaluation of conditions. so, don't know evaluated first. second, engine may use alternative execution paths (such using indexes). and, finally, short-circuiting typically has minimal impact on performance. reading data typically more important. 1 exception when 1 of conditions uses complex functions. in case, use case or subqueries ensure order of execution.

css - How can I draw this background without a real BG image (using canvas/css3?) -

Image
im building app using ionic2 , need add background (light blue lines) app background: , don't want import image (using html5 canvas &/or css3). anyone can me it? here css: { width: 100%; height: auto; background-repeat: no-repeat; background-size: 100% 100%; background-color: #01c4cd; } thank you! you don't need canvas or background image. can achieve css gradients: #background { width: 300px; height: 400px; background-image: /* line 1 */ linear-gradient(45deg, rgba(255,255,255,0) 63%,rgba(255,255,255,0.1) 64%,rgba(255,255,255,0) 65%), /* line 2 */ linear-gradient(45deg, rgba(255,255,255,0) 78%,rgba(255,255,255,0.1) 79%,rgba(255,255,255,0) 80%), /* blue background gradient */ linear-gradient(45deg, #1f579b 0%,#7bdce5 100%); } <div id="background"></div> there's few different ways achieve this, in example there's 1 di

ruby on rails - Best use of content_tag in a custom link_to helper method -

what best way use custom helper method in order generate html tags links , html options? lets def drop_document_options(title,document,version,html_options) end in order generate link parameters: <div class="dropdown"> <button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown"> <%=@hebrew_document[document]%> - <%=@hebrew_version[version]%> <span class="caret"></span></button> <ul class="dropdown-menu dropdown-menu-right"> <li> <%=link_to( {:controller => "invoices", :action => "download", :id => document.id, :disposition => 'inline', :version => version[i]} , html_options ) %> <%=action_title%> <% end %> </li> &l

How To Select all input type file by jquery -

select type every element <input type="file" name="userfile" > whit code can select input whit type file. $('input[type="file"]')

regex - Why this apache rewrite fail? -

i'm using vbulletin 5 , routes requests index.php using rule # main redirect rewritecond %{request_uri} !\.(gif|jpg|jpeg|png|css)$ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?routestring=$1 [l,qsa] it working fine had weird issue .. when click url contating arabic letter "م" redirect fails , 404 ( apache not vbulletin ) for example http://localhost/vb5/forum/main-forum/27-مدرسة solved issue replacing rule rewriterule ^(.*)$ index.php?routestring=$1 [l,qsa] with rewriterule ^([^.]+) index.php?routestring=$1 [l,qsa] and working fine .. i'm curious know why first 1 not working in scenario !

python-requests cookies export session to selenium -

i want export cookies session python-requests selenium, im write code : import requests selenium import webdriver session=requests.session() myheaderss = {"user-agent":"mozilla/5.0 (windows nt 10.0) applewebkit/537.32 (khtml, gecko) chrome/48.0.2564.109 safari/537.32", "x-gwt-permutation" : "6fefbe57c6e73f0ab33bd5a4e17945de", "content-type":"text/x-gwt-rpc; charset=utf-8"} login_data = '''7|0|7|https://www.cartetitolari.mps.it/portaletitolari/|feac78ffdf81d6121438d70986af1c41|portale.titolari.client.service.ptservice|login|portale.titolari.client.common.login.loginrequest/3583069702|xxxxxxxxxxx|matteosbragia1984|1|2|3|4|1|5|5|0|0|6|7|''' ra0=session.post('https://www.cartetitolari.mps.it/portaletitolari/service', data=login_data, headers=myheaderss) print ra0.content profile = webdriver.firefoxprofile() profile.set_preference("general.useragent.override", "mozilla/5.0

laravel - Sort by average value of an one to many related table column -

i have 2 models; post , rating the rating model contains amount column specifies how high has been rated. based on 5 star rating amount can value 1-5 the post model has 1 many relation rating model , function called ratings returns hasmany. i'd 5 latest posts based on average rating. average rating i've created function can seen below note : plural(ratings) returns hasmany relation singular(rating) returns value average rating public function rating(){ return floor($this->ratings()->avg('rating')); } is possible retrieve posts ordered avg rating using eloquent querybuilder? currently i'm retrieving posts , using sortby method on collection object in order ones highest average rating. way i'm doing can seen below. $posts = post::all(); $posts = $posts->sortbydesc(function ($post, $key) { return $post->rating(); }); now if i'd want show 5 still have retrieve , sort doesn't seem resource friendly(in eyes. don&

html - Make absolute div height 100% -

Image
i have parent div position relative , 2 child divs (left , right) absolute positioning. left div should of height: 100% , right div content changes dynamically. when scroll left child remains smaller (not 100%) , right div had height. there horizontal navigation-bar on top of parent div. tried bottom: 0 , position: fixed , results not good. .left-sidebar { font-weight: 400; background-color: #b3e5fc; display:inline-block; width: 29%; left: 0; z-index: 2; box-shadow: 5px 10px 10px 0px grey; height: 92vh; position: absolute; } .right-content{ display: inline-block; // height: 100%; position: absolute; left:0; right: 0; padding: 1em; min-width: 66%; } .main-parent { position: relative; } you don't need position:absolute need give height:100% body / html , .main-parent * { box-sizing: border-box } body, html { margin: 0; height: 100% } .main-parent { height:100% } .

c# - Does ThreadPool.RegisterWaitForSingleObject block the current thread or a thread-pool thread? -

from reading the documentation of threadpool.registerwaitforsingleobject method, not clear whether: it blocks current thread while waiting on eventwaithandle , commissions waitortimercallback on thread pool thread, or it commissions thread pool thread wait on wait handle , on same thread execute waitortimercallback once wait handle has been signaled. it blocks current thread , when wait handle signaled, calls waitortimercallback on current thread. equivalent functionality of waithandle.waitone() . also, not involve thread pool @ all. which of 3 do? it none of above, 2) closest. exact details pretty convoluted, of code buried in clr , has changed across .net versions. can have look-see @ current version in coreclr source , i'll give 10,000 feet view. key doesn't block, work done dedicated unmanaged thread. called "wait thread" in source code, uses waitformultipleobjects() winapi function wait on registered waits. if there none (left) sle

android - Navigation view handle back button on fragment -

hi need handle button on fragment. using navigation on mobile apps. question how handle button when open new fragment page? i try using below code on new fragment. actionbar.setdisplayshowhomeenabled(true); actionbar.setdisplayhomeasupenabled(true); but when click button , navigation open. solution ? thanks as know whenever user presses back button need go loaded fragment , try (note fragment must added transaction.addtobackstack(null); ) @override public boolean onoptionsitemselected(menuitem item) { if (item.getitemid() == android.r.id.home) { int backstackcount = fragmentmanager.getbackstackentrycount();//check how many frags loaded if (backstackcount > 0) { fragmentmanager.popbackstack(); //go loaded fragment } } return super.onoptionsitemselected(item); } happycoding;

angularjs - Datatables search, filter, and export with Firebase -

i have crud app powered angular. added datatables in order search, filter, sort,export , hide columns using power of datatables. unfortunately returns firebase references in various columns {{contact.name}} {{contact.email}} (there 4 more columns) when use datatables feature such search returns firebase reference instead of field. there way fix this? need datatable features @ same time use firebase. $(document).ready(function() { $('#contacts').datatable( { dom: 'bfrtip', buttons: [ 'copyhtml5', 'excelhtml5', 'csvhtml5', 'pdfhtml5' ] } ); } ); <table id="contacts" class="table table-striped table-hover" > <thead> <tr> <th>name</th> <th>phone</th> <th>area</th> <th>occupation</th> <th>e-mail</th>

java - Separate logic from logging via template method pattern -

may use template method pattern separate logic logging , exception handling or "bad practice"? for example have code: public abstract class parent { private final logger log = loggerfactory.getlogger(getclass()); public void eat() { try { doeat(); } catch (someexception1 e) { log.debug("some text"); throw new customexception1(); } } protected abstract void doeat(); public void sleep() { try { dosleep(); } catch (someexception2 e) { log.debug("some text"); throw new customexception2(); } } protected abstract void dosleep(); } and child class: public class child extends parent { @override protected void doeat() { //some logic } @override protected void dosleep() { //some logic }} i not have different implementations of methods doeat() , dosleep() . i want know whether it's worth , 'bad practice' or not. if pattern solves problem havi

c# - Removing Default Properties in Serilog Output -

in serilog output in file, see default is { "timestamp": "2016-05-28t21:21:59.0932348+08:00", "level": "information", "messagetemplate": "processed {@number} records in {@time} ms", "properties": { "number": 500, "time": 120 } } is there way remove timestamp, level, messagetemplate, , properties i"m left only { "number": 500, "time": 120 } the log.logger assigned such log.logger = new loggerconfiguration() .writeto.sink(new filesink(configurationmanager.appsettings["serilogpath"], new jsonformatter(), null)) .createlogger(); thanks from looking @ source code , doesn't jsonformatter supports skipping default properties. create own itextformatter you're looking for. here's quick example (that should not used in production because doesn't escaping -

maven - CSS images not loaded myfaces and primefaces, #{resource['image...']} not working -

i tried many forum didn't found solution working solve problem. using maven project in eclipse make website using myfaces , primefaces. using apache tomcat 8.0.28. everything in project works fine except loading of images css file. include css in xhtml template files using (between <h:head></h:head> ) : <h:outputstylesheet name="css/styles.css"/> my css under /resources/css loaded correctly. not images inside it. tried these solutions : - background-image: url("#{resource['images/image.jpg']}"); - background: #fff url(../images/image.jpg); - background: #fff url(../images/image.jpg.xhtml); -> works don't know why ?? the last line working in first time used solution problem incountered own images has been incountered primefaces css images... enter image description here note : when use <h:graphicimage name="images/image.png"> inside xhtml works ! here project structure my web.xml : <?xm

python - How to convert "01 January 2016" to UTC ISO format? -

so have following string : " 01 january 2016" utc iso date format ? i'm using arrow module , following code, it's full of errors, , thinking may be, there smaller more elegent solution python encourages elegant , easier ways things, anyways here's code : updatestr = " 01 january 2016" #note space @ beginning datelist = updatestr.split[' '] datedict = {"day" : datelist[1],"month": months.index(datelist[2])+1, "year" : datelist[3]} datestr = str(datedict['day']) + "-" + str(datedict["month"]) + "-" + str(datedict["year"]) dateiso = arrow.get(datestr, 'yyyy-mm-dd hh:mm:ss') please me have convert utc iso formats, months list of months in year . you can use datetime : >>> updatestr = " 01 january 2016" >>> import datetime dt >>> dt.datetime.strptime(updatestr, " %d %b %y") datetime.datetime(2016, 1,

python - django dumpdata empty array -

i new django , using make website online game. game has it's own auth stuff using custom auth model django. i created new app called 'account' put stuff in , added models. added router , enabled in settings , works good, can log in admin site , stuff. now trying learn tdd, need dump auth database fixture. when run ./manage.py dumpdata account empty array back. there aren't errors or trace ever, empty array. i've fiddled best can can't seem find issue is. here relevant settings. database databases = { 'default': { 'engine': 'django.db.backends.postgresql_psycopg2', 'name': 'censored', 'user': 'censored', 'password': 'censored', 'host': 'localhost', 'port': '', }, 'auth_db': { 'engine': 'mysql_pymysql', 'name': &

what is the c/c++ virtual machine referred to in the asm.js spec -

in spec asm.js (at http://asmjs.org/spec/latest/ ) in introduction section says "the asm.js language provides abstraction similar c/c++ virtual machine" ..but can't find information on 'the c/c++ virtual machine' googling. can enlighten me or point me in direction of book/website describes 'the c/c++ virtual machine' the c standard talks abstract machine makes assumptions about. suppose author of asm.js talks about.

How do you *get* the number of threads for BLAS operations in Julia? -

julia's blas library has function set_num_threads() sets threads blas operations. how get number of threads being used default, or currently? if have julia linked against openblas, case if use windows, mac or generic linux binaries julialang.org, or if build source , don't set use_system_blas=1 , number threads used openblas calling ccall((:openblas_get_num_threads64_, base.libblas_name), cint, ()) . eventually, we'll provide julia function.

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot

angular - Angularfire 2 Error: The specified authentication provider is not enabled for this Firebase -

Image
i creating simple sample auth app ionic 2 , angularfire 2 backend, when try create new user says: exception: error: uncaught (in promise): error: specified authentication provider not enabled firebase. but enabled firebase authentication in firebase console: app.ts import {app, platform} 'ionic-angular'; import {statusbar} 'ionic-native'; import {homepage} './pages/home/home'; import { firebase_providers, defaultfirebase, firebaseauthconfig, authproviders, authmethods } 'angularfire2'; @app({ template: '<ion-nav [root]="rootpage"></ion-nav>', providers: [ firebase_providers, defaultfirebase('https://samplequizapp-50eb5.firebaseio.com'), firebaseauthconfig({ provider: authproviders.password, method: authmethods.password }) ], config: {} // http://ionicframework.com/docs/v2/api/config/config/ }) export class myapp { rootpage: = homepage; constructor(platform:

bigdata - Alter column data type in Hive -

we need alter table column data type string date. while trying getting below error. please help. hive> describe sales_staging; ok cust_id string prod_num string qty int sale_date string sale_id string time taken: 0.151 seconds, fetched: 5 row(s) hive> alter table sales_staging change sale_date sale_date date ; failed: execution error, return code 1 org.apache.hadoop.hive.ql.exec.ddltask. unable alter table. following columns have types incompatible existing columns in respective positions :sale_date hive> you can't give same name column wish change datatype of. use this alter table sales_staging change sale_date sale_date_new date; refer apache hive wiki

qt - How to highlight QTreeWidgetItem text -

Image
when button clicked need tree-item turn highlighted (editing mode) (see image below). have double-click item set in highlighted mode. how achieve this? from pyqt4 import qtcore, qtgui app = qtgui.qapplication([]) class dialog(qtgui.qdialog): def __init__(self, parent=none): super(dialog, self).__init__(parent) self.setlayout(qtgui.qvboxlayout()) tree = qtgui.qtreewidget() self.layout().addwidget(tree) button = qtgui.qpushbutton() button.settext('add item') self.layout().addwidget(button) button.clicked.connect(self.onclick) item = qtgui.qtreewidgetitem() item.setflags(item.flags() | qtcore.qt.itemiseditable) item.settext(0, 'item number 1') tree.addtoplevelitem(item) def onclick(self): print 'onclick' dialog=dialog() dialog.show() app.exec_() from pyqt4 import qtcore, qtgui app = qtgui.qapplication([]) class itemdelegate(qtgui

java - Executor Service framework with consumer code -

i planning write code that's similar producer , consumer using executorservice fixed threadpool , ibm mq messaging. suppose consumer created 10 fixed threads. how handle if place 10 messages in consumer queue? how 10 consumer worker threads cover below scenarios? each worker thread take single message synchronously , process message? each consumer worker threads take these 10 message 1 worker thread per 1 message? after reading message second scenario above ,how each thread call executor service.is done concurrenly or synchronously. if there 20 messages in queue,how consumer worker thread takes these message,each thread takes 2 messages? if takes 1 message per 1 thread happen other 10 messages? while processing above scenarios there webservice call , internal api method calls synchronous methods. there use if implement class process code concurrently? i don't think it's idea implement producer/consumer scheme when have tools jms implemented, de

c# - how can i modify a small section of bytes in a memory stream, that was written to using binarywriter -

how edit first 4 bytes in memory stream? imagine "bytes" in following code few 100 bytes long. need write place holder of say, 4 bytes of value 0 , come , update bytes new values. static memorystream stream = new memorystream(); static binarywriter writer = new binarywriter(stream); writer.write(bytes); how solution: static void updatenthlong(memorystream ms, long idx, long newvalue) { var currpos = ms.position; try { var offset = sizeof(long) * idx; ms.position = offset; var bw = new binarywriter(ms); bw.write(newvalue); } { ms.position = currpos; } } static void showbytearray(byte[] array) { console.writeline("size: {0}", array.length); for(int = 0; < array.length; i++) { console.writeline("{0} => {1}", i, array[i]); } } static void main(string[] args) { using (var ms = new memorystream()) { var bw = new binarywriter(ms); bw.write(1

java - Maven test depends on jar in target but that gets only created after the test succeeds -

i have test requires compiled jar in target directory: software interacts other programs started separate process , test test starts small program jar of own package. can "bootstrapped" first running build , skipping tests , running build again - not ideal. is possible create pom first compile, create jar in target (or somewhere else) allow test run , if fails maybe remove jar again? or if jar created anywhere else testing in addition, not problem.

node.js - How can I query DynamoDB and return all child values for a specific key in an array -

i have table in dynamodb each row has following structure: { "id": 1, "data": [ { "key": "a", "value": "a" }, { "key": "b", "value": "b" } ] }, ... i create query returns single row of data "value" keys have been filtered out of results. essentially, looking way produce output: { "id": 1, "data": [ { "key": "a" }, { "key": "b" } ] } the trick "data" list contains unknown number of elements. using following code projection expressions, can close need in nodejs: var aws = require('aws-sdk'); var docclient = new aws.dynamodb.documentclient(); var params = { tablename: "mytable", key: {

arrays - Java, singleton elements modification, software patterns -

short question. gets answered pretty fast. lets have singleton this: package main.library; public enum librarysingleton { instance(new string[][]{}); final string[][] bookstore; private librarysingleton(string[][] bookstore){ this.bookstore = bookstore; } } and book class holds 3 variables: package main.library; public class book{ string author; string title; int pages; @override public string tostring(){ return ("|" + author + "|" + title + "|" + pages + "|"); } public book(){ system.out.println("error: no book information specified"); } public book(string author, string title, int pages){ this.author = author; this.title = title; this.pages = pages; } public string getauthor(){ return author; } public string gettitle(){ return title; } public int getpages(){ return pages;

php - Doubts about require and require-dev of Composer -

i'm setting composer-installable repository. read composer documentation , setup repository success following instructions. understood of difference between require , require-dev require-dev declare dependencies aren't mandatory repository works properly. however, watched composer.json of libraries on github, zend form , respect validation , and, on these 2 repositories, there packages required these repositories works , listed in require-dev . example, egulias/email-validator dependency listed in require-dev in respect validation, on this file , dependency required in order email validator works. so, why dependency isn't listed in require ? the same happens zendframework/zend-captcha , required captcha element works. this dependency required in order email validator works. it isn't. can see respect\validation\rules\email has optional dependency egulias\emailvalidator\emailvalidator . if egulias/email-validator provided, class use it , ot

JavaScript Regex: Replace |b| with <b> -

i've got funky json i'm dealing with, client sending these odd html tags, |b| , |\br| on place. want replace them , respectively. i'm trying run following str.replace function on string, can't seem target pipe characters correctly. string.replace(/[|b|]/, '<b>'); i've tried /|b|/ , /\|b\|/ any appreciated in regex, [] means "one of these characters", /[|b|]/ means | or b . you want /\|b\|/g . without g , replaces once.

android - stackoverflow error using gson -

i trying places of interest , enabled apis "google maps android api & google places api". when post url in web browser api_key. error message: " ip, site or mobile application not authorized use api key. request received ip address 212.241.70.124, empty referer". 2nd thing when run code error: " java.lang.stackoverflowerror: stack size 1036kb gson". kindly let me know doing wrong? thankful you! java code: public class foodfragment extends fragment { private supportmapfragment mapfragment; @nullable @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view= inflater.inflate(r.layout.food_layout, null); // getting map here , it's okay. googlemap(); postfetcher postfetcher=new postfetcher(); postfetcher.execute(); return view; } private class postfetcher extends asynctask<void,void,string>{ private static final string t

html - Background image doesn't show up -

i have tried following tutorials on w3schools, , i've dug developer tools on website i'm tasked cloning, , have gone previous project when had background image . i know user error, stuck. my html looks this: <section class="introduction"> <img src="background-image"> and css looks this: .introduction { background-image: url('../images/karma-background.jpg'); } you don't require image object <img src="..."> css , background images work so. <section class="introduction"></section> .introduction { background-image:url('../images/karma-background.jpg'); } so problem haven't ended section tag have in example. may have add additional css sizing

go - Building for ARM? -

whenever try , use 'go install' after settings goarch, goos , gobin 'cannot install cross-compiled binaries when gobin set', don't understand why? what's simplest way build arm linux? you can use go build command instead: env goos=android goarch=arm64 go build -o /arm64bins/app available goos/goarch 's in go 1.7: ➜ go tool dist list | grep arm 05/29/16 android/arm android/arm64 darwin/arm darwin/arm64 freebsd/arm linux/arm linux/arm64 nacl/arm netbsd/arm openbsd/arm plan9/arm

maven - Java Execute methods from different project -

i working on creating framework includes both capability execute selenium , cucumber feature files. i have cucumber descriptions on framework, , aut project , framework have maven dependency. the question is, can execute methods defined in aut project framework project?, intention able execute aut method cucumber feature file. have keyword execution class differentiate framework keywords , aut keywords.

user input - Inputting different variable types in one time in Java -

i made calculator in c++ , i'm trying recreate mirror-like in java. there 2 double variables( double a , double b )for 2 operands , char( char op ) put in if cycle, instace if op = '+' cout << << op << b << "=" << a+b << endl; . so write 12+2 in console prompt , see 12+2=14 output. now in java have 1 per line: scanner scin = new scanner(system.in); system.out.println("operation>"); = scin.nextdouble(); op = scin.next().charat(0); b = scin.nextdouble(); and have write value , press return each time. how can input in 1 time c++, , maybe in 1 line of code? in advance. you can't read in multiple variables @ once using scanner , have read them in 1 @ time. however, there nice way allow inputs occur without hitting enter each time or inputting space: set different delimiter! default delimiter whitespace (which includes newlines), set word boundary \b rege

android returning a "live" object from an AIDL bound service -

i'd create aidl service returns, lack of correct terminology, "live" objects. is, work, ifoo foo = myservice.getfoo(x); // calls myservice service ifoo ibar bar = foo.getbar(y); // ipc ifoo ibar ibaz baz = bar.getbaz(z); // ipc ibar ibaz baz.setenabled(false); // ipc ibaz modify service's copy of ibaz i expect possible, can find example. alternative like, myservice.setbazenabled(x, y, z, false); the former being more oo approach, while latter more functional. thanks. so long ifoo , ibar , , ibaz defined via aidl, should work fine.

ios - Display array from a value in the array -

so if have array this: var myarray = ["bmw", "toyota", "ford", "lamborghini", "ferrari", "lada"] i want display value inside array after "ford", bmw, toyota , ford doesn't show up.. how can this? using swift slice, e.g: myarray[3...myarray.count - 1] output ["lamborghini", "ferrari", "lada"] option 1 if don't know index of ford element, find using indexof method: if let index = myarray.indexof("ford") { let startindex = index + 1 let endindex = myarray.count - 1 let slice = myarray[startindex...endindex] let array = array(slice) print(array) // prints ["lamborghini", "ferrari", "lada"] } option 2 as @leo dabus pointed out, simpler method of getting section want array uses suffixfrom method: if let index = myarray.indexof("ford") { let slice = myarray.suffixfrom(index.

javascript - Prevent shaking on hard scroll while animating scrollTop -

i scrolling section section, if scroll harshly mouse (not 1 easy scroll) or scroll harshly on laptop touchpad, shakes , down before scrolling animation starts or jumps 2 sections! is possible make scroll smoothly , 1 section (not jump 2 sections) regardless of how hard scrolls , disable scrolling while animation taking place? my code ( jsfiddle ): var isanimated = false; var nbhdlength = $('.nbhd').length; var lastsectionid = nbhdlength - 1; var allheight = (nbhdlength - 1) * window.innerheight; var = true; function setheights() { $('.nbhd').css('height', window.innerheight); } setheights(); $('html').mousewheel(function(e) { var = e.deltay > 0; if (up) { console.log('up'); = true; } else { console.log('down'); = false; // console.log(up); } if (!up && $('#id' + lastsectionid).hasclass('scrolledto') || (!up && !$('.scrol

css3 - Issue with custom icon font rendering differently in different browsers -

Image
having issues custom icon font. renders differently between safari , chrome. appears between 1-2 pixels lower in safari. can somehow have render same in both browsers? created icon font exporting 16 x 16 px svg sketch , imported them icomoon , put optimize metrics 16 automatic. grid on icomoon chrome os x safari os x live example: http://jsfiddle.net/qq7mv/ html: <a href="" class="button increase">&#x2b;</a> css: * { box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; } @font-face { font-family: "icons"; src: url("http://cl.ly/qo0t/icons.ttf") format("truetype"); font-weight: normal; font-style: normal; } { display: block; text-decoration: none; outline: none; } .button { width: 115px; height: 37px; color: #333333; font-size: 14px; font-weight

pip - How to install a Python wheel under an alternative package name? (in my specific case, PyCryptodome under the "Cryptodome" package name) -

the installation information page of pycryptodome says following under "windows (pre-compiled)" section : install pycryptodome wheel: pip install pycryptodomex to make sure works fine, run test suite: python -m cryptodome.selftest there several problems though: contrary these instructions say, not install pycryptodome wheel, rather download , try build it, resulting in error if don't have correct build environment installed c components included in package (and entire mess related biggest benefit of using wheel instead begin with). even if instead download correct wheel file pycryptodome's pypi page , must (as far know?) instead use command-line follows install it: pip install c:\some\path\name-of-wheel-file.whl this in turn makes install under default "crypto" package instead of "cryptodome" package explicitly mentioned in instructions (and therefore colliding in brea

ruby - postgresql_adapter async_exec error on rails rspec test using Capybara + FactoryGirl -

i'm getting strange error when try run test in rails: postgresql_adapter.rb:592:in `async_exec': pg::undefinedtable: error: relation "users" not exist (activerecord::statementinvalid) i don't know if helps spec_helper.rb file looks this: require 'rubygems' env["rails_env"] ||= 'test' require file.expand_path("../../config/environment", __file__) require 'rspec/rails' require 'factory_girl_rails' require 'database_cleaner' require 'capybara/rails' require 'capybara/rspec' require 'capybara/poltergeist' require 'support/mailer_macros' require 'support/test_helper' require 'support/factory_girl_helper' activerecord::migration.check_pending! if defined?(activerecord::migration) capybara.register_driver :poltergeist |app| capybara::poltergeist::driver.new app, window_size: [1600, 1200], js_errors: false end rspec.configure |config| config.use

c++ - Expanded life-span of variables through std::unique_ptr -

with c++11 unique_ptr , object's lifespan seems extended outside of usual scope in following (rather contrived) example: #include <iostream> #include <memory> using namespace std; int main() { unique_ptr<char> uptr(nullptr); { char c = 'x'; cout << "c = " << c << endl; uptr.reset(&c); c = 'y'; } cout << "c = " << *uptr << endl; return 0; } output: c = x c = y the character c, released @ end of scope, survives until end of program. second output 'y', showing unique_ptr not copy value. is recommended extend lifespan of variable in way? safe, or carry same dangers reference? with c++11 unique_ptr, object's lifespan can extended outside of usual scope no, can't. the character c, released @ end of scope, survives until end of program. no doesn't, survives until end of scope, n

Unity3d maintaining a minimum distance between multiple GameObjects c# -

i have multiple enemies move toward player. trying stop them merging each other, i.e maintain type of minimum distance between each other. i'm trying (from unity3d forums): enemy1.transform.position = (enemy1.transform.position - enemy2.transform.position).normalized * distance + enemy2.transform.position; however, when have >= 3 enemies still seem bunch when apply every enemy combination. i need better method 1 not work , not scale. what around enemy prefab place quad box in effect trigger element, on script enemy set if enemy (using tag types, imagine) comes within touching of quad box run appropriate code stop enemy getting closer in , prevent enemy overlapping trigger box. your code example in question looks referencing enemy units rather instance entitites bad way of coding, you're finding, it's inflexible dealing not-specifically-named reference entities. using unityengine; using system.collections; public class exampleclass :

java - android - recycle adapter not appearing in the view pager -

i have tablayout in profileactivity. , 1 of tablayout display recycleview of userlist retrieve database using asynctask. use getter method return userlist asynctask class my recycleview in activity_user_view.xml , set adapter in class extends fragments. got no error tablayout doesn't appear in view pager. here code fragmentfriends.java (class extends fragment) public class fragmentfriends extends fragment { arraylist<userlist> alist = new arraylist<>(); recyclerview recyclerview; recyclerview.adapter adapter; recyclerview.layoutmanager layoutmanager; @nullable @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.activity_user_view,container,false);// activity contains recyclerview phpuserlist phpuserlist = new phpuserlist(getactivity()); phpuserlist.execute(); alist = phpuserlist.getarraylist(); recyclerview = (recycler