Posts

Showing posts from July, 2014

is there a way to record audio in mp4 using ruby on rails / web / html5 -

i find way record audio (not video) in mp4 format on web. reason ios/android both generating in format, , want able consistent audio format. (android mediarecorder example not mp3, thats reason why preferred format) is there recorder records mp4 audio web/html5/rails? update: i found out recorderjs https://github.com/mattdiamond/recorderjs im guessing if change encodewav encodempeg4 in here: https://webaudiodemos.appspot.com/audiorecorder/js/recorderjs/recorderworker.js this target audio outcome im trying achieve: type: audio codec: mpeg aac audio (mp4a) there example uses web audio api . think front-end(html , javascript) should handle audio recording generate mp4 file can save in rails app via carrierwave or else.

java - can i use an if statement to append to a string? -

right have following code, , i'm trying code append string instead of system.out.println. know worded oddly, not sure how put it. char[] c = inputstring.tochararray(); for(char ch : c) { if(ch <=88 && ch>=65 || ch<=120 && ch>=97) system.out.print(character.valueof((char) (ch+2))); else if (ch =< 1) system.out.print(character.valueof((char) (ch-24))); else if (ch == 2) system.out.print(character.valueof((char) (ch-24))); else system.out.print(ch); all need defining string next c[] array and add characters operator += , @ end have complete string of want, char[] c = inputstring.tochararray(); string str = ""; for(char ch : c) { if(ch <=88 && ch>=65 || ch<=120 && ch>=97) { str += character.valueof((char) (ch+2)); } else{ if (ch =...

sql - is it possible to order by column based on values, in sqlite? -

suppose table name status ab 1 cd 4 ef -2 mn 3 pq -1 xy 2 defination of status: 1,2 = success 3,4 = failure -1,-2 = error expected results after order (order status based on success, failure, error) ab 1 xy 2 cd 4 mn 3 ef -2 pq -1 while simple order status gives this ab 1 xy 2 mn 3 cd 4 pq -1 ef -2 is there way sort in expected way, without adding column maps similar status value? you can use case statement: order (case when status in (1, 2) 1 when status in (3, 4) 2 else 3 end) if have reference table, can join information well.

jquery - Adding placeholder attribute to input HTML -

i'm attempting add placeholder attribute multiple input tags unique classes in form. form generated plugin can't add attribute in manually. unfortunately nothing have tried has worked. because each placeholder different i'm address each 1 separately... here's html <input class="name-field" type="text" id="yourname_38_1" name="yourname" value=""> the jquery i'm using $(".name-field").attr("placeholder", "name"); when in console following referring line jquery on. uncaught typeerror: $ not function my understanding of jquery basic. please help thank in advance. dave you need load jquery plugin. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> please add line above <script></script> tag.

node.js - Cookie not accepted while web-scraping with NodeJS -

i'm making script web-scrape response post request in form. thing page asks cookie jsessionid on it, before that, script makes request same page rescue cookie sent use in post request, page response 'error 400: invalid path /salidaaplicacion requested' var request = require('request'); var async = require('async'); request = request.defaults({ jar: true }); var url = "http://civil.poderjudicial.cl/civilporweb/atpublicodaction.do"; var headers = { 'host': 'civil.poderjudicial.cl', 'user-agent': 'mozilla/5.0 (x11; ubuntu; linux x86_64; rv:44.0) gecko/20100101 firefox/44.0', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'accept-language': 'en-us,en;q=0.5', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive' } var options = { url: url, followredirect: true, forever: true...

jquery - Can not get values from a form in javascript -

i'm trying values of different inputs of form: <form class="form-horizontal" role="form" id="form_newcours"> <div class="form-group"> <label class="control-label col-sm-2" for="discipline">matiere:</label> <div class="col-sm-4"> <input type="text" class="form-control" id="discipline" placeholder="matiere"> </div> </div> <div class="form-group" align="left"> <label class="control-label col-sm-2" for="datetimepicker">date:</label> <div class="input-group col-sm-4"> <input type="text" class="form-control" id="datetimepicker"/> <span class="input-group-addon"...

javascript - What's the proper way to test SPA angular application which relies heavily websockets? -

i'm using protractor jasmine test our angular 1.5 based application. page uses reactjs handle streams sources websockets. protractor responsible angular based events/states. problem is, have wait data arrive websockets. right doing manual waits, that's unstable , lame. i'm guessing somehow have listen websocket manually, i'm not sure. what best way wait data coming websockets?

json - Map mongodb collection to non existing java class -

i've got mongodb several collections , need map collects new java classes using spring. first idea expect 1 item json , generate java class based on json code. here's json: { "_id" : objectid("5550b632e6d665c6fc8b4567"), "id" : numberint(1), "registrationdate" : "2008-11-02 10:55:05", "firstname" : "", "lastname" : "", "email" : "mail@mail.nl", "salutation" : "", "enabled" : false, "bouncecount" : numberint(0), "groups" : [ numberint(1), numberint(15), numberint(16), numberint(19), numberint(20), numberint(21), numberint(22) ], "tags" : [ numberint(1), numberint(19), numberint(29), numberint(34), numberint(49), numberint(51), ...

excel - VBA: copy paste from selected workbooks based on cell value -

i want copy data selected different workbooks based on cell value , paste 1 single workbook enter code here sub ram_copypaste() dim w workbook dim string dim x worksheet dim j integer dim integer j = cells(2, 1).value = "portfolio" b = ".xlsx" = 1 j set w = & & b set x = & w.worksheets("download1").range("a1:h14").copy workbooks("te copypaste.xlsx").x.cells(1, 1).pastespecial xlpastevalues next end sub try this: use debug.print @ various points understand code better. sub ram_copypaste() dim w workbook dim string, b string dim x worksheet dim j integer dim integer j = cells(2, 1).value 'use debug.print check value of j = "portfolio" b = ".xlsx" = 1 j set w = workbooks(a & & b) 'make sure have workbook 'with same name & & b opened otherwise give error. if 'you don't have opened have on drive first open , set it. set x = w.sheets(a & i) ...

php - Form if then Else/ifElse HTML on submit -

i have form need act in specific ways. example: user brings equipment back: don't want show in form. user takes equipment out: want generate form, enters information, form sends information database. user takes equipment out: generates said form, doesn't enter information, form submits information after 20 sec, information in database. i doing simple page refresh information form pulling equipment had been brought warehouse day. commented out , stuck on ajax page. i tried creating new php page had 301 page refresh , worked page index page, however, form wasn't working , commented out auto submit , form works great... except can't fulfill last requirement page submit data if user forgets put equipment information in. i'm looking if/then/else type of page submission. however, can't figure out how 1 purely in either php or html. have figured out far doesn't work , know i'm way off somewhere. <!doctype html> <html> <body> <...

json - reading the numbers from a flat text files in R -

i have text file following lines: {"time":"2015-11-15t17:56:45.300","x":93.32,"y":8.6,"s":4.57,"dis":0.45,"on_field":true,"game":{"references":[{"origin":"gsis","id":2015111500}]},"team":{"references":[{"origin":"gsis","id":"5110"}]},"play":{"references":[{"origin":"ngs","id":""}]},"references":[{"origin":"gsis","id":"00-0026189"}]} {"time":"2015-11-15t17:56:45.400","x":93.77,"y":8.48,"s":4.55,"dis":0.47,"on_field":true,"game":{"references":[{"origin":"gsis","id":2015111500}]},"team":{"references":[{"origin":"gsis","id":"51...

Durandal child router updating bindings only once -

the router have created builds navigation model, it's missing update bindings need updated each time page loaded within childrouter ( app.pagetitle , app.pagedescription ). is there way how map these updates durandal's lifecycle, activate event? define([ 'durandal/app', 'plugins/router', 'knockout', 'app' ], function(app, router, ko, app) { console.log("content start"); var childrouter = router.createchildrouter().makerelative({ moduleid : 'app/content/pages', fromparent : true }).map([ { route : [ '', 'grid' ], moduleid : 'grid/index' }, { route : 'details/:id', moduleid : 'details/index' }, { route : 'details/tabs/base', moduleid : 'details/tabs/base' } ]).buildnavigationmodel(); console.log("cms title start"); app.pagetitle(app.i18n('app:modules.cont...

automation - Why does this small vbscript to change desktop background work intermittently, not all the time? -

a small vbscript in order change desktop background automatically, practically demo purposes: dim wshshell dim susername set wshshell = wscript.createobject("wscript.shell") set oshell = createobject("wscript.shell") currwallpaper = oshell.regread("hkcu\software\microsoft\internetexplorer\desktop\general\wallpap ersource") if currwallpaper = "c:\users\utsav\pictures\493889.png" msgbox "ok1" swallpaper = "c:\users\utsav\pictures\336180.png" elseif currwallpaper = "c:\users\utsav\pictures\336180.png" swallpaper = "c:\users\utsav\pictures\1920-1080-278658.png" else swallpaper = "c:\users\utsav\pictures\493889.png" end if ' update in registry oshell.regwrite "hkcu\control panel\desktop\wallpaper", swallpaper ' let system know change oshell.run "%windir%\system32\rundll32.exe user32.dll,updateperusersystemparameters", 1, true msgbox "done" this scrip...

twitter bootstrap - Angularjs 1.5 vs boostrap.js Compatibility -

i have compatibility problems angularjs 1.5 , boostrap.js. i tried versions without success. created plunkr exemplify typeahead input doesn't work. <input type="text" ng-model="selected" uib-typeahead="state state in states | filter:$viewvalue | limitto:8" class="form-control"> plunkr example you need make 2 changes code: in script.js, change var scotchapp = angular.module('scotchapp', ['ngroute']); to var scotchapp = angular.module('scotchapp', ['ngroute', 'ui.bootstrap']); in home.html, change typeahead="state state in states... to uib-typeahead="state state in states...

html - Align div into a list element like a grid -

i have structure: <ul class="wrap-accordionblk"> <li class="accordionblk-item"> <div class="accordionblk-header"> <div class="row-fluid"> <div class="infoblk"> <label>id sessione</label><strong>mm-00120853</strong> </div> <div class="infoblk"> <label>data</label>31/01/16</div> <div class="infoblk"> <label>nome sessione</label>ferrarif-2b0000118188</div> <div class="infoblk"> <label>anno stagione</label>ai 2015</div> <div class="infoblk"> <label>tipo ordine</label>2b</div> <div class="infoblk"> <label>n° capi</label>1</div> <div class="infoblk"> ...

android - How to use Firebase REST API in Java? -

i need able update data firebase without setting firebase online specified data gets sent while no wifi available. have been unable find documents or guides on how use rest api in java. can me it? unfortunately there isn't existing java sdk firebase rest interface (that find). instead you'll need make 1 using http client of choice. here's example using jersey: import javax.ws.rs.core.mediatype; import com.sun.jersey.api.client.client; import com.sun.jersey.api.client.clienthandlerexception; import com.sun.jersey.api.client.uniforminterfaceexception; import com.vnomicscorp.firebase.sdk.firebasesdk; import com.vnomicscorp.firebase.sdk.firebasesdkexception; public class firebasesdkjersey { private static final string default_auth_param_name = "auth"; private static final string default_path_format = "%s.json"; private final string credentials; private final string url; private final client client; private strin...

Better way to validates a hash parameter in a method on Ruby? -

is there better dry way validate parameter hash contains key this? module exemple def foo_method(config) validate_config(config) foo = config[:foo] bar = config[:bar] qux = config[:qux] || {} end private def validate_config(config) raise(argumenterror, "no foo config found", caller) unless config.has_key?(:foo) raise(argumenterror, "no bar config found", caller) unless config.has_key?(:bar) end end use hash#fetch : def foo_method(config) foo = config.fetch(:foo) bar = config.fetch(:bar) qux = config.fetch(:qux, {}) end foo_method({}) #=> key not found: :foo (keyerror) foo_method({foo: 1}) #=> key not found: :bar (keyerror) foo_method({foo: 1, bar: 2}) #=> no error you can pass block fetch called if given key not found, e.g.: foo = config.fetch(:foo) { raise argumenterror, "no foo config found" }

user interface - jQuery UI: Action when slider position changes -

i using jquery ui slider http://jqueryui.com/slider/#steps it's simple slider 3 steps (1, 2 , 3) , div-element ("id_1") shows picture. want picture changes depending on position of slider. in position "1" shows picture, , picture changes move slider position 2 or 3. how can this? <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>jquery ui slider - snap increments</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> <script> $(function () { $("#slider").slider({ value: 100, min: 1, ...

sql server - Run a migration script where a column is created and then updated -

i have script want add surveyid , remove contractid sor table. script not run because surveyid created in script , considered invalid column not exist before created. how fix this? see -- start of script print 'start of script' if not exists ( select 1 information_schema.columns table_schema = 'dbo' , table_name = 'sor' , column_name = 'contractid' ) begin print 'the colmun contractid not exist in sor table' goto endscript end begin transaction go if @@error <> 0 begin goto errorscript end print 'begin transaction' -- add new surveyid field both questions , sor if exists ( select 1 information_schema.columns table_schema = 'dbo' , table_name = 'sor' , column_name = 'surveyid' ) begin print ...

How can I stack up the number patterns with while loop in java? -

dear professionals! i'm super beginner of programming java. i'm learning basic stuff in school. while i'm doing homework, i'm stuck in 1 problem. the question using nested loops make stack-up number pattern: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10 i can use while loop (because haven't learned or loops yet), , outer loop body should execute 10 times. can use print , println making pattern. i tried many different methods while loop, can't figure out. please, please give me hint. this code i'm working on far: class c4h8 { public static void main(string[] args) { int i, j; = 1; while(i <= 10) { j = 1; while (j <= 10) { system.out.print(j); j++; } system.out.println(); i++; } } } but displays: 1234567891...

Python bytecode and .pyc file format specification -

i'm looking pyc file format specification, found link provides bytecode instructions without opcodes need alot more detailed file includes file structure of .pyc, can provide me link it? thanks. the structure of .pyc files explained here: http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html cilyan posted link actual documentation bytecodes in standard library ( https://docs.python.org/3.5/library/dis.html#python-bytecode-instructions ).

python - Why does ImageMagick from MacPorts does not work, when imagemagick from Homebrew does -

i have fixed error installing through homebrew know: why homebrew work macports not?? if install imagemagick macports error though can call " convert " command line: traceback (most recent call last): file "<stdin>", line 1, in <module> file "/library/python/2.7/site-packages/wand/image.py", line 20, in <module> .api import magickpixelpacket, libc, libmagick, library file "/library/python/2.7/site-packages/wand/api.py", line 205, in <module> 'try install:\n ' + msg) importerror: magickwand shared library not found. had not installed imagemagick library. try install: port install imagemagick which did! if install via homebrew , can no longer use " convert " command line plays wand pip . why that?

javascript - How can I update the video dynamically in this context? -

i have working 1 video have 3 thumbnails , want update video once click on thumbnail. so code have , guess somehow should put video names in array. how call video array? function playvideo(){ if(!vidinitialized){ vidinitialized = true; $("#video").append( "<source src='video/video1.mp4' type='video/mp4'></video>" ); $("#video").append( "<source src='video/video1.webm' type='video/webm'></video>" ); initvideo('pause'); }else{ video.currenttime=0; } } function addeventlisteners() { document.getelementbyid("video1").addeventlistener("click", playvideo); document.getelementbyid("video2").addeventlistener("click", playvideo); document.getelementbyid("video3").addeventlistener("click", playvideo); }

javascript - D3js force layout - line with gradient between nodes -

Image
this d3 force layout: (please run code snippet) var width = 600, height = 600; var svg = d3.select('body').append('svg') .attr('width', width) .attr('height', height); var color = d3.scale.category20(); var datanodes = [ { x: width/3, y: height/3 , group: 0, color: 'blue'}, { x: 2*width/3, y: height/3, group: 1, color: 'red' }, { x: width/2, y: 2*height/3, group: 2, color: 'green'} ]; var datalinks = [ { source: 0, target: 1}, { source: 1, target: 2}, { source: 2, target: 0} ]; var force = d3.layout.force() .charge(-400) .linkdistance(height/2) .size([width, height]) .linkstrength(1.3) .friction(0.8) .gravity(0.9); force .nodes(datanodes) .links(datalinks) .start(); var link = svg.selectall(".link") .data(datalinks) .enter().append("line") .attr("class", ...

string formatting - DecimalFormat with DecimalFormatSymbols problems in Java -

i'm tring format bigdecimal value 621500.0 thisdecimalformatsymbols: zerodigit = '0' groupingseparator = '.' decimalseparator = ',' permill = '‰' percent = '%' digit = '#' patternseparator = ';' infinity = "∞" nan = "�" minussign = '-' currencysymbol = "¤" intlcurrencysymbol = "xxx" monetaryseparator = '.' exponential = 'e' locale = {locale@59611} "en" currency = {currency@59612} "xxx" serialversiononstream = 3 and use pattern "€ #,0;€ -#,0" , when execute new decimalformat("€ #,0;€ -#,0", numberformatsymbols).format(value) returns in € 6.2.1.5.0.0 instead of € 62150.0 . idea why? related locale? thanks.

xml - Output unique XSLT attribute values when using a key nested within another key -

i have been working on web page constructed through combination of xslt 1.0 , xml , come across problem have been struggling export unique attribute values while using xsl key ( <xsl:keyname="name" match="pattern" use="expression"/> ) nested within xsl key. due sensitivity of xml data, have reconstructed problem using 'classic w3c schools example' of bookstore. the code: xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output indent="yes"/> <xsl:key name="prom-by-id" match="bookstore/promotion" use="promotionid"/> <xsl:key name="location-by-id" match="bookstore/locations" use="locationid"/> <xsl:template match="bookstore"> <xsl:apply-templates select="book"/> </xsl:template> <xsl:template match="book"> <xsl:...

C# iterate list for objects without some fields -

how can iterate list<> of objects having 2 of 4 fields? below code works far there easier way in c#? using system; using system.collections.generic; namespace consoleapplication1 { class program { private static void main() { var list = new list<employee> { new employee("a", 32, 5235.32, 2004, 3, 2), new employee("b", 28, 1435.43, 2011, 11, 23), new employee("c", 47, 3416.49, 1997, 5, 17), new employee("d", 22), new employee("e", 57) }; list.foreach(l => { if (l.salary == 0) console.writeline(" {0} {1}", l.name, l.age); }); } } } it looks you're trying filter items out of collection - you're doing works fine, it's (arguably) more idiomatically written as: foreach(var l in list.where(x => x.s...

ruby on rails - How can I add two variables on one line in HAML? -

i'm trying modify haml code , output 2 different variables on same line. how can achieve this? %h3= @level.name " $" @level.price ideally, want output in format: individual $35 any appreciated. thanks! %h3= "#{@level.name} $#{@level.price}"

error handling - disable JsHint warnings in Intel XDK -

the brackets editor in intel xdk requiring me strange things in js file. if try make ajax call, jshint give me error: `$ not defined (w117).` the way i've been able figure out how rid of warning seems wrong me. have declare `var $;`. it's same thing when use 'document' manipulate dom. if don't do `var document;` first not defined warning. issue? if go jshint documentation (found here: http://jshint.com/docs/ ) it'll tell configuration jshint comes default set of warnings designed configurable. there 3 main ways configure copy of jshint: can either specify configuration file manually via --config flag, use special file .jshintrc or put config projects package.json file under jshintconfig property. in case of .jshintrc, jshint start looking file in same directory file that's being linted. if not found, move 1 level directory tree way filesystem root. (note if input comes stdin, jshint doesn't attempt find configuration fil...

dictionary - Scala filter by set -

say have map looks this val map = map("shoes" -> 1, "heels" -> 2, "sneakers" -> 3, "dress" -> 4, "jeans" -> 5, "boyfriend jeans" -> 6) and have set or collection looks this: val set = array(array("shoes", "heels", "sneakers"), array("dress", "maxi dress"), array("jeans", "boyfriend jeans", "destroyed jeans")) i perform filter operation on map 1 element in each of set retains. expected output should this: map = map("shoes" -> 1, "dress" -> 4 ,"jeans" -> 5) the purpose of doing if have multiple sets indicate different categories of outfits, output map doesn't "repeat" on technically same objects. any appreciated, thanks! first rid of confusion sets arrays. rest of example use definition instead: val arrays = array(array("shoes", "heels...

sql server - Stored procedure called in VBA keeps going to default value for a parameter -

i have stored procedure calling excel. 1 of parameters float, , seems not getting sql server. results fine in server , when hardcode query in vba. traced in sql server profiler , it's passing in default, null aka user didn't specify. going on here? the stored procedure: create procedure um.topstudents @semesterstart datetime, @semesterend datetime, @schoolid char(10) = null, @gradethreshold float = null begin select top 20 sc.schoolname school, sd.last, sd.first, sd.ssn, sd.dob dbo.studentrecords sr inner join dbo.lkpmajor mj on r.major = mj.code inner join dbo.tblstuddemo sd on sr.schoolid = sd.schoolid , r.ssn = sd.ssn inner join dbo.tblschools sc on sr.schoolid = sc.code r.startdate between @semesterstart , @semesterend , ((sr.schoolid = @schoolid ) or (@schoolid null)) , sr.major = '03' , sr.program = 'scholarship' ...

How to upload a Google App Engine (Go) project in a different folder than the app.yaml -

my project has following structure: | appengine |---- app.yaml |---- myscript.go | bower_components |----|... | build |----|images |----|----|branding |----|----|---- favicon.ico |----|styles |----|----|*.css |----|index.html | src | ... i upload entire content of build folder when running goapp deploy appengine . my app.yaml looks this: application: myproject version: 0-1 runtime: go api_version: go1 handlers: - url: /(.*\.(gif|png|jpg|ico|js|css)) static_files: ../build/\1 upload: ../build/(.*\.(gif|png|jpg|ico|js|css)) - url: /.* script: _go_app and myscript.go looks this: package myproject import ( "fmt" "io/ioutil" "net/http" ) func init() { http.handlefunc("/", handler) } func handler(w http.responsewriter, r *http.request) { site, err := ioutil.readfile("../build/index.html") if err != nil { panic(err) } fmt.fprint(w, string(site)) } when run goapp serve appen...

eclipse - Jersey com.sun.jersey.spi.container.servlet.ServletContainer error when using MAVEN -

when i'm attempting build simple test application in eclipse using jersey. when try run app exception: java.lang.classnotfoundexception: com.sun.jersey.spi.container.servlet.servletcontainer i've researched answers question here on stack overflow , have verified these things: it true missing class not exists in jersey-server more. class exists in jersey-servlet (notice "servlet", not "server"). maven dependencies this: <dependencies> <dependency> <groupid>com.sun.jersey</groupid> <artifactid>jersey-core</artifactid> <version>1.19</version> </dependency> <dependency> <groupid>com.sun.jersey</groupid> <artifactid>jersey-servlet</artifactid> <version>1.19</version> </dependency> <dependency> <groupid>com.sun.jersey</groupid> <artifactid>jers...

jquery - Run query based on two dropdown and show table PHP -

i have 2 dropdowns, second dropdown getting populated first dropdown condition. now, want take both dropdowns' conditions , apply query , show results in table via html. this code, script code: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.country').on('change', function() { // code add country information in url location.href = location.href.split('?')[0] + ['?country', $(this).val()].join('='); }); }); </script> php code first dropdown: <?php $countries = mysqli_query($mysqli,"select source nhws.masterkey group source;"); echo "<select class='country' name='country' style='width:200px'>...

java - Spring Data vs Couchbase SDK -

what difference between spring data library , couchbase java sdk? 1 preferred on other in specific scenarios? if working on spring project , spring data preferred on couchbase java sdk? spring data helps create automatic data access objects based on entity definitions. works multiple types of data stores. so, write own daos insert/update/delete/select items couchbase, or let spring data you. also, if need switch data stores later, data access interfaces wouldn't change.

haskell - How to let default values come from the database? -

why user object still have nothing createdat , updatedat ? why fields not getting assigned database? share [mkpersist sqlsettings, mkmigrate "migrateall"] [persistlowercase| user email string createdat utctime maybe default=current_time updatedat utctime maybe default=current_time deriving show |] main = runsqlite ":memory:" $ runmigration migrateall userid <- insert $ user "saurabhnanda@gmail.com" nothing nothing liftio $ print userid user <- userid case user of nothing -> liftio $ putstrln ("coulnt find userid=" ++ (show userid)) u -> liftio $ putstrln ("user=" ++ (show user)) output: userkey {unuserkey = sqlbackendkey {unsqlbackendkey = 1}} user=just (user {useremail = "saurabhnanda@gmail.com", usercreatedat = nothing, userupdatedat = nothing}) (edit: see solution below using triggers) the problem: default values don't override explicitly setting column null...

How does ElasticSearch and Lucene share the memory -

i have 1 question following quota es official doc: but if give available memory elasticsearch’s heap, there won’t left on lucene. can impact performance of full-text search. if server has 80g memory, issued following command start es node: bin/elasticsearch -xmx 30g means give process of es 30g memory maximum. how can lucene use left 50g, since lucene running in es process, it's part of process. the xmx parameter indicates how heap allocate es java process. allocating ram heap not way use available memory on server. lucene indeed run inside es process, lucene doesn't make use of allocated heap, uses memory heavily leveraging file system cache managing index segment files. there these 2 great blog posts ( this one , this other one ) lucene's main committer explain in greater details how lucene leverages available remaining memory. the bottom line allocate 30gb heap es process (using -xmx30g ) , lucene happily consume whatever left needs done. ...

signals - Can alarm(int) override sleep(int) in C? -

i've created signal handler alarm() . parent forks out process not have pending alarm signal. so, alarm invoked in parent process. alarm(2) invoked, overrides sleep(10) in parent process. parent waits 2 seconds before printing : "parent retval=8" whereas child waits 10 seconds. why alarm() signal override sleep() , sleep return (obviously in case, why? sleep() shouldn't return anything, right?)? the code given below. <headers> pid_t cpid; int main() { int retval; signal(sigalrm, handler); alarm(2); if ((cpid = fork()) == 0) { printf(“i’m child\n”); retval = sleep(10); printf(“child retval=%d\n”, retval); } else { printf(“i’m parent\n”); retval = sleep(10); printf(“parent retval=%d\n”, retval); } } /* handle sigalrm */ void handler(int sig) { if (cpid == 0) printf(“running child handler\n”); else printf(“running parent handler\n”); } s...