Posts

Showing posts from January, 2014

javascript - jQuery appendTo() w/ Selectors -

so i've added 4 elements page separate wordpress loop. i'm using jquery appendto() add them within list of posts (loop). works fine except last one... seems not able select using last-child or only-child or nth-child. other 3 elements selected , moved fine using last-child(#).i've tried can think of. think? of course, once 3 elements moved suppose last 1 left no longer considered last-child or first-child?... only-child doesn't work either... jquery(document).ready(function ($) { var toapp1 = $(".recent_updates > .fp_post:nth-child(4)"), toapp2 = $(".recent_updates > .fp_post:nth-child(7)"), toapp3 = $(".recent_updates > .fp_post:nth-child(10)"), toapp4 = $(".recent_updates > .fp_post:nth-child(13)"); var ad1 = $(".recent_updates > #skippingads:nth-last-child(4)"), ad2 = $(".recent_updates > #skippingads:nth-last-child(3)"), ad3 = $(...

calling a C++ DLL from LuaJIT -

i know can't use ffi load in c++ dll (only c work), how go doing this? if need use wrapper, how started that? edit: cannot change dll in way whatsoever. you can try mangling names manually in ffi cdefs, different compilers use different name mangling schemes, not mention referring functions awkward. rather manually mangling names in cdef, recommend writing wrapper in c. while tedious, it's not difficult. gist of c side of treats classes opaque structs pass around wrapper functions. see site more details , gotchas, though. here's sample snippet of wrapper use box2d: #include <box2d/box2d.h> #ifdef __linux__ #define cexport extern "c" #else #define cexport extern "c" __declspec(dllexport) #endif // /////////////////////////////////////////////////////// // world cexport b2world* b2world_new(b2vec2* gravity) { return new b2world(*gravity); } cexport void b2world_destroy(b2world* world) { delete world; } cexpor...

ruby - rspec failing error: expected false to respond to `false?` -

i running portion of test: describe dictionary before @d = dictionary.new end 'can check whether given keyword exists' @d.include?('fish').should be_false end with code: class dictionary def initialize @hash = {} end def add(new_entry) new_entry.class == string ? @hash[new_entry] = nil : new_entry.each { |noun, definition| @hash[noun] = definition} end def entries @hash end def keywords @hash.keys end def include?(word) if @hash.has_key?(word) true else false end end end i don't know i'm doing wrong, tests keep failing , saying this: > 1) dictionary can check whether given keyword exists > failure/error: @d.include?('fish').should be_false > expected false respond `false?` i confused @ error since seems giving correct answer. appreciate if take few minutes tell me what's wrong code. thank tons. if b...

javascript - Bootstrap slider with slideStop event -

i have bootstrap slider on page. don't know how can change code, page.php not constanly loading while dragging slider, when stop dragging (after desired period of time). have use slidestop event, don't know how. <script type="text/javascript"> $(document).ready(function() { var intseconds = 1; var refreshid; function stimeout() { $("#mydiv").load("page.php"); // load content refreshid = settimeout(function() { // saving timeout stimeout(); }, intseconds *3000); } stimeout(); $.ajaxsetup({cache: false}); // slider $("#ex1").slider({ min : 1, // minimum value max : 20, // maximum value step : 1, value : intseconds, // copy current value formater: function(value) { // option format values before sent tooltip cleartimeout(refreshid); //...

html - javascript function onclick must click twice -_- why so? -

i have page(it faq page web site) such when user click on div (e.g. #question01) there's new div appears below it. easy thing function, when click first time, nothing appears, click , there go. #faqanswer01 has "unhide" class set display:block; (.hide = display:none;) so here 2 question : 1- why have click twice function executed? 2- how can fix code works after 1 click? html code <div id="faqcontainer"> <div id="question01" onclick="showanswer('faqanswer01','imgarrow01');">here's question?<img src="public/images/gt.png" class="imgarrow" id="imgarrow01"></div> <div id="faqanswer01" class="faqanswerdiv hide">bla bla bla</div> <div id="question02" onclick="showanswer('faqanswer02','imgarrow02');">another question here? <img src="public/images/gt.png" class=...

css3 - Is possible use fade transition on tag 'content' only with css? -

please view code jsfiddle: http://jsfiddle.net/rflfn/6wcp6/ <div id="menu"> <ul> <li><a href="#">link #1</a></li> <li><a href="#">link #2</a></li> <li><a href="#">link #3</a></li> <li><a href="#">link #4</a></li> </ul> </div> css: *{ margin: 0; padding: 0; text-decoration: none; font-family: arial; font-size: 16px; } a{ color: #000000; } a:hover{ color: #860000; } #menu{ margin: 15px auto; padding: 20px; width: 300px; background: #dddddd; border-radius: 5px; box-shadow: 0 0 5px #000000; } #menu ul{ list-style: none; } #menu li:before{ margin-right: 10px; content: url("http://st.deviantart.net/emoticons/s/smile.gif"); transition: 0.5s ease 0s; /* transition: content 0.5s ease 0s; */ }...

ruby on rails - Set Default Language on Pygments.rb | Redcarpet -

i'm trying set fix language pygments.rb , javascript. i'm using redcarpet markdown. far i'm here: # model.rb before_save :render_source def render_source require 'redcarpet' renderer = pygmentizehtmlsource extensions = {fenced_code_blocks: true} redcarpet = redcarpet::markdown.new(renderer, extensions) self.rendered_source = redcarpet.render self.source end class pygmentizehtmlsource < redcarpet::render::html def block_code(code, language) pygments.highlight(code, :lexer => 'javascript', options: {linenos: 'table'}) end end right i'm passing :lexer => 'javascript' can't rid of language option block. if remove 'language' wrong number of arguments (2 1) does have redcarpet ? how can set lexer default javascript ? my main problem want initial :text clear input of user. don't want store the ```javascript ``` in that. found !! i using block-level call predefined r...

Why does IntelliJ IDEA 13.1 show sbt files with so many lines in red? -

Image
i had working sbt based project. after small change can not identify sbt files having object resolution issues (see screenshots). i tried following: sbt refresh project rebuild reimport project these did not work. then started going farther afield resolve issue. copied *.sbt files from project on top of ones in project. still no dice . not have time presently destroy, rebuild project scratch - , in case not lead insight on root cause here. has experienced issue - , suggestions on remedies/workarounds? update tried sbt gen-idea even though project **not ** built way.. did make difference: @ least crazy errors went away. different set of problems arises: assembly , packaging imports not being resolved (see last screenshot). seems a bit more healthy @ least . following screenshot after running sbt gen-idea. situation has improved assembly/packaging import errors. another update ok, have quit , restarted ij , things back. objective changes ...

Show metrics on Travis-CI -

is possible configure travis-ci t show metrics sonarqube provides ( http://nemo.sonarqube.org/ ) like % duplicate lines % code coverage % rules appliance % documented methods etc and see graphically? thanks in advance. guillermo. i did not come across such setting. travis ci mean running scanners, highly dependent on used project technologies. however http://container-solutions.com/moved-ci-jenkins-travis/ explains how can sonarqube commenting code changes in github pull requests.

post - I can not return a BOOLEAN value using $. Pos jQuery -

i have js function following code: $('#pedesenha').click(function () { $("#respostaquery").html(''); var vpos = math.floor((math.random() * 20) + 1); var vsenha = prompt("digite sua senha de posição [" + vpos + "]"); var vcdmil = $("#cdmil").val(); var vcdreq = $("#cdreq").val(); if (vsenha != '') { $.post('paginas/testasenha.php', { pos: vpos, senha: vsenha, cdmil: vcdmil }, function (resp2) { if (resp2) { alert('acertou'); } else { alert('errou'); } $('html').removeclass('wait'); }) } }); the function follows. clicking button asks password card password, random number 1 20 generated , user asked enter relevant password. these data sent page .. follows: **<?php include_once '../inc/...

nested - Simplify Excel Statement into one Column -

i'm trying simplify these 2 column equations 1 column in excel. trying simplify 2 nested if(and()) statements one, can't quite figure out how it. here statement 1 column: =if(and([@[% rsi]]>$n$13+$n$15, (g2-[@[adj close]])/[@[adj close]]<0), "true overbought", "false overbought") and here next column: =if(and([@[% rsi]]<$o$13+$o$15, (g2-[@[adj close]])/[@[adj close]]>0), "true oversold", "false oversold") i've been trying make work 'or()' statements haven't been quite able figure out.

linux - x86 GNU Assembler Strange Change Seg Fault -

the following x86 assembly code assembles fine, , used run flawlessly on school's linux server, when applying same code linux virtual machine (ubuntu 14.04, of sudden causes segmentation fault. did stack conventions change, gnu assembler problem? memo did miss? running on 64-bit machine, , warm-up building backbone of os, need able use 16-bit real, 32-bit protected, , 64-bit mode in same program. suppose need little details making modes valid in same program. know use .code16/32/64 when changing modes, guess i'm missing (and can't seem find in os tutorial, how on 64-bit architecture. .code32 .text .global _start _start: pushl $str1 pushl $len1 call print addl $8, %esp <-cleans stack pointer exit: movl $1, %eax movl $0, %ebx int $0x80 print: pushl %ebp movl %esp, %ebp movl $4, %eax movl $1, %ebx movl 12(%ebp), %ecx <- seg fault occurs according gdb movl 8(%ebp), %edx int $0x80 popl %ebp ret...

html - How can I make a border wrap around a group of pictures? -

i'm trying figure out how make border fit around group of images. can see in jsfiddle posted, border fits around top , left corner, doesn't fit around bottom , right corners. here html: <!doctype html> <html> <head> <title>gallery test</title> <link type="text/css" rel="stylesheet" href="css.css"/> </head> <div class="album"> <span><img class="img1" id="imgalbum" src="http://images.nationalgeographic.com/wpf/media-live/photos/000/006/cache/red- fox_679_600x450.jpg"> </span> <span><img class="img2" id="imgalbum" src="http://images.nationalgeographic.com/wpf/media-live/photos/000/006/cache/red- fox_679_600x450.jpg"> ...

python - Serving static files from root of Django development server -

my goal have angular project being served root of development server. files static far django concerned, no django template processing needed. angular project make resource calls django project located @ /api/ on same development server, return json results generated view angular project process. i assumed easy adding following urls.py file. url(r'^/', 'django.views.static.serve', { 'document_root':'/users/kyle/development/project/site/app', }), or + static("^/$", document_root="/users/kyle/development/project/site/app") to end of urlpatterns. with /project/site/app being directory angularjs files. however, both of these leave me 404 errors. i'm open changing structure of project if more obvious solution exists. note default django won't serve directory listing. still 404 if file /users/kyle/development/project/site/app/beer.jpg doesn't appear http://localhost/beer.jpg ? in urls.py...

http post - Posting back to website from a Java Web Start app? -

is there way post website java web start app ? here i'm trying accomplish. have website page place orders online. i've designed jws app can read barcodes little scanner use ordering software. i'm trying make can start java app website , read scanner, send barcode data website fill in order don't have hand key order website. trying figure out best way accomplish , not sure java capable of doing. a java web start app can post data server, either using http client library or manually urlconnection . a java applet can manipulate dom of webpage it's included.

html - Hover effect is affecting them all at once, not individually -

i have been looking through cause of problem , haven't had luck finding anything. i'm not entirely sure if own stupidity or purely lack of knowledge. i don't know lot coding , i've had super long day may have on looked something. here basic idea of i'm trying do. i want list of 5 options, , have block under window when rolled on shows block. (indicated colour) now i've created when rolled on show up, why this? here example of i've created html <div id="nature"> <a class="sound"> <h4>forest</h4> <div class="preview" style="background:red;"> </div> </a> <a class="sound"> <h4>storm</h4> <div class="preview"style="background:blue;" > </div> </a> <a class="sound"> <h4>winter</h4> <div class="preview"style="background:lig...

android - Splash Screen to support both 1280X768 and 1280x720 -

i trying create splash screen android. question note 2 takes format of 1280 x 720 n 1280 x 768, , since both xhdpi format, splash screen picture put in xhdpi folder. since splash screen covers entire page, how can make sure both version gets right image if i put both pictures in xhdpi folder? use imageview layout_height , layout_width match_parent , use scaletype = "centercrop". trick you. <imageview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/containerrl" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/splash" android:scaletype="centercrop" ></imageview>

css - Float:left prevents click on <a href> tag -

i'm trying website , i'm using css designed unfamiliar navbars , getting stuff side side. used "float: left" image (logo) , text aligned but, seems cannot click on image anymore since it's can clicked using tag. so, ideas? code: css: #navbar { width: 100%; height: 40px; background-color: black; opacity: 0.7; display: fixed; } #navbar img { opacity: 1; float: left; } #navbar img:hover { opacity: 0.7; } #navbar img { margin: 0; padding: 0; } #navbar ul { position: relative; list-style-type:none; margin:0; padding: 8px 0 0 0; color: white; font-size: 1.5em; } #navbar ul { display:block; width:60px; } #navbar li { display:inline; } html: <div id="navbar"> <a href="#"><img src="logo.png"/></a> <ul> <li>hello</li> <l...

javascript - Run prototype.js in a no conflict mode -

i working on site using prototype. had embed pure js app page. unfortunately, prototype library added 20 new methods array object-prototypes. bad because existing pure js app looping on arrays, , instead of getting strings of array keys, it's getting function definitions new methods. like: function clone() { return slice.call(this, 0);} (undefined%) is array key when iterate on it. know it's prototype because adds prototypes , thats why no 1 uses on jquery anymore. how can fixed?!

redirect - Laravel 4 authentication login issue -

in laravel login route, have following code: route::get('/login', function() { $credentials = input::only('username', 'password'); if (auth::attempt($credentials)) { return redirect::intended('/'); } return redirect::to('login'); }); when try access /login , "web page has redirect loop" error. how fix this? tia - joe take @ logic, if user has invalid credentials redirected /login try validate credentials again causing infinite loop. should split /login post , route prevent this. in view when submit login form, should sent post. route::get('/login', function() { //do nothing here, return view login form }); route::post('/login', function() { $credentials = input::only('username', 'password'); if (auth::attempt($credentials)) { return redirect::intended('/'); } return redirect::to('login'); });

<Android> Bluetooth Pairing Confirmation notification -

we developing android application connects bluetooth device using secure simple pairing. expected, observed when ever application connects bluetooth device using android provided api's, pairing confirmation dialog generated user confirmation. on nexus4, observed pairing notification generated , user needs select pairing notification confirm pairing. looking source code of setting application, specifically(bluetoothpairingrequest.java), there check screen on/off decide whether generate pairing dialog or notification. in our case, screen on, still generates notification. can please provide information on how usecase(pairing notification) can avoided. thanks in advance. -ashwin

python - Perceptron Learning Algorithm taking a lot of iterations to converge? -

i solving homework-1 of caltech machine learning course ( http://work.caltech.edu/homework/hw1.pdf ) . solve ques 7-10 need implement pla. implementation in python: import sys,math,random w=[] # stores weights data=[] # stores vector x(x1,x2,...) output=[] # stores output(y) # returns 1 if dot product more 0 def sign_dot_product(x): global w dot=sum([w[i]*x[i] in xrange(len(w))]) if(dot>0): return 1 else : return -1 # checks if point misclassified def is_misclassified(rand_p): return (true if sign_dot_product(data[rand_p])!=output[rand_p] else false) # loads data in following format: # x1 x2 ... y # in present case d=2 # x1 x2 y def load_data(): f=open("data.dat","r") global w line in f: data_tmp=([1]+[float(x) x in line.split(" ")]) data.append(data_tmp[0:-1]) output.append(data_tmp[-1]) def train(): global w w=[ random.uniform(-1,1) in xrange(len(data[0]))] #...

sql server - SQL Select MAX and 2nd MAX -

i running query against ms sql server 2008 , selecting accountnumber , max of column mydate grouped accountnumber: select accountnumber, max(mydate), #sampledata group accountnumber i want add column result contains second highest mydate associated accountnumber group. know have like: select max(mydate) #sampledata mydate < (select max(mydate) #sampledata) but how both max , 2nd max in 1 select query? something should select second highest: select accountnumber, max(mydate), (select max(sd2.mydate) #sampledata sd2 sd2.accountnumber=#sampledata.accountnumber , sd2.mydate<max(#sampledata.mydate)) #sampledata group accountnumber

python - Visual Basic Script as Windows Scheduled Task -

i trying create .bat script creating scheduled task both windows xp , 7. script run python script hidden command line window. here code .vbs script: dim fso dim curdir dim winscripthost set fso = createobject("scripting.filesystemobject") curdir = fso.getabsolutepathname(".") set fso = nothing wscript.echo curdir set winscripthost = createobject("wscript.shell") winscripthost.run ".\python27\python.exe .\modules\monitor.py" set winscripthost = nothing here .bat script invokes .vbs script: schtasks /create /sc onlogon /tn monitor /tr "%~dp0schedule.vbs" @echo off pause this script create scheduled task, when try run it, nothing shows up. can verify .vbs script works if manually run it. here folder heiarchy of program: \project schedule.vbs create_schedule.bat \modules monitor.py

html - SVG gets distorted -

i'm trying embed several .svg-files on website. seems work fine long use chrome, firefox or mobile browser i've tested far. however, there's 1 exception: whenever view svg on windows phone (internet explorer mobile) image gets distorted. i guess found reason behavior already: since want size of svg fluid, gave them percentage-based width , auto-height. works, mentioned before, fine browser. internet-explorer however, seems ignore height:auto thereby stretching svg it's maximum heigth. that said, 1 solution assign fixed dimensions every single .svg. sacrifice idea of responsive design. has idea problem might be? oh, here's link page of website featuring svg (the black "star" saying "select"): http://alexanderschlosser.de/select.html many in advance! alex edit: that's code of 1 of embedded svgs. <?xml version="1.0" encoding="utf-8"?> <!-- generator: adobe illustrator 16.0.4, svg export plug-in ...

d3.js - Very basic syntax error, lines not drawing in d3 -

for reason, in last block of code append("g) successful, data bind append lines not. know should print 10 lines on top of each other, cannot them print page reason. can see error? help! var w = 300; var dataset = 10; var svg = d3.select("body").append("svg") .attr("width", w) .attr("height", w); svg.append("line") .attr("x1", w/2) .attr("y1", 0) .attr("x2", w/2) .attr("y2", w); svg.append("line") .attr("x1", 0) .attr("y1", w/2) .attr("x2", w) .attr("y2", w/2); svg.append("g") .selectall("line") .data(dataset) .enter() .append("line") .attr("x1", 0) .attr("y1", w/4) .attr("x2", w/2) .attr("y2", w/4); dataset in .data(dataset) has array nothing. if use, example .data([dataset]) 1 line. if want 10...

c++ - Why does std::iterator not define const_reference and const_pointer? -

so, made own "standard compliant" container. defined nested classes called iterator , const_iterator derive from std::iterator<std::bidirectional_iterator_tag, value_type> where value_type typedef inside new container class. derive std::iterator can do typedef typename std::iterator<std::bidirectional_iterator_tag,value_type>::value_type value_type; typedef typename std::iterator<std::bidirectional_iterator_tag,value_type>::difference_type difference_type; // ... etcetera inside nested iterator classes. however, cppreference.com says std::iterator not have typedefs const_reference nor const_pointer. can typedef them myself, puzzled why these typedefs omitted. i've reviewed spec. const_pointer defined part of allocator types, std::allocator , std::allocator_traits , , container types, , has nothing whatsoever iterators. therefore, makes sense std::iterator not define const_pointer typedef. this makes sense when think it, b...

class - C# Interface Method calls from a controller -

i working on application architecture , may sound stupid question please explain me how following works: interface: public interface imatterdal { ienumerable<matter> getmattersbycode(string input); ienumerable<matter> getmattersbysearch(string input); } class: public class matterdal : imatterdal { private readonly database _db; public matterdal(database db) { _db = db; loadall(); //private method } public virtual ienumerable<matter> getmattersbysearch(string input) { //code return result; } public virtual ienumerable<matter> getmattersbycode(string input) { //code return results; } controller: public class mattercontroller : apicontroller { private readonly imatterdal _publisheddata; public mattercontroller(imatterdal publisheddata) { _publisheddata = publisheddata; } [validateinput(false)] public jsonresult searchb...

javascript - Date selection goes to previous day when using momentjs -

i having headache when saving dates on cloud server. works correctly on local machine. files up-to-date. i using momentjs. when selecting date jquery picker dates saved previous day. i have been looking @ post requests , dates render such 2014-05-30t23:00:00.000z date selected 31st may 2014 jquery picker. i noticed when retrieving data server has utc on date object below: date1: tue may 13 2014 00:00:00 gmt+0000 (utc), but local machine in uk , has date1: thu may 01 2014 00:00:00 gmt+0100 (bst), in client side angular code have following $scope.selectedbookingmodal.date1 = moment($scope.selectedbookingmodal.date1).format(); just wondering how can correct date appear , saved? cheers try setting .zone() $scope.selectedbookingmodal.date1 = moment($scope.selectedbookingmodal.date1) .zone('100') .format();

ruby - Capistrano read from .env on deployment server -

i trying perform database backup part of capistrano (v3) deployment script (for non-rails app). the script works fine -- if hard-code database config it. now want load in database config .env file. on local machine, .env file (in repo root next capfile) reads follows: db_name='local_name' db_user='local_user' db_password='local_pw' db_host='127.0.0.1' on server, .env file (which capistrano has placed in shared folder & symlined current folder) reads follows: db_name='dev_name' db_user='dev_user' db_password='dev_pw' db_host='127.0.0.1' however, when running cap deploy, following: info [292e2535] running /usr/bin/env mysqldump -u local_user --password='local_pw' --databases local_name -h 127.0.0.1 | bzip2 -9 > /var/www/vhosts/xxxxx/backups/database_local_name_2014-05-29_22:52:07.sql.bz2 on <server> i.e. it's using local .env file, when i'd load .env file present on server. ...

asp.net - Unable to retrieve the value of textbox inside repeater, when repeater is bound to datatable at postback -

i have repeater bound datatable last column of repeater has textbox (not programmatically created). have button outside repeater. in button_click event wanted value entered in textbox data in row of repeater. in/during postback, datatable again recreated , bounded repeater, in button_click event textbox empty (assuming user entered value , click button). have done rebinding of answer when googling it. im not sure if databinding of datatable repeater affects textbox column since column not part of datatable? how go it? please see html , behind code below, html <div id="ucprodres-any-mfg"> <asp:repeater id="rptanymfg" runat="server" > <itemtemplate> <div id="ucprodres-any-mfg-row"> <div class="ucprodres-stock manufacturer"> <div class="ucprodres-mfg "> <div id="ucprodres-...

python - logp in stochastic variables of pymc -

i have intrinsic confusion regarding logp. explain through anexample on na webpage don't fall short of explaining well. i wrote disaster_model.py illlustrated in tutorial: http://pymc-devs.github.io/pymc/tutorial.html i launched python shell , after importing required modules, did following in [2]: import disaster_model out[2]: -2.9780301980174 in [3]: disaster_model.switchpoint.logp out[3]: -4.709530201312334 in [4]: disaster_model.late_mean.logp out[4]: -2.407183392124894 in [5]: disaster_model.early_mean.logp out[5]: -2.9780301980174 m = mcmc(disaster_model) m.sample(iter = 10000, burn = 1000, thin = 10) in [11]: m.switchpoint.logp out[11]: -4.709530201312334 in [12]: m.early_mean.logp out[12]: -3.2263189370368117 in [13]: m.late_mean.logp out[13]: -0.9012784557735074 in [14]: m.disasters.logp out[14]: -164.37141285002255 i reemphasize line (written in disaster_model.py) disasters = poisson('disasters', mu=rate, value=disasters_array, observed=true ...

How can I replace the nth occurence of a substring/character within a string? [Python 3] -

i going replacing every fifth "b" "c" here input string: jstr = aabbbbbaa now here code import re m = re.search('c', jstr) jstr1 = jstr[:m.end()] jstr2 = jstr[:m.end()] jstr3 = jstr[:m.end()] jstr4 = jstr[:m.end()] jstr5 = jstr[m.end():] jstr6 = jstr5.replace('c', 'b', 1) jstr == (jstr1+jstr6) the output keep getting same aabbbbbaa i started with? jstr = "aabbbbbaabbbbb" count = 1 res= "" # strings immutable have create new string. s in jstr: if count == 5 , s == "b": # if count 5 have our fifth "b", change "c" , reset count res += "c" count = 1 elif s == "b": # if "b" not fifth add b res , increase count count += 1 res += "b" else: # else not "b", add res res += s print(res) aabbbbcaabbbbc finds every fifth b, counting b's using count, when have reac...

datetime - How to get milliseconds from LocalDateTime in Java 8 -

i wondering if there way current milliseconds since 1-1-1970 (epoch) using new localdate , localtime or localdatetime classes of java 8. the known way below: long currentmilliseconds = new date().gettime(); or long currentmilliseconds = system.currenttimemillis(); i'm not entirely sure mean "current milliseconds" i'll assume it's number of milliseconds since "epoch," namely midnight, january 1, 1970 utc. if want find number of milliseconds since epoch right now, use system.currenttimemillis() anubian noob has pointed out . if so, there's no reason use of new java.time apis this. however, maybe have localdatetime or similar object somewhere , want convert milliseconds since epoch. it's not possible directly, since localdatetime family of objects has no notion of time zone they're in. time zone information needs supplied find time relative epoch, in utc. suppose have localdatetime this: localdatetime ldt = l...

c++ - Hello World CUDA compilation issues -

i'm using cuda example book , attempting compile first real example in book. i'm on osx 10.9.2: my source is: @punk ~/documents/projects/cuda$ /developer/nvidia/cuda-6.0/bin/nvcc hello.c nvcc warning : 'compute_10' , 'sm_10' architectures deprecated, , may removed in future release. hello.c:6:1: error: unknown type name '__global__' __global__ void kernel(void) { ^ hello.c:6:12: error: expected identifier or '(' __global__ void kernel(void) { ^ hello.c:10:3: error: use of undeclared identifier 'kernel' kernel<<<1,1>>>(); ^ hello.c:10:11: error: expected expression kernel<<<1,1>>>(); ^ hello.c:10:17: error: expected expression kernel<<<1,1>>>(); ^ hello.c:10:19: error: expected expression kernel<<<1,1>>>(); ^ 6 errors generated. and source simply: punk ~/documents/projects/cuda$ cat hello.c ...

vcl - How to break up TPageControl tabs into seperate files in Delphi? -

i have vcl form 5 tab tpagecontrol on it. each ttabsheet 's content unrelated , has lot of individual controls , processing logic...so want break it's easier deal code "just tab". having line like //-------------------------- begin rules tab methods ------------------- just isn't cutting anymore. really, think i'd each tab in separate file somehow. currently i'm contemplating creating vcl frame each ttabpage. if did i'd either need load frames tpagecontrol in constructor, or when tab shown. is approach? better make whole tform each tab? should continue wrap tabs in tpagecontrol, or should changed ttabcontrol if content loaded dynamically? if approach, better load tabs on startup, or each time tab shown? (perhaps pros/cons if it's not totally obvious better in most/all cases) you can use either frames or forms. with frames have add tabcontrol parent each frame. with forms have to dock each form pagecontrol (the form captio...

clojure - Clojurescript ajax post always returning nil value -

i have atom vector of maps describes starting messages,like this... (def messages (atom [{:message "hello world" :user "foo"} {:message "ajax fun" :user "bar"}])) i have routes set this... (defroutes home-routes (get "/messages" [] (response/edn @messages)) (post "/add-message" [message user] (response/edn (swap! messages conj {:message message :user user})))) in clojurescript file have this... (defn render-message [{:keys [message user]}] [:li [:p {:id user} message " - " user]]) (defn render-messages [messages] (let [messages-div (domina/by-id "messages")] (destroy-children! messages-div) (->> messages (map render-message) (into [:ul]) template/node (append! messages-div)))) (defn by-id [id] (.getelementbyid js/document id)) (defn add-message [] (post "/add-message" {:format :edn :params {:message (value (by-id "message...

asp.net identity - UserCookieAuthentication in Mono 3.4.1 -

when ever add line below startup class exception below. self hosted exe running mono (ubuntu). works fine in windows. i've narrowed down usecookieauthentication call. can instantiate options without issue. idea going on here? have aspnet identity working , ef6/mysql. app.usecookieauthentication(new cookieauthenticationoptions()); unhandled exception: system.reflection.targetinvocationexception: exception has been thrown target of invocation. ---> system.typeloadexception: not load type 'microsoft.owin.security.dataprotection.dpapidataprotector' assembly 'microsoft.owin.security, version=2.1.0.0, culture=neutral, publickeytoken=31bf3856ad364e35'. @ microsoft.owin.security.dataprotection.appbuilderextensions.createdataprotector (owin.iappbuilder,string[]) <0x00052> @ microsoft.owin.security.cookies.cookieauthenticationmiddleware..ctor (microsoft.owin.owinmiddleware,owin.iappbuilder,microsoft.owin.security.cookies.cookieauthenticationoptions) <0x002...

php - Laravel how to retrieve specific value in array -

i have polymorphic relation between organizations , ratings. ratings table set so: id - integer user_id - integer score - integer ratable_type - text ratable_id - integer calling $org->ratings retrieve array ratings associated specific org. however, want see if there rating specific user_id value. basically, want retrieve rating user_id = auth::user()->id . possibly without looping through ratings see when $org->rating->user_id == auth::user()->id ? if don't need load relation, query db: $org->ratings()->where('user_id', auth::id())->first(); // returns rating model or null // in previous versions of framework (if auth has no id method) $org->ratings()->where('user_id', auth::user()->id)->first(); otherwise filter collection: $org->ratings->first(function ($key, $rating) { return $rating->user_id == auth::id(); }); // before: rating model or null

Python noob hangman issue -

i'm trying learn python , i'm writing hangman game (which seems 'hello world' of python lol). think i've got down, function i've written replace hidden letters rightly guessed letter isn't working. life of me seems should want, instead replace entire hidden word 1 letter correctly guessed. here's specific function: def update_word_guessed(guess): global word_guessed in xrange(word.count(guess)): x in xrange(len(word)): if guess == word[x]: word_guessed = word_guessed.replace(word_guessed[x], word[x]) print word_guessed, 'wg[x] =', word_guessed[x], 'word[x] = ', word[x] return word_guessed and here's whole thing: import random import string wordlist_filename = "words.txt" def load_words(): """ returns list of valid words. words strings of lowercase letters. depending on size of word list, function may take while finis...

Selecting option from Javascript drop down menu with Applescript - How to? -

using applescript so set settrimsize "'7.440&quot; x 9.690&quot; (246mm x 189mm)'" tell application "safari" javascript "document.forms['aspnetform']['_ctl0:_ctl0:maincontent:maincontent:ctlbooktypeselector:ddltrimsize'].value = " & settrimsize in document 1 end tell it should work select option list <tr id="trimsizerow"> <td align="right" class="formlabelsmallright"> <label>trim size</label> </td> <tr id="trimsizerow"> <td align="right" class="formlabelsmallright"> <label>trim size</label> </td> <td align="left" width="60%"> <select name="_ctl0:_ctl0:maincontent:maincontent:ctlbooktypeselector:ddltrimsize" id="_ctl0__ctl0_maincontent_maincontent_ctlbooktypeselector_ddltrimsize"> <option selected="selected" value="...