Posts

Showing posts from April, 2014

css - FAB button animation not working properly -

i'm trying animate fab button when it's clicked. want open , fills screen - it's responsive webapp running in mobile devices. the problem is: when click open button, gets full width instantly , animate up. , close button, shorten instantly , animate down. the problem i'm using fixed position, don't know how deal it. this code example: html: <div class="fab" ng-class="{'open': fabopen}" ng-click="togglefab()"> <span ng-show="!fabopen">fab</span> <h4 ng-show="fabopen">just test</h4> </div> scss: $time: 400ms; .fab { -webkit-transition-duration: $time; -moz-transition-duration: $time; -o-transition-duration: $time; transition-duration: $time; border-radius:50%; background:#358fe8; display:inline-block; height:80px; line-height:80px; width:80px; position:fixed; bottom:16px;

java - Timestamps, Timezones, Locales, and Servers -

my head starting spin timestamp , timezone issues. in app, timestamps saved utc. timezones of submitted saved separately. the environment follows: os: centos on san francisco digital ocean droplet app server: apache tomcat backend: java -> hibernate -> spring db: postgresql the first issue solved fact postgresql default timezone set america/eastern on server in san francisco. switched utc, part of problem , i'm not 100% sure did anything. fyi, column in postgresql timestamp time zone . the localized date tests, i.e. mst or utc-07: "2016-01-20 13:45:19.894 mst" the utc date used in insert tests: "2016-01-20 20:45:19.894z" first test:---------------------------------------------- with quick sql insert, right date go in. when query, localized date because local system offsets -7 hours mst. the date after query: "2016-01-20 13:45:19.894" this indeed time inserted locally. second test:------------------------

hash - Storing key, value pairs with redis sorted set -

i want store (key, value) pairs in redis sorted set (along double ordering). current option have sorted set keys, , have redis hash can store pairs in. there better/more canonical way approach problem? it highly depends on planned use of sorted set. 1 pattern might use duplicate data. in nosql world, normalization not critical. concatenate key value in sorted set. instead of key: score , store key-value: score . - character can delimiter choose can parse. saves 1 trip key: value set fetch value. again, highly depends on planned use of sorted set.

c# - Windows 10 UWP - How to preload a page before displaying it? -

i'm working on windows 10 app involves using lot of images. stands, navigating 1 page results in few seconds of "pop-in" various images on page load , result rather janky so tl;dr - is possible preload contents of page before displaying user transition page x page y smooth? i've tried googling solution whether wrong vernacular i'm using or can't done, don't know. is possible preload contents of page before displaying user transition page x page y smooth? in uwp app, before page loaded, frame.navigate() must called. there should have actions in method, example: allocate memory, load resource, rendering. scenario, in view, impossible preload resource of page before showing them. avoiding using images huge size possible solution. or, if want load lot of small images, you can bind list controls arbitrarily large data sources, , still achieve high performance, using incremental loading. when need load lot of images in 1 page, r

Erase a cell by pressing a button in Excel -

Image
i'm working in excel. i'd press button cancel value of cell @ left of button itself. so user experience should following: when user presses "button1", cell @ left became 0. same "button2" , "button3" how can do? using macro? assign macro , buttons, , it'll delete info. in cell directly left. sub test() dim btnrow&, btncol& btnrow = activesheet.shapes(application.caller).topleftcell.row btncol = activesheet.shapes(application.caller).topleftcell.column cells(btnrow, btncol).offset(0, -1).clearcontents end sub or, @rory, can be: sub test() activesheet.shapes(application.caller).topleftcell.offset(0,-1).clearcontents end sub note: make sure shapes placed, uses wherever top left of shape determine row/column. macro reduces need run 3 different ones, depending on where, , minimizes if/then type statements uses caller determine shape, determines is.

.net - Extend C# Dictionary for Atomic AddOrUpdate -

Image
previously asked question on atomic addorupdate on c# dictionary . answer got extend c# dictionary implementation, found quite rational. i extended dictionary implementation suggested, however, performance surprisingly bad!! tried minimize tweaks on c# implementation trace cause. minimum reach was: created addorupdate function, has similar signature add except returns bool if dictionary contained key , it's value updated given value , or false if otherwise. on source code made following changes: public bool addorupdate(tkey key, tvalue value) { return insert(key, value); } and private bool insert(tkey key, tvalue value) { if (buckets == null) initialize(0); int hashcode = comparer.gethashcode(key) & 0x7fffffff; int targetbucket = hashcode % buckets.length; (int = buckets[targetbucket]; >= 0; = entries[i].next) { if (entries[i].hashcode == hashcode && comparer.equals(entries[i].key, key)) { entrie

typescript - Type problems while overloading constructors -

i having problems while overloading constructors, won't let me tell type variable contains. how can force type, or make work anyway...? constructor(points: point[], name?: string); constructor(walls: wall[], name?: string); constructor(pointsorwalls: (wall | point)[], name?: string) { if (pointsorwalls[0] instanceof point) { // if first point must points // here typescript says pointsorwalls of type (wall | point)[] this.walls = pointsorwalls.map(function(point, ind, points) { return new wall(point, points[++ind % points.length]) }) }else{ // since these aren't points walls this.walls = walls } this.name = name } how can force type, or make work anyway... use type assertion: // if first point must points let points = pointsorwalls point[]; complete: class wall {w} class point {p} class foo { walls; name constructor(points: point[], name?: string); constru

Adding user and associated data CakePhp 3.x and receive validation errors for associated data -

i have scoured internet , tried figuring out docs, don't understand doing wrong. i have users can have membership , many orders. membership , orders associated membership level. unsure if these associations correct, think are. here associations: users: $this->hasone('memberships', [ 'foreignkey' => 'user_id', 'jointype' => 'inner' ]); $this->hasmany('membershiporders', [ 'foreignkey' => 'user_id', 'jointype' => 'inner' ]); orders: $this->belongsto('users', [ 'foreignkey' => 'user_id', 'jointype' => 'inner' ]); $this->hasone('membershiplevels', [ 'foreignkey' => 'membership_level_id', 'jointype' => 'inner' ]); memberships: $this->belongsto('users', [ 

jquery - how to make an expanded div, that contains half text and half image/photogallery, to work properly? -

i trying create "read more" text button, succed in creating it, have problems when try split in 2 parts -> half text , half image/photogallery ( article of newspapper - left text, right image ) http://jsfiddle.net/nn3uz/6/ . should change code work propper expectaction ? ps: can see dimensoin of main div not working well, ther no contour text before cliking reed more... , should change there border ? html <p id="title">math</p> <div class="expander" id="aspect"> <div id="paragraf"> paragraph 2: excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est excepteur sint occaecat cupidatat n

c# - EF Updating entity related table is inserting instead of updating -

i have object trying update using entity framework 5. once retrieve existing object , go update fields, correctly updates base object "coach", fails update address object , instead inserts again instead of updating new primary key though has been passed existing primary key use again. any appreciated. below dumbed down version of code: using (altairentities context = new altairentities()) { dtlcoach coach = context.dtlcoaches.firstordefault(x => x.coachid == coachid); coach.name = "bob"; coach.description = "sample"; coach.dtlcoachaddresses.add(prepareaddress(coach.dtlcoachaddresses.first().coachaddressid)); context.database.connection.open(); context.entry(coach).state = entitystate.modified; context.savechanges(); } public static dtlc

mysql - Inserting data from a join within tables -

i'm trying figure out how extend table of company_ids using group reference table. given company_name, want company_ids, join them company_groups table, , group_ids. there, want every company_id associated group_id, , insert them in companies table proper company_name. the structure bit atypical. single company name can have many ids, because id isn't used unique identifier single company. i'm trying make sure of them copied companies table. i'm sure there's simple join command, i've never been @ joining tables within themselves. can help? thanks! +---------------+ | companies | +---------------+ | company_id pk | | company_name | +---------------+ +----------------+ | company_groups | +----------------+ | company_id pk | | group_id | +----------------+ here's example. in companies table, have company "tesla", 3 different ids. +--------------+------------+ | company_name | company_id | +--------------+------------+

urlencode - Cannot make get_file_contents read a cyrillic file names. PHP -

this news.php file: <form action="create_file.php" method="post" class="form-horizontal"/> <label class="control-label">Заглавие:</label> <div class="controls"> <input name="name" type="text" width="40" class="span6 m-wrap" /> <input type="submit" value="Продължи..." class="btn red"></input> </div> </form> this create_file.php <?php $pre_file_name = $_post['name']; $ext = ".txt"; $file_name = $pre_file_name.$ext; fopen($file_name,'w'); ?> <form action="edit_file.php" method="post" class="form-horizontal"/> <label class="control-label">Въведете новината (текст):</label> <div class="controls"> <span class="field"><textarea class=&q

android - Select custom location to save file -

i have 2 weeks of experience in android , want have no idea how this.my requirement want save , read file in app not on fixed location on location user wants save , retrieve in uc browser when download file? you can use android directory picker this.

tipsy live does not work with jQuery 1.9.0 -

we upgraded our jquery 1.9.0, broke our tipsy plugin. live functionality causes error. $('.tooltip, abbr').tipsy({ live: true }); typeerror: this[binder] not function are there fixes or patches this? googling didn't lead useful. update: thanks answers. decided try fix issue myself, because couldn't find patches. upon inspection error seemed easy trace. tipsy plugin can patched use on functionality instead of deprecated live functionality. in tipsy plugin, replaced following code: if (options.trigger != 'manual') { var binder = options.live ? 'live' : 'bind', eventin = options.trigger == 'hover' ? 'mouseenter' : 'focus', eventout = options.trigger == 'hover' ? 'mouseleave' : 'blur'; this[binder](eventin, enter)[binder](eventout, leave); } with: if (options.trigger != 'manual') { var eventin = options.trigger == 'hover' ? 'm

javascript - Why textarea with contenteditable value true don't register keydown event -

it confuse me. code below shows, when press "ctrl + b" in div, font weight turn bolder, while, won't happen in textarea. question based on comments in marcus ekwall's answer rendering html inside textarea . can't add comment, ask here. div, textarea { width: 100px; height: 100px; border: 1px solid; padding: 5px; } textarea { resize: none; } <div contenteditable="true"></div> <textarea contenteditable="true" placeholder="textarea"></textarea> in textarea doesn't work because can not support html tags when run document.execcommand("bold") add <b>fdsfsdfds</b> in selected text here example using jquery (updated) $("#editor").keypress("c",function(e){ if(e.ctrlkey) { document.execcommand('bold', false, null); } }) #editor { width: 200px; heig

C++ Code::Blocks "#include <array>" causing error -

i'm using code::blocks 13.12 gnu gcc compiler , when attempt compile: #include <iostream> #include <array> #include <iomanip> using namespace std; int main() { array< int, 20 > c1={}; array< int, 20 > c2={}; array< int, 20 > c3={}; } it jumps header file "c++0x_warning.h" following warning: #ifndef _cxx0x_warning_h #define _cxx0x_warning_h 1 #ifndef __gxx_experimental_cxx0x__ #error file requires compiler , library support \ iso c++ 2011 standard. support experimental, , must \ enabled -std=c++11 or -std=gnu++11 compiler options. #endif #endif what doing wrong? sorry started studying c++ , couldn't find useful info when googling issue. read error message, it's telling exact problem. need pass -std=c++11 or -std=gnu++11 compiler argument use std::array , introduced c++11 standard. later standard supported compiler (e.g. -std=c++14 ) work. for specific case of codeblocks, enabling c++11 supp

How to display images from Photo gallery on uiwebview ios swift? -

using photos api(phimagemanager) able list of photos url , photo object. when trying use url in webview , image not displaying consider following image url got photos api(phimagemanager) you have take burl in string , load string in webview in viewdidload like urlstr = obj["url"] as! string and load url in uiwebview webview.loadrequest(nsurlrequest(url: nsurl(string: urlstr)!))

What is the use of Hashable and Equatable in Swift? When to use which? -

i know hashable inherited equatable, can give me example requires hashable, not equatable. thanks! when conform hashable , provide method returns hash value of self . when conform equatable , provide method returns whether given object , self equal. they seem serve 2 different purposes, why hashable inherit equatable ? because hash values 2 equal objects equal! what can , can't hashable , equatable ? equatable has more limited uses hashable . can compare equality of 2 objects, , that's it. for hashable , because can number represents object, can kind of treat objects numbers . can compare objects: whether less than, greater than, or equal object, numbers: if obja.hashvalue > objb.hashvalue this means can sort objects hashable . last not least, can use hashable objects keys maps! because maps' keys cannot duplicate, how can system check whether put duplicate item in it? uses hash values of keys!

ios - Alamofire response not matching request -

i having issue when making post request api via alamofire, gets work without issue, whenever make post when check response results of last get. import alamofire import swiftyjson class networkmanager { static let sharedinstace = networkmanager() let defaultmanager: alamofire.manager = { let servertrustpolicies: [string: servertrustpolicy] = [ "homestead.app": .disableevaluation ] let configuration = nsurlsessionconfiguration.defaultsessionconfiguration() configuration.httpadditionalheaders = alamofire.manager.defaulthttpheaders return alamofire.manager( configuration: configuration, servertrustpolicymanager: servertrustpolicymanager(policies: servertrustpolicies) ) }() } internal class apihelper { /** data target url , return json data parsed - parameter targeturl: url pull data - parameter success: return data calling function - parameter fai

java - Array object and maximum -

i know how find minimum , maximum in array. if method lets called fmax(): public static double fmax(object[] stuff) the parameter array object how go finding max of array? cannot do. okay how if want method return double , if memory hasnt been allocated parameter named stuff return value negative_infinity in double class, otherwise return value maximum value elements in stuff array object max = stuff[0]; (int = 0; < stuff.length; i++) { if (data[i] > max) { max = stuff[i]; } } to find maximum of something, either a) needs implement comparable interface b) need have sort of explicit criteria determining maximum is, can put in instance of comparator object isn't going have useful sorting. if subclass object, sort based on components of object. public class example implements comparable { int sortablevalue = 0; public example (int value) { this.sortablevalue = value; } public int compareto(example other)

php - monthly post timeline for wordpress -

how can use code http://astheria.com/this-site/creating-a-timeline-style-archive-page ( demo yearly archive ) show posts on several month instead of year? example have 3 posts in jun 2015. , 2 posts in jan 2016 want sort posts in month. below jun 2015 post1 post2 post3 jan 2016 post4 post5 this code yearly archive: <?php get_header(); query_posts('posts_per_page=-1'); $dates_array = array(); $year_array = array(); $i = 0; $prev_post_ts = null; $prev_post_year = null; $distance_multiplier = 2; ?> <?php while (have_posts()) : the_post(); $post_ts = strtotime($post->post_date); $post_year = date( 'y', $post_ts ); /* handle first year special case */ if ( is_null( $prev_post_year ) ) { ?> <h3 class="archive_year"><?=$post_year?></h3> <ol class="archives_list"> <?php } else if ( $prev_post_year != $p

javascript - Search box in my website which searches within the page -

i want add search box searches within website . dont want add external search engine. javascript code helpful. please me out. try in html : <form method="get" action="http://www.google.com/search"> <input type="text" name="q" size="31" maxlength="255" value="" /> <input type="submit" value="google search" /> <input type="radio" name="sitesearch" value="" /> web <input type="radio" name="sitesearch" value="yoursite.com" checked />my site name here </form>

java - Getting data with an array (or with another way) -

i have method takes answer id's (specific each answer) database answer table- getanswerid() but want change it. created answer0,answer1, answer2 columns in question database , want take 0,1,2 answerid . how can identify getanswerid() ? shortly; name of columns :answer0,answer1,answer2 take "0,1,2" " answerid " , put in " getanswerid() " then want use : public int getanswerid() { return this.answerid; } edited: sqlhelper: final string query = "select " + "answer._id, answerlang.answertext, answer.correct, " + "answersquestions.questionid" + " answersquestions" + " inner join answerlang" + " on answersquestions.answerid = answerlang.answerid" + " inner join answer" + " on answerlang.answerid = answer._id" + " answersquestions.questionid in

c - How to implement separate static variables for a given function called with different parameters -

i working on microcontroller project in c requires several timed functions take place. using hardware timer produce interrupt every millisecond, , variables counters produce appropriate time intervals. hardware details not important. as example, particular function, following code executed on every tick of 1ms counter, resulting in function() being called every 10ms. if (count < 10) { count++; } else { function(); count = 0; } i implement wrapper function avoid rewriting counter code every different interval, i.e: timerwrapper(required interval 1, function 1 pointer) timerwrapper(required interval 2, function 2 pointer) and call on every tick of timer. work, each different function called wrapper needs have separate count variable needs persist between calls of timerwrapper() . keep of implementation details separate main program , introduce few variables main program possible. is possible asking, or there simpler/better way achieve same effect? know how

Using .Net NamedPipes in a VB6 to communicate with C# application -

update: 1 - new c# application exposes namedpipeserverstream(system.io.pipes) on .net framework. 2 - legacy vb6 needs communicate c# namedpipeserverstream. 3 - until vb6 resides in system without .net framework. but, going forward both c# , legacy application on computer has .net installed. 3 - can vb6 talk c# pipe server using callnamedpipe() , approach hassle free in maintenance of communication betwen applications? any resources can or other approaches ? old question: have legacy vb 6.0 application needs communicate newer c# application using .net namedpipes. currently, legacy vb6 application sits on system without .net. when install .net framework , c# namedpipeserver application on system, how can legacy vb6 program communicate c# application on namedpipes ? please let me know. in advance. i have worked vb6 application needed data set of wcf services. the easiest way achieve put logic communicate remote systems in .net assembly exposes operations via

php - Select a column (having foreign key) without joining two tables -

i want select column (which has foreign key constraint) without creating joins on tables. have 2 tables named eventupdate , eventcategory . event column common in both tables. whenever try following code gives error. please give suggestion. don't want create join. $qb2 = $this->em->createquerybuilder(); $from = 'entities\eventcategory cat'; $qb2->add('from',$from) ->select('cat.event') ->where('cat.id=3); $query=$qb2->getquery(); there 2 options can see: hint_include_meta_columns arrayhydrator $query = $querybuilder->getquery(); $query->sethint(\doctrine\orm\query::hint_include_meta_columns, true); var_dump($query->getarrayresult()); // return array raw foreign key column name => value, e.g. user_id => 5 create separate property in entities\eventcategory has foreign key primitive type /** * @var user * * @manytoone(targetentity="user") * @joincolumn(name="user_i

clojure - In ClojureScript, why can't I navigate to a URL entered by hand, but if I click a link it works? -

(note, i'm using reagent, secretary, , compojure (among others)) i want create route /sectest/:id , , if point browser route, following error: resource interpreted stylesheet transferred mime type text/html: "http://localhost:3449/sectest/css/site.css". asdf:1 refused execute script 'http://localhost:3449/sectest/js/app.js' because mime type ('text/html') not executable, , strict mime type checking enabled. but if click on link in browser navigates route, works fine... here's pertinent code: client side: (secretary/defroute "/sectest/:id" [id] (do (js/console.log (str "hi " id)) (session/put! :current-page #'my-page))) server side: (defroutes routes (get "*" [] loading-page) ;this anticipates client-side routing (get "/cards" [] cards-page) (resources "/") (not-found "not found")) (def app (wrap-middleware #'routes)) so following link takes me

java - Struts is taking incorrect return string. Instead of "input" it should take "success" -

this question has answer here: how result on same page why input required? 2 answers i developing application using struts 2 , hibernate. have submit button on jsp page having action evaluaterating jsp page <s:form action="evaluaterating"> // jsp code here // <s:hidden name="year" value="2015" /> <s:submit value="evaluate" cssstyle="float:right"/> </s:form> and action mapped in struts.xml struts.xml <action name="evaluaterating" class="action.ratingaction" method="evaluaterating"> <result name="success" type="redirectaction"> <param name="year">${year}</param> <param name="actionname">mgrpage</param> </result> <result name="inp

ssh - Tortoise git Asking password on every pull and push operation -

i have added key also. i tried adding username , password in url as: root:password@ssh://10.10.14.119//home/pk/user_app.git. i tried making file containing login , password , added windows 10 cmd prompt. nothing working. asking password every push , pull thanks responses. got answer. i used global key (id_rsa.ppk) of git server , working now.

sql server - SQL combining two row results into one row -

Image
my ddls create table employee (employeeid varchar(10) not null primary key, fname varchar(20) not null, mname varchar(20) not null, lname varchar(20) not null, dob date, position varchar(15)not null, addres varchar(40)not null, warehouseid varchar(10)foreign key references warehouse(warehouseid), retailshopid varchar(10)foreign key references retailshop(retailshopid), customerid varchar(10)foreign key references customer(customerid), ); create table warehouse_province (provinceid varchar(10) not null primary key, province varchar (25) not null, city varchar (25) not null, addresss varchar (40) not null, ); create table warehouse (warehouseid varchar(10) not null primary key, qtyofstocks int not null, reorderqty int not null, provinceid varchar(10)foreign key references warehouse_province(provinceid) ); create table retailshop_provice (retailprovinceid varchar(10) not null primary key, province varchar (25) not null, city varchar (25) not null, addresss varchar (40) not nu

How to get a set of dropdown list values and email it using PHP? -

i have 3 dropdown list - set. demo page can inspected here : http://goo.gl/vqttym 1st 1 'destination' 2nd 1 select guest interest in 'attraction or activity' in 'destination' 3rd 'available attraction / activity' in 'destination' created following code: <div class="multi-field"> <select class="text-one" name="destination[]"> <option selected value="base">please select</option> <option value="colombo">colombo</option> <option value="kandy">kandy</option> <option value="anuradhapura">anuradhapura</option> </select> <br /> <select class="text-two" name="attraction_or_activity[]"> <option value="attraction_or_activity">select attractions or activities</option> <option value="a

javascript - Parse Cloud Code - Only Retrieve Certain Columns Before Sending Response. -

i have cloud code retrieve users have relation current user. have first find current user query "friends" column hence relational query step. the line response.success(results) returns attributes of of current user's friends. want few of columns belong these friends, not every single thing saved when signing up. parse.cloud.define("getfriends", function(request, response) { var userid = request.params.userkey; var query = new parse.query(parse.user); query.ascending("updatedat"); query.get(userid, { success: function(foundcurrentuser) { var currentuser = foundcurrentuser; var relation = currentuser.relation("friends"); var getrelationquery = relation.query(); getrelationquery.find().then(function(results) { response.success(results); }); }, error: function(error) { response.error(error); }

xml - ActiveMQ Data persistent Issue in Java Spring -

i have application uses embedded activemq 5.11. @ start of application creates activemq-data\producerbroker\kahadb folder @ class path location. want change location spring.xml doesn't take location. spring.xml given, <bean id="producerbroker" class="org.apache.activemq.broker.sslbrokerservice"> <property name="brokername" value="producerbroker" /> <property name="persistent" value="true" /> <property name="persistenceadapter" ref="persistenceadapter"/> <property name="transportconnectors"> <list> <bean class="org.apache.activemq.broker.transportconnector"> <property name="name" value="xxx"></property> <property name="uri" value="${transportconnectoruris}"></property> </bean> &l

maven - spring integration with drools -

i want integrate drools in spring.my spring config is: <kie:import releaseid-ref="ksession-rules2" enablescanner="true" scannerinterval="20000"/> <kie:releaseid id="ksession-rules2" groupid="com.test" artifactid="epay-risk2" version="1.0.3"/> <bean id="kiepostprocessor" class="org.kie.spring.annotations.kmoduleannotationpostprocessor"/> i don't know why following exception thrown: java.lang.nosuchmethoderror: com.google.inject.binder.bindlistener(lcom/google/inject/matcher/matcher;[lcom/google/inject/spi/provisionlistener;)v @ org.eclipse.sisu.plexus.plexusbindingmodule.configure(plexusbindingmodule.java:75) ~[org.eclipse.sisu.plexus-0.0.0.m5.jar:na] @ com.google.inject.spi.elements$recordingbinder.install(elements.java:223) ~[guice-3.0.jar:na] @ com.google.inject.spi.elements.getelements(elements.java:101) ~[guice-3.0.jar:na] @ com.google.i

ios - What type can't be copied in objective C -

i passing through interview, , there question couldn't answer. what objects can't copied (property copy ) in objective c. , specific details on copy property. i've looked through web, didn't find information it. there suggestions? there copyable objects in objective c, confirm nscopying , nssecurecoding protocols. object don't confirm these protocols, not copyable. hope, clears things out. p.s.: there nsmutablecopying protocol copying mutable version of object well.