Posts

Showing posts from May, 2012

javascript - scrolltop with if less than not work -

hello work create simple parallax effect there simple problem scroll top if less not work, need if user scroll bottom please animate position of flowers top:-20% left:-20% , if scroll top please animate position of flowers top:0; left:0; $(document).ready(function () { $(window).scroll(function () { var flowersleft = $(".flowers-topleft") if ($(window).scrolltop() > 50){ $(flowersleft).animate({ top: "-18%", left: "-20%" }, 600); $("body").css("background", "green"); } else { $(flowersleft).animate({ top: "0", left: "0" }, 600); $("body").css("background", "black"); } }) }) html{ height:100%; } body{ heigh...

javascript - How to add attribute data-val-required if it is removed dynamically using jquery -

i want remove attribute on condition used $("#tab-1").removeattr("data-val-required"); but on conditions want make required again have used doesnt work $("#tab-1").rules("add", "required")

java - Checksum validation failed while downloading maven dependency -

i have maven project these dependencies - <dependency> <groupid>org.apache.hbase</groupid> <artifactid>hbase-server</artifactid> <version>1.2.2</version> <exclusions> <exclusion> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>org.apache.hbase</groupid> <artifactid>hbase-server</artifactid> <version>1.2.2</version> <classifier>tests</classifier> <scope>test</scope> </dependency> i did fresh ( deleted repository directory under .m2 ) mvn clean install . one machine 1 ( mvn version - 3.3.3 ), under .m2/repository/org/apache/hbase/hbase-server/1.2.2 it downloaded -rw-rw-r-- 1 impa...

java - EntityManages NullPointerException, eclipselink + tomee + Jersey + Derby -

i new jpa, ejb , rest topic , wanted make simple crud app. when use entitymanagerfactory entities derby problem starts when want use transactions persisting objects. when try inject entitymanager nullpointerexception. i've seen several topic @ stackoverflow similar problems apparently cannot solve problem. i want run app , focus on persistence concept , not spent few days trying set up. don't know why cannot provide datasource in web-inf/resources.xml ( warning - failed register in jmx: javax.naming.namenotfoundexception: name "resource/crud/localdb" not found. ) persistence.xml <?xml version="1.0" encoding="utf-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit n...

Ruby date format validation -

how can verify date '2016-01-01' in right format (%y-%m-%d). for example want true or false if date in right format. pseudo code: if ('2016-01-01' == (%y-%m-%d)) puts date valid else puts date not valid end please help, thanks! it seems not interested in format of string if string represents valid date (for example 2016-01-32 invalid): require 'date' def validate_date(string) format_ok = string.match(/\d{4}-\d{2}-\d{2}/) parseable = date.strptime(string, '%y-%m-%d') rescue false if string == 'never' || format_ok && parseable puts "date valid" else puts "date not valid" end end validate_date('2016-01-01') #=> "date valid" validate_date('2016-01-32') #=> "date not valid" validate_date('01-01-2016') #=> "date not valid" validate_date('never') #=> "date valid" validate_date('to...

jquery - angular-flot $.plot is not a function -

i using angular-flot chart when render page gives error $.plot not function. as have jquery in project. do need add jquery.flot.js , other files somewhere? if yes why should use angular-flot? can't use directly adding jquery flot js , $(function){ ... })

properties - Lua variable as a function call -

i need define variables in lua when accessed result in call of c++ function: lua: var rootname = root.name; // 'root' acts call c++ function defined below c++: class node { std::string name; } node * root() { return mynodegraph->getroot(); } is possible in lua? yes can that. that's acutally 1 of common use cases of lua. although proper lua syntax local = prop() if want 5. read https://www.lua.org/manual/5.3/ , https://www.lua.org/pil/24.html https://www.lua.org/pil/25.html https://www.lua.org/pil/26.html

javascript - Idiomatic way to lazy-load with mobx -

what current idiomatic way lazy load properties when using mobx? i've been struggling few days, , haven't found examples since strict mode has become thing. idea of strict mode, i'm starting think lazy-loading @ odds (accessing, or observing property should trigger side effect of loading data if it's not there). that's crux of question, see how got here keep reading. the basics of current setup (without posting ton of code): react component 1 (listview): componentwillmount componentwillmount & componentwillreceiveprops - component gets filter values route params (react-router), saves observable object on listview, , tells store fetch 'proposals' based on it store.fetchproposals checks see if request has been made (requests stored in observablemap, keys serializing filter object 2 identical filters return same response object). makes request if needs , returns observable response object contains info on whether request finished or has err...

javascript - Using angular's templateCache in case of large apps -

i working on optimizing pretty large angularjs application 100+ templates. use grunt automation. trying achieve here need prefix urls in production code cdnurl plan host static assets on cdn. i tried using this grunt plugin , replace references in code except templateurls in <ng-include> tags , in ui routers state configuration. hence thought of solving issue precompiling angular js templates single js file using $templatecache service using this plugin. after checking out size of precompiled js file found out whopping 1.13 mb html minified. comparing overall app takes 1.5 ~ 1.7 mb entire app during first load. don't find legible include precompiled template forces lot of weight downloaded on user's device. there views partially restricted users , speaking feel unfair load data sections of app many users won't anyway visiting. so guys recommend in such cases ? still preferable use $templatecache in production? if not regarding prefixing angular templa...

android - How to get progress of a file being downloaded from google drive using REST API? -

i'm using this method download file google drive. my code: bytearrayoutputstream bytearrayoutputstream = new bytearrayoutputstream(); driveservice.files().export(remotefiles[0].getid(),"text/plain").executemediaanddownloadto(bytearrayoutputstream); fileoutputstream fileoutputstream= new fileoutputstream(new file(downloadsdirectory,remotefiles[0].getname())); bytearrayoutputstream.writeto(fileoutputstream); bytearrayoutputstream.flush(); bytearrayoutputstream.close(); fileoutputstream.close(); is there way progress of file download? answering own question,found on page . //custom listener download progress class downloadprogresslistener implements mediahttpdownloaderprogresslistener{ @override public void progresschanged(mediahttpdownloader downloader) throws ioexception { switch (downloader.getdownloadstate()){ //called when file still downloading ...

How can I draw multiple lines connected via “nodes” in winforms c#? -

Image
i'm writing dijkstra algorithm want draw lines between each 2 nodes connect 2 nodes each other writing code draw 1 line between 2 nodes.i wanna each time click on 2 node created line.of course , using "drawlines()" method create 1 line. public class graph { public dictionary<int, list<keyvaluepair<int, int>>> vertices = new dictionary<int, list<keyvaluepair<int, int>>>(); public void addvertex(int id, list<keyvaluepair<int, int>> edges) { if (!vertices.containskey(id)) { vertices.add(id, new list<keyvaluepair<int, int>>()); } vertices[id].addrange(edges); } } private circlemanager circlemanager = new circlemanager(); private list<circle> circlessourceanddestination = new list<circle>(); private graph g = new graph(); private int lastclickednode = -1; public form1() { initializecomponent...

javascript - HTML5 ondrop event returns before zip.js can finish operations -

the crux of issue need use datatransferitemlist asynchronously @ odds functionality described in specs, locked out of datatransfer.items collection once event ends. https://bugs.chromium.org/p/chromium/issues/detail?id=137231 http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#drag-data-store the case offender following. more detailed description of problem , thoughts below it. drophandler: function(event) { event.stoppropagation(); event.preventdefault(); event.datatransfer.dropeffect = 'copy'; zip.workerscriptspath = "../bower_components/zip.js/webcontent/"; zip.usewebworkers = false; // disabled because makes life more complicated // check if files contains zip if (event.datatransfer.files[0].name.match(/(?:\.([^.]+))?$/) == 'zip') { var reader = new filereader(); = this; reader.onload = function(e) { that.fire('zipuploaded', e.target.result.split('...

angularjs - How to prevent ui-select from being closed when selecting items (with multiple select)? -

i don't want close ui-select dropdown (with multiple select) when select value. close on clicking outside of drop down. set close-on-select attribute false, shown in documentation . example: <ui-select ng-model="selected" close-on-select="false"> you can find live example here .

ios - Core Bluetooth will not restore when coming back to view controller -

i'm working on bluetooth heart rate monitor , followed code https://www.raywenderlich.com/52080/introduction-core-bluetooth-building-heart-rate-monitor i have app running great. within same app have several other view controllers other things login page , simple "about us" page. issue have when coming view controller, containing actual heart rate monitor, monitor sits @ 0 , not update values. i have restore code , delegates in place: -(void)centralmanager:(cbcentralmanager *)central willrestorestate:(nsdictionary *)state { nslog(@"willrestorestate called"); self.polarh7hrmperipheral = [state[cbcentralmanagerrestoredstateperipheralskey] firstitem]; self.polarh7hrmperipheral.delegate = self; } central manager declared so: cbcentralmanager *centralmanager =[[cbcentralmanager alloc] initwithdelegate:self queue:nil options:@{ cbcentralmanageroptionrestoreidentifierkey:@"mycentralmanageridentifier" }]; when coming view contr...

c++ - If treble product of first 2 digits -

i writing program should able calculate product of first n-1 digits. note: if treble first 2 digits. the code working when 4 digits entered , example : 1234 , product 6 . cant figure out treble part so far tried this, no solution: using namespace std; int main() { int n , sum = 0, s,d,k,w, product ; cout <<"enter number: " << endl; cin >> n; if ((n>1) && (n<10000)) { { s= n/10; d = n/100%10; // 2. k = n/1000%100%10; //1. w = n/10%10; //3. //1234 product = w*d*k; if ((n>1) && (n<1000)) { s = n/10; d = n/100%10; // 2. k = n/1000%100%10; //1. w = n/10%10; //3. product = k*d; } cout <<"sum of digits inp numb : " << d+k+w << " , product : " << product << endl; cout << "w: " << w << " k: " << k << " d: " << d << " s: " << s <...

node.js - Flash Message from ejs in Express 4 -

i trying show confirmation message before user deletes anything. i've tried following various related sources found in internet, couldn't them work. using ejs template , express 4. app.js var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieparser = require('cookie-parser'); var bodyparser = require('body-parser'); var routes = require('./routes/index'); var users = require('./routes/users'); var app = express(); var flash = require('connect-flash'); var session = require('express-session'); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); app.use('/js', express.static(__dirname + '/node_modules/bootstrap/dist/js')); // redirect bootstrap js app.use('/css', express.static(__dirname + '/no...

javascript - Interesting fixed element issue when page scroll down -

i have web page , fixed menu(display:none) , if scroll page until rezervation form fixed menu make appear it's far if resulution under 768px fixed menu doesn't work when scroll page until refresh.. edit: undserstand problem..problem top navigation menu(mega menu) if remove codes work have solve not removing js $(function() { if (!$(".hotel-search-box").length) { return false; //check if element exist } $(window).scroll(function() { if($(window).scrolltop() > $(".hotel-search-box").offset().top+$(".hotel-search-box").height() && $(".oda-otel-giris").val() == ""){ $(".sticky-checkin").fadein(500); }else{ $(".sticky-checkin").fadeout(500); } }); }); css .sticky-checkin{ position:fixed; top:0; left:0; z-index:1042; background:#fff; width:100%; padding:15px 0; @include clearfi...

java - Hibernate Id Sequence Resulting null -

i have 1 table in postgresql database 2 id sequence. @jsonproperty("id") @column(name = "id", nullable = false,unique=true) @id @generatedvalue(strategy = generationtype.identity,generator = "order_seq_gen") @sequencegenerator(name = "order_seq_gen", sequencename ="order_id_seq") private integer id; @jsonproperty("state") private string state; @jsonproperty("order_id") @column(name="order_id", nullable=false, unique=true, insertable = false, updatable = true, columndefinition = "bigint default nextval('order_idgen_seq')" ) @generatedvalue(strategy = generationtype.sequence,generator = "order_seq_gen") @sequencegenerator(name = "order_seq_gen", sequencename ="order_idgen_seq") private integer orderid; this pojo. my issue orderid, if call crud repository save creating new record sequence starting values, while returning ob...

android - Gradle test run fails after class rename -

we have gradle set build , test our android app. ran problem, gradle test runs fail reproducibly after class renamed somewhere in project: execution failed task ':proj:compiledebugunittestjavawithjavac'. > unable read class file: '/path/to/class/with/the/name/before/renaming.class' this error reproducible both.. locally (run gradle tests android studio, or on command line using ./gradlew test ), and remotely , when tests run on our ci (a teamcity server). what solves issue, manually triggering rebuild locally (e.g. in android studio build > rebuild project ) or re-running teamcity task flag clean files in checkout directory before build set. is there way can our tests not fail after class has been renamed? while above solution simple enough kinda annoying simple rename makes our repo blow ci builds... want stay green. :) this known issue in gradle 2.14 , 2.14.1 , there workaround in upcoming android gradle plugin release. as work...

html - Media Queries for responsive typography -

i'm trying find way make typography responsive. code follow. whenever refresh in dev tools doesn't seem have desired result. how can result have text displayed on phones, tablets , laptop/desktops? @media screen , (min-width: 320px) { html {line-height: 1.25em, font-size: 16px;} h1{line-height: 1.25em, font-size:32px;} h2{line-height: 1.15384em, font-size:26px;} h3{line-height: 1.136363em, font-size:22px;} h4{line-height: 1.111111em, font-size:18px;} } did set viewport meta tag in html? <meta name="viewport" content="width=device-width, initial-scale=1"> also, why don't use rems make more simple? specify initial html font-size , line-height , change rem value each query. read: https://css-tricks.com/confused-rem-em/

sockets - Julia TCP select -

i have 1 problem tcp connection. i have made server like: server = listen(5000) sock = accept(server) while isopen(sock) yes=read(sock,float64,2) println(yes) end i want continually print [0.0,0.0] when there nothing read, otherwise print reads server. go loop(trying read something), if there nothing read or crashes. try task like: begin server = listen(5000) while true sock = accept(server) while isopen(sock) yes=read(sock,float64,2) println(yes) end println([0.0,0.0]) end end but print reads. i'm making connection other console , ride through consol: clientside=connect(5000) write(clientside,[2.0,2.0]) so i'm trying make server prints [0.0,0.0], if there nothing read , print reads when there read. ideas? maybe, 1 strategy make server run accept / print block asynchronously (since accept call blocks main thread). following tutorial "using tcp sockets in julia" , 1 way make server is: notw...

jquery - Do next method once this one is complete -

this question has answer here: jquery - wait till end of slideup() 2 answers i want html element removed after finished sliding up. remove executed immediately. $(document).ready(function() { $(':button').on('click', function() { $("body").prepend("<div class='messagebox'>dsds</div>"); $(".messagebox").text('you wot!').slideup(0).slidedown("slow"); settimeout(function() { $(".messagebox").slideup("slow"); //wait till finish then.... $(".messagebox").remove(); }, 2000); }); }); .messagebox { background: blue; color: #fff; padding: 20px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h1> settings </h1> <h...

playframework - Change the folder that WebJars are put in -

i'm using play webjars working great i'd change directory webjar dependencies put. @ moment put in assets/lib . i possible change location in build.sbt or similar? if want change url assets accessed can change routes, like: get /webjars/*file controllers.assets.versioned(path="/public/lib", file: asset) if want change dir stored in can try set webmoduleslib in build.sbt different dir. can see setting in sbt-web plugin extracts webjars: https://github.com/sbt/sbt-web/blob/master/src/main/scala/com/typesafe/sbt/web/sbtweb.scala#l37

android - Getting user location takes a very long time inside Google Map FragmentActivity -

i having issues getting location in map activity. basically, gets location, takes long time (a few minutes). i'm using singleton requests single location update retrieve location. works fine across multiple other instances in app. when try in map activity, takes long time. here class use location: public class singleshotlocationprovider { public interface locationcallback { void onnewlocationavailable(gpscoordinates location); } public static void requestsingleupdate(final context context, final locationcallback callback) { final locationmanager locationmanager = (locationmanager) context.getsystemservice(context.location_service); //if network available if (locationmanager.isproviderenabled(locationmanager.network_provider)) { log.i("singleshot", "network available"); criteria criteria = new criteria(); criteria.setaccuracy(criteria.accuracy_coarse); try { locationmanager.requestsingleupdate(c...

Steps to send mail using sendgrid mailer function in yii2? -

i trying mail using sendgrid in yii 2 doesn't seem work.can 1 tell me steps of sendgrid in yii2 . you can use https://github.com/bryglen/yii2-sendgrid#yii-2-bryglen-sendgrid installation: composer require --prefer-dist bryglen/yii2-sendgrid "*" common/config/main.php 'components' => [ ... 'sendgrid' => [ 'class' => 'bryglen\sendgrid\mailer', 'username' => 'your_user_name', 'password' => 'your password here', //'viewpath' => '@app/views/mail', // view path here ], ... ], to send email, may use following code: $sendgrid = yii::$app->sendgrid; $message = $sendgrid->compose('contact/html', ['contactform' => $form]); $message->setfrom('from@domain.com') ->setto($form->email) ->setsubject($form->subject) ->send($sendgrid);