Posts

Showing posts from February, 2012

javascript - AngularJS SPA with Node.js and parse.com backend -

i have angularjs spa ui-router works perfectly. uses parse.com backend, , have working on regular apache server. now want move node.js server-app, , want node.js handle cruds parse.com. i set nice little node.js app act server, , works. my question is: how handle requests between node.js server-app , angularjs spa? i've included server.js file, in case can use it. // set ===================================================================================================== var express = require('express'), path = require('path'), morgan = require('morgan'), bodyparser = require('body-parser'), methodoverride = require('method-override'), routes = require('routes'), keys = require('./config/keys'), port = 80; var app = express(); var parse = require('parse/node').parse; // view engine setup ==============================================================================

android - Send data from seperate thread within a service to service Class -

can suggest me tutorial explains on how send data android seperate thread class within service class -----> sends data to------> service oncreate() method. the thread can timertask or thread class or kind threads within service class i'm not sure understood when data to------> service oncreate() however, need use handler created inside service's oncreate method , pass thread. posting runnable handler thread result in executing runnable in ui thread (which thread service running on).

AngularJS: Video disable autoplay and preload not working -

note: strictly angular solutions please. no jquery. default video controls not work our scenario. scenario: click play button, load , play video. should not preload video unless button clicked. but, both preloading , autoplaying without button click. missing in fiddle? html <div ng-app ng-controller="videoctrl"> <video preload="preload" autoplay="autoplay"> <source src="http://www.w3schools.com/html/mov_bbb.mp4"> </video> <button ng-click="playvideo($event)">play</button> </div> angular function videoctrl($scope) { $scope.autoplay = false; $scope.preload = "none"; $scope.playvideo = function () { console.log("hello"); $scope.autoplay = true; $scope.preload = "auto"; } } css div { position:relative; width:300px; height:150px; } button { position:absolute; top:50px; left:120px; } https://jsfiddle.net/

sql - How to get results of a TQuery en Delphi? -

database when run following query in database: select t.id tabla t id=3 resutl: no rows returned now try show message in delphi "the record not exist". in form have component tquery call qvalidacion connected database oracle 11g. try 1 procedure tfprueba.buttonaceptarclick(sender: tobject); begin qvalidacion.close; qvalidacion.sql.add('select t.id'); qvalidacion.sql.add('from tabla t'); qvalidacion.sql.add('where id=3'); qvalidacion.open; qvalidacion.first; if (not qvalidacion.eof) begin showmessage('the record not exist'); //it should display message, not show end; qvalidacion.sql.clear; end; if want check if record in query don't use qvalidacion.eof qvalidacion.isempty if (qvalidacion.isempty) begin showmessage('the record not exist'); end; the eof function here returning true when reach end of dataset. example: qvalidacion.first

angularjs - Toggling play / pause button using a directive in ionic / angular -

i want toggle play / pause button in ionic using directive, based on value of $scope.autoplay in html have button element: <playbtn></playbtn> the button ionic icon. play button: <i class="ion-ios-play"></i> pause button: <i class="ion-ios-pause"></i> how should directive changed toggle icon ? .directive('playbtn', function() { return { restrict: 'e', template: '<i class=""></i>', link: function(scope,element,attrs) { if(scope.autoplay == 'true') { //show pause button } else { //show play button } }; } }) you can use ng-class so: .directive('playbtn', function() { return { restrict: 'e', scope: {autoplay:'='}, template: '<i ng-class="{\'ion-ios-play\': autoplay, \'ion-ios-pause\': !autoplay}"></i>'

python - Trouble Importing in Ipython: ImportError: No module named 'ipdb' -

i've run "pip install ipdb" when run "import ipdb" in ipython still error: importerror: no module named 'ipdb' what mean? similarly, when i'm importing files (with .py extension) in ipython, i'm getting error (importerror: no module named chapter_1_python_syntax) though i've checked path directory , it's correct. when error after using 'pip install', closing , restarting terminal solve problem.

osx - issues with sed on Mountain Lion -

i trying delete line on file looks this: test 1800 in cname mydomain.com. i using sed on mountain lion , trying following keep getting no errors, line not deleted. sed -i -e '/$regex/d' $file or sed -i "" -e '/$regex/d' $file where $regex expression containing line mention above , $file name of file line is. any appreciate it. this near duplicate of sed command find , replace in file ... , , portable answer same there: sed -e '/$regex/d' $file >$file.tmp && mv $file.tmp $file ...for reasons, , advantages, given there. when you're concerned portability, posix spec great resource, since describes common subset of unix commands, frustratingly restricted, pretty reliably present in unixes 1 come across.

vba - Crystal Report XI error in formula using Basic Syntax " 'THEN' Missing " -

Image
i getting error ' then ' missing if play around formatting highlight else if way down formula = line. i have attached screenshots show mean highlight. have come realize crystal report finicky formatting sometimes, can provide insight or correct approach formula working? thanks in advance! dim qtyavailable number if isnull({hb_available_qty_sku\\.avail}) qtyavailable = 0 else if ({hb_available_qty_sku\\.avail}) = 0 , ({inventory_part\\.prime_commodity}) fly* or spc* "na" else if {shop_material_alloc\.qty_required} = {shop_material_alloc\.qty_assigned} qtyavailable = {hb_available_qty_sku\\.avail}+{shop_material_alloc\.qty_assigned} else qtyavailable = {hb_available_qty_sku\\.avail} end if end if end if formula = qtyavailable you need have "then" on same line "if" modified pseudocode of if statement s

javascript - Converting byte[] to ArrayBuffer in Nashorn -

how convert array of bytes arraybuffer in nashorn? trying insert binary data pure javascript environment (i.e., doesn't have access java.from or java.to ) , create instance out array of bytes. looks going wrong way. made more sense convert uint8array since i'm sending in is array of bytes. i created following function: function bytetouint8array(bytearray) { var uint8array = new uint8array(bytearray.length); for(var = 0; < uint8array.length; i++) { uint8array[i] = bytearray[i]; } return uint8array; } this convert array of bytes (so bytearray of type byte[] ) uint8array .

php - Gathering rows to 1 row and adding column -

hello learning programming , working on project of php , mysql, have problem. what doing have table called marks , every time people add mark student, add column table, table looks this: |------------------| | subject | marks | |------------------| | math | 16 | | english | 18 | | history | 15 | | math | 14 | | english | 20 | |------------------| but want change when treat it: |-------------------------| | math | 16 | 14 | | english | 18 | 20 | | history | 15 | | |-------------------------| how can mysql's query, or php if needed? well final goal make html table know how it. i sorry if looked simple, beginner @ databases , programming , apologize if title confuses guys. you can try select subject, group_concat(marks order marks) marks table group subject order subject it give 2 columns, 1 comma-separated list of subjects. english 18, 20 history 15 math 14, 16

Unable to parse xml in GO with : in tags -

i find if tags in xml file have : in them unmarshal code in go not seem work. insights ? for example, in xml file below, summary works not cevent . <summary>...air quality alert </summary> <cap:event>air quality alert</cap:event> type entry struct{ summary string `xml:"summary"` cevent string `xml:"cap:event"` } cap namespace identifier, not part of tag name. here shorthand urn:oasis:names:tc:emergency:cap:1.1 (this answer looks may have condensed explanation of namespaces: what "xmlns" in xml mean? ) the go "encoding/xml" package not handle namespaces well, if there no conflicting tags, can elide namespace altogether type entry struct { summary string `xml:"summary"` event string `xml:"event"` } the proper way specify event, in case of identical tags in different namespaces, full namespace like: type entry struct { summary string `xml:

c# - WPF Navigate to other page -

i want navigate between pages public partial class mainwindow : window { public mainwindow() { initializecomponent(); } private void routeitems(object sender, routedeventargs e) { navigationservice nav = navigationservice.getnavigationservice(this); nav.navigate(new itemspage()); } } getnavigationservice returns null <window x:class="special.mainwindow" name="window" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:special" mc:ignorable="d" title="mainwindow" windowstate="maximized"> <button content="go"

Call VBA Class Module in Excel formula -

i know function of module can called in formula this: =getmymodulefunction() now call class module function. don't know if class module can instantiated in formula @ i've created function in module can call =getmymodulefunction() : ' class module myclassmodule: public property myproperty() string myproperty = "hello world!" end property public function getmyfunction() string getmyfunction = "hello world!" end function ' end class module myclassmodule ' module mymodule: public function getmyclassmodule() myclassmodule set getmyclassmodule = new myclassmodule end function ' end module mymodule so after tried in formula bar: =getmyclassmodule().getmyfunction() =getmyclassmodule().myproperty which shows error dialog formula invalid. not possible i'm trying achieve here? use modules instead functions , subs duplicate names confusing , error prone use in modules.. your question similar question asked h

android - New Google Sign-In: Token used too late, 1452928807 > 1452897485 -

i'm trying implement new google sign-in in new app. i implemented official example additionally requesting idtoken. then send token server via volley post request , verify using python example google posted here (on bottom of page). everything working fine except verification of idtoken . following error occurs time: token used late, 1452928807 > 1452897485: it followed account information of user. it seems token not refreshing - or - because expiring date of token stays same, if sign out , in again. google doesn't mention method refresh token or if has expired. has how solve problem? 1452928807 1/15/2016, 11:20:07 pm gmt-8:00 1452897485 1/15/2016, 2:38:05 pm gmt-8:00 1452928807 > 1452897485: probably timezone mismatch. id token expires in 1hr. looks it's issued @ 1:38pm (expire @2:38pm) , used @ 2:20pm? (all in gmt-8) (i don't know why took hour try verify it? :) retrying?) guess in gmt+1 time zone? could confirm serve

Oxyplot division color change -

Image
does know how change color of division markers on oxyplot? can't seem find specific property anywhere. here code using produce plot below. can see division markers black. change color. thanks. <oxy:plot plotareabordercolor="white" background="#242426" textcolor="white" margin="5" title="x , y fpos" titlefontsize="12" grid.row="0" grid.columnspan="2"> <oxy:lineseries itemssource="{binding xydata}"/> </oxy:plot> the property looking ticklinecolor . have in both axes: effect: code: <oxy:plot> ... <oxy:plot.axes> <oxy:linearaxis position="left" ticklinecolor="white" /> <oxy:linearaxis position="bottom" ticklinecolor="white" /> <oxy:plot.axes> </oxy:plot>

ms access - DAO.Recordset.RecordCount property not working as expected -

i running query input form. extract records 1 table, table joined 3 others. extract record. in case there 1 record , query find it. problem every time run code, 1 more recordcount. first time run it, recordcount 1 , debug.print gives me correct information. second time run it, recordcount 2 , debug.print gives me correct information twice. third time ... 3 , 3, etc. doesn't matter if close form (from variables) , reload it. number keeps climbing. closed access , reopened , number keeps climbing - didn't reset 1 record found. the query selects records depending on productid (qtyordered - qtyproduced > 0) , records sorted priority of customers. dim rs dao.recordset dim db dao.database dim findcsql string findcsql = "select tblwarehousetransfers.wtrproductid, tblorderdetails.odepriority, tblorderdetails.odequantityordered, " _ & " tblorderdetails.odeqtyproduced, tblcustomers.companyname " _

c - C99 pointer to a struct which contains a pointer to a struct -

the k&r "the c programming language" 2nd edition says on page 131 given set of variables : struct rect r, *rp = &r; where : struct rect { struct point pt1; struct point pt2; }; and struct point { int x; int y; } then these 4 expressions equivalent : r.p1.x rp->pt1.x (r.pt1).x (rp->pt1).x earlier on same page see : p->member_of_structure which described "refers particular member". i changed hyphens underscores ensure not confused minus sign. so great, can see have refer nested struct because struct rect contains within struct point. well definition of rect such pt1 , pt2 both pointers struct point? here hit troubles following code bits : typedef struct some_node { struct timespec *tv; struct some_node *next; } some_node_t; clearly making linked list here , no problem. what big problem : struct timespec some_tv; clock_gettime( clock_realtime, &some_tv ) /* set head node */ struct so

BNE branch in MIPS assembly -

right i'm preparing test in computer architecture, , being stuck in task don't understand. * $1=4, $2=2, $3=x here's code loop: addi $2,$2-1 sll $2,$2,2 mult $3,$1 mflo $3 sw $3, 0($2) bne $2,$1,loop my question is, value $2 have after this? 4 or 4x? maybe clearer if write out ordinary paper math: $1 = 4 $2 = 2 $3 = x loop: $2 = $2 -1 $2 = $2 * 2^2 $lo = $3 * $1 $3 = $lo "contents of memory address in $2" = $3 if $2 != $1 goto loop

Visual Studio, csproj: How can I specify a linked file in DependentUpon? -

suppose have default.aspx.cs in project, want make dependent upon default.aspx file that's linked. e.g.: <content include="..\somedir\default.aspx"> <link>default.aspx</link> </content> this doesn't work: <compile include="default.aspx.cs"> <dependentupon>default.aspx</dependentupon> <subtype>aspxcodebehind</subtype> </compile> this doesn't work: <compile include="default.aspx.cs"> <dependentupon>..\somedir\default.aspx</dependentupon> <subtype>aspxcodebehind</subtype> </compile> for both, error: the parent file, 'default.aspx', file 'default.aspx.cs' cannot found in project file. is possible have file dependent upon linked file? i tried same thing , seems not supported. check this: https://bitbucket.org/jfromaniello/nestin/issue/4/error-when-nesting-linked-files "dependentupon

express session - Error: Connection strategy not found MongoDB -

here simple connection use express session store, keeps banging out error though text right book. pretty sure has 'new mongostore' object initialization. var express = require('express'), expresssession = require('express-session'); var mongostore = require('connect-mongo/es5')(expresssession); var sessionstore = new mongostore({ host: '127.0.0.1', port: '27017', db: 'session' }); var app = express() .use(expresssession({ secret: 'my secret sign key', store: sessionstore })) .use('/home', function (req, res) { if (req.session.views) { req.session.views++; } else { req.session.views = 1; } res.end('total views you:' + req.session.views); }) .use('/reset', function(req, res) { delete req.session.views; res.end('cleared views'); }) .listen(3000); add url new mongostore()

linked list - C++ Linker Errors (LNK 2019: unresolved external symbol) / Project Specific -

main issue i trying build homework project involving linked lists , custom classes, when build project, following 3 linker errors... 1>customerimp.obj : error lnk2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class linkedlisttype<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const &)" (??6@yaaav?$basic_ostream@du?$char_traits@d@std@@@std@@aav01@abv?$linkedlisttype@v?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@@@@z) referenced in function "public: void __thiscall customertype::printrentedvideo(void)" (?printrentedvideo@customertype@@qaexxz) 1>testvideostore.obj : error lnk2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl o

VIM Always Use Tabbed Pages -

i command can put in ~/.vimrc file make vim open in tabbed pages mode without having pass -p on command line. is there such command? if not, there better way this. currently, i'm using alias vi='vim -p' in bash profile. thanks..... setting following in ~/.vimrc , source ~/.vimrc au vimenter * if !&diff | tab | tabfirst | endif works being mentioned here or set alias in rc file e.g. ~/.bashrc . approach take. alias vim='vim -p' alias vi='vim -p'

MultipleApiVersions with Swagger -

i trying enable versioning on rest api, version specified in header, "api-version":2 , vendor media type, "accept: application/vnd.company.resource-v2+json , application/json; version=2" , or in query string "?version=2" . implementation using ihttprouteconstraint , routefactoryattribute. works perfectly. however, swagger not able match right model correct versioned document. operationid version 1 model. public class devicescontroller : apicontroller { [httpget, routeversion( "api/devices", 1, name = "v1.devices" )] [responsetype( typeof( ienumerable<models.v1.device> ) )] public ihttpactionresult getv1( ) { return ok( new list<models.v1.device> { ... } ); } [httpget, routeversion( "api/devices", 2, name = "v2.devices" )] [responsetype( typeof( ienumerable<models.v2.device> ) )] public ihttpactionresult getv2( ) { return ok( new list<

python - Modifying a variable in a function has no result -

i have tkinter application, have mainloop typical of tkinter, , various functions handle mouse clicks , garbage. in 1 of functions, generate string , want store string somewhere in program, can use later on if other function called or maybe if want print main loop. import , that, here , there etc etc #blah blah global declarations fruit = '' def somefunction(event): blahblahblah; fruit = 'apples' return fruit mainwin = tk() #blah blah blah tkinter junk #my code here #its super long don't want upload #all of works, no errors or problems #however button = button( blahblahblha) button.bind("<button-1", somefunction) print fruit #yields nothing mainwin.mainloop() this abridged example. else in program works fine, can track variable throughout program, when it's time saved later use, gets erased. for example, can print variable pass along 1 function argument, , fine. preserved, , prints. instant try loop or store later u

Parsing complicated Json Array in C# -

this question has answer here: parse json string inconsistent field names 1 answer i have json array: { "array":[ { "name_0":"value_0", "name_1":"value_1" }, { "name_2":"value_2", "name_3":"value_3", "name_4":"value_4", "name_5":"value_5" } ] } the data structures inside json array not consistent. how can parse them in c#? thanks! one way be var serializer = new javascriptserializer(); var data = serializer .deserialize<dictionary<string, list<dictionary<string, string>>>>(input); this because json data structure this. innermost element have dictionary<string, string> nested in generic list in turn nested in generic dict

Does Apache or some other CLIENT JAVA implementation support HTTP/2? -

i'm looking java client can connect http/2 based server.. server supporting http/2 api. don't see popular apache http client https://hc.apache.org/ still supporting http/2. does apache have implementation java client supports http/2? if not, there java client supports connecting http/2 preferably on java 7? jetty 's provides 2 http/2 java client apis. both require java 8 , mandatory use of alpn, explained here . low level apis these apis based on http2client , it's based on http/2 concepts of session , streams , uses listeners notified of http/2 frames arrive server. // setup , start http2client. http2client client = new http2client(); sslcontextfactory sslcontextfactory = new sslcontextfactory(); client.addbean(sslcontextfactory); client.start(); // connect remote host obtains session. futurepromise<session> sessionpromise = new futurepromise<>(); client.connect(sslcontextfactory, new inetsocketadd

erlang - Run an escript using TLS distribution -

i have been unable make tls distribution work when providing arguments vm via %! line in escript. cat test.es #!/usr/bin/env escript %%! +p 256000 -env erl_max_ets_tables 256000 -env erl_crash_dump /dev/null -env erl_fullsweep_after 0 -env erl_max_ports 65536 +a 64 +k true +w w -smp auto -boot /tmp/start_clean -proto_dist inet_tls -ssl_dist_opt server_certfile "/var/lib/cinched/cert.pem" server_cacertfile "/var/lib/cinched/cacert.pem" client_certfile "/var/lib/cinched/cert.pem" client_cacertfile "/var/lib/cinched/cacert.pem" server_keyfile "/var/lib/cinched/key.pem" client_keyfile "/var/lib/cinched/key.pem" -name test@192.168.101.1 main(_) -> io:format("ping: ~p~n",[net_adm:ping('cinched@192.168.101.1')]). [root@dev1 ~]# ./test.es {error_logger,{{2016,1,15},{23,36,42}},"protocol: ~tp: not supported~n",["inet_tls"]} {error_logger,{{2016,1,15},{23,36,42}},crash_report,[[{

html - When I move checkbox position to navbar, then hide and show sidebar is not working -

in demo used checkbox hide , show sidebar respectively move content left side question when change checkbox current position navbar doesn't work. please me. jsfiddle index.html <div id="wrapper"> <div id="header"> <h2>my header</h2> </div> <div id="navbar"> <h2>my navbar</h2> </div> <div class="content-wrapper"> <input id="slide-sidebar" type="checkbox" role="button" /> <label for="slide-sidebar"><span>close</span></label> <div class="sidebar-left"> <h2>lecture dates</h2> <p>11/07 - lecture on caesar</p> <p>11/08 - lecture on caesar</p> <p>11/09 - lecture on caesar</p> <p>11/10 - lecture on caesar</p>

python - How to pass different commands in tkinter based on user input -

i'm starting learn python , thought idea learn tkinter. i'm doing program takes 3 numbers user input , calculate them, printing result. from tkinter import * root = tk() root.title("test") e1 = entry(root) e1.pack() e2 = entry(root) e2.pack() e3 = entry(root) e3.pack() l = label(root) l.pack() def my_function(a,b,c): if condition: (calculations) l.config(text="option1") else: (calculations) l.config(text="option2") b = button(root, text="result", command= lambda: my_function(float(e1.get()),float(e2.get()),float(e3.get()))) my question is, how can set button print error message in case inputs not numbers? when try inside function, valueerror: cannot convert string float i managed make work despite still printing error in shell using def combine_funcs(*funcs): def combined_func(*args, **kwargs): f in funcs: f(*args, **kwargs) return combined_func def check

python - Removing strings from other strings -

how remove part of string like blue = 'blue ' yellow = 'yellow' words = blue + yellow if blue in words: words = words - yellow that thought like? edit: know thatit won't work want know work. since cant use '-' in str() you can use str.replace exchange text empty string: words = words.replace(yellow,'') note transform: "the yellow herring" into simply: "the herring" (the replacement happen anywhere in string). if want remove 'yellow' end of string, use .endswith , slice: if blue in words , words.endswith(yellow): words = words[:-len(yellow)]

Memory leak in Java? -

i wondering if following code produced sort of memory leak in java. anyways here's code: public class test { public static void main(string[] args){ a = new a(); a.x = new a(new a(new a(new a(a)))); a.x.x = null; } } class a{ public x = null; a() {} a(a a){ x = a; } } if number a's: a = new a(); // 1 a.x = new a(new a(new a(new a(a)))); // 2 3 4 5 then have circular chain: a → 1 → 2 → 3 → 4 → 5 → 1 when break circle using a.x.x = null , get: a → 1 → 2 instances 3, 4, , 5 eligible garbage collection. then, when main exits, a goes out of scope, , instances 1 , 2 eligible garbage collection. note program end before gc has chance anything.

c# - Why is WPF not updating on INotifyPropertyChanged? -

i implementing inotifypropertychanged implementing same interfaces , passing calls observablecollection`1 : class wrappedobservablecollection<telement> : inotifypropertychanged, inotifycollectionchanged //, ...others { private readonly observablecollection<telement> baselist; public wrappedobservablecollection(observablecollection<telement> baselist) { contract.requires(baselist != null); this.baselist = baselist; } #region wrapping of baselist public event propertychangedeventhandler propertychanged { add { ((inotifypropertychanged)baselist).propertychanged += value; } remove { ((inotifypropertychanged)baselist).propertychanged -= value; } } #endregion } this works fine, when bind .count property, ui never updates. suspect wrong implementation of inotifypropertychanged have verified propertychanged.add called, , event raised when property being changed. passing .add call i

Email validation error in PHP -

i have build form , and link emailvalidation.php send data on mail. facing error in php code on line 37. don't know error. error: fatal error: call undefined function checkdnsrr() in g:\pleskvhosts\domain.com\httpdocs\php\functions\emailvalidation.php on line 37 php code: <?php function validemail($emailaddress) { $isvalid = true; $atindex = strrpos($emailaddress, "@"); if (is_bool($atindex) && !$atindex) { $isvalid = false; } else { $domain = substr($emailaddress, $atindex + 1); $local = substr($emailaddress, 0, $atindex); $locallen = strlen($local); $domainlen = strlen($domain); if ($locallen < 1 || $locallen > 64) { // local part length exceeded $isvalid = false; } else if ($domainlen < 1 || $domainlen > 255) { // domain part length exceeded $isvalid = false; } else if ($local[0] == '.' || $local

ios - How to set a small image on a uiimage view on a particular position? -

i created uiview. need set small image on particular position. i can setting image in small separate view. but, plan dynamically on large uiview full screen. thanks. uiview *view = [[uiview alloc] initwithframe:cgrectmake(0,0,320,200)]; view.backgroundcolor=[uicolor clearcolor]; [self.view addsubview:view]; // add image in view uiimageview *imageview =[[uiimageview alloc] initwithframe:cgrectmake(50,50,20,20)]; imageview.image=[uiimage imagenamed:@"image.png"]; [view addsubview:imageview];

ruby on rails - How to add time format to locale on production? -

i use activeadmin gem , here error when try access site: actionview::template::error (translation missing: ru.time.formats.long) . same error in development mode on local computer, , add time: formats: long: "%y-%m-%d %h:%m:%s" to activeadmin original ru locale in external libraries. no good, know. in production can't this. tried add format config/locales in app, nothing happen. how add it? update i'm sorry stupid question leave here. problem solved adding format locale in config/locales , server restart problem solved adding format locale in config/locales time: formats: long: "%y-%m-%d %h:%m:%s" and server restart

html - How can I display first 3 element instead of displaying all css only -

i have code this: <ul> <li>karnataka</li> <li>assam</li> <li>gujarath</li> <li>westbengal</li> <li>karnataka</li> <li>assam</li> <li>gujarath</li> <li>westbengal</li> <li>karnataka</li> <li>assam</li> <li>gujarath</li> <li>westbengal</li> </ul> and want display first 3 li elements. this css code may you. <style> ul li { display: none; } ul li:nth-child(1), ul li:nth-child(2), ul li:nth-child(3) { display: list-item; } </style>

bash - How to store a variable with command status [shell script] -

i searching word in file through grep command. need store status in variable v1 0 or 1. how can it? tail -n 2 test.s | grep -q "fa|"$(date "+%m/%d/%y") tail -n 2 test1.s | grep -q "fa|"$(date "+%m/%d/%y") tail -n 2 test2.s | grep -q "fa|"$(date "+%m/%d/%y") if above searching word found variable v1 value should 0 else 1. file content : keytran|20160111|test.s submkeyqwqwqw|ndm|jan 11 01:34|test.s|6666666|sdgdh-rb|ltd.et.cts00.act loadstatus|thunnnb|6666666|fa|01/16/2016|01:34:57|01/16/2016 |01:37:13|load|test.s please suggest depending on shell, after each command execution status of previous command available in special variable: bash family $? , csh family $status$ : #/bin/bash tail -n 2 test.s | grep -q "fa|"$(date "+%m/%d/%y") v1=$? or #/bin/csh tail -n 2 test.s | grep -q "fa|"$(date "+%m/%d/%y") set v1=$status

Getting the previous Word in VBA using selection.previous wdword, 1 bug -

i'm trying write macro type previous word @ cursor. problem when i'm using "selection.previous wdword, 1" previous character, 2 previous characters , seems bug. when press "delete" button works , strange me. i'd glad if help. ultimate goal create calendar converter inside word using code. here how test it: msgbox selection.previous(unit:=wdword, count:=1) it same using next : msgbox selection.next(unit:=wdword, count:=1) instead of next word, returns word after! for example text: during flight on 21/3/1389 if cursor right after 1389, msgbox selection.previous(1,1) show "/"; if cursor after space after 1389 shows "1389". problem is, think, space. question if there alternative read previous word instead of command (selection.previous(unit:=wdword, count:=1)) word not buggy - it's behaving designed. something has tell word words start , end. when cursor stands right of space it's (quite logically) @ begi

How to convert a loop that sometimes adds a transformed value to a Java 8 stream/lambda? -

how convert java 8 lambda expression? list<string> inputstrings = new arraylist<>(); // say, list of inputstrings arraylist<someclass> outputresultstrings = new arraylist(); for(string aninputstring : inputstrings) { someclass someresult = dosomthing(aninputstring); if (someresult != null) { outputresultstrings.add(someresult); } } your code loops on input strings, performs dosomthing on each of them ( map in java's terminology), ignores results null ( filter in java's terminology) , produces list of results ( collect in java's terminology). , when put together: list<someclass> outputresultstrings = inputstrings.stream() .map(someclass::dosomething) .filter(x -> x != null) .collect(collectors.tolist()); edit: suggested tunaki, not-null check can cleaned objects::nonnull : list<someclass> outputresultstrings = inputstrings.stream()

mysql - PHP time range validation -

i working on php page includes scheduling. planning include validation limit user input same or between time ranges other schedules under single classroom. for better understanding, if schedule present on database schedule 1 : mwf 9:00am - 10:00am; room 1 neither schedule 2 : wednesday 9:00am - 10:00am; room 1 nor schedule 3: mwf 9:30am - 10:30am; room 1 allowed entered. can give me idea make happen? assuming have start_time , end_time , whenever new item getting added should not find existing items such that: start_time between new_item_start_time , new_item_end_time or end_time between new_item_start_time , new_item_end_time

Consume only first message from Kafka Queue? -

is there way consume first message kafka queue out of 1000 messages? trying implement same in java. , not have backend db. right can't it, there kip-41 solved this. although if know size of element want, there property in consumer called fetch.message.max.bytes can set size of elements want poll, , each poll return 1 record.

c# - VisualStateManager not working when value is passed through a converter for applying a Button Bg -

Image
i applying button's background color through converter. @ first applied after hovered or pressed background color gone forever , not come back. desired behavior default state hovered after hover state my problem the orange background not appear again when hovered state over implementation button usage <button content="continue" style="{staticresource buttonanycolorstyle}"> <button.background> <solidcolorbrush color="{binding something, converter={staticresource panelbgcolorconverter}, mode=twoway}" /> </button.background> </button> button style <style x:key="buttonanycolorstyle" targettype="button"> <setter property="borderbrush" value="{staticresource phoneforegroundbrush}" /> <setter property="template"> <setter.value> <controltemplate targettype="button">

asp.net - Changing a div to Text Box? -

i have div area following in .aspx program. <div id="valueintroduction" type="text" class="labelarea" runat="server"> </div> <div class="line"></div> <asp:button id="editbutton" runat="server" text="edit" /> currently div valueintroduction getting data database. have edit button in program. when press edit button trying change div text box. try this.. 1.add textbox , make visible="false" 2.when clicking edit button copy div's contents textbox , make div invisible using visibility:"hidden" . 3.set textbox visibility true.

Image on the first line disappear in wordpress posts, but DOES NOT disappear from second line onward -

i developing wordpress theme based on roots starter theme . however, facing problem here. when insert image on first line not appear, not in html mark-up (i checked page source ensure that). however, when insert image second line onward shows (also reflected in html mark-up checked page source). i wondering if issue theme or wordpress itself. using version 3.5.1 in development environment. would highly appreciate discussion on this. well can try insert image manually begining in html code.find path of image want insert , put on <img src="" />

Google Directions API Duration In Traffic -

i noticed when using google directions api web service when request contains more 1 leg response not include duration in traffic information. 1 leg requests duration in traffic present in response. why this? https://maps.googleapis.com/maps/api/directions/json?origin=50.7963874022473,-1.12215042114258&destination=50.8525337185711,-1.17932204157114&waypoints=50.7921245679458,-1.13072438976753&mode=driving&departure_time=1452940200&traffic_model=pessimistic&units=imperial&key=mykey in above request no duration in traffic in below request https://maps.googleapis.com/maps/api/directions/json?origin=50.7963874022473,-1.12215042114258&destination=50.8525337185711,-1.17932204157114&mode=driving&departure_time=1452940200&traffic_model=pessimistic&units=imperial&key=myapi the duration in traffic present. you can prefix waypoints via: , return response 1 leg , include duration in traffic field.(so long correc parameters in

android - Counter on toolbar cart icon -

i trying add counter on cart icon public boolean oncreateoptionsmenu(final menu menu) { if (!mnavigationdrawerfragment.isdraweropen()) { menu.clear(); getmenuinflater().inflate(r.menu.main, menu); relativelayout badge =(relativelayout)menu.finditem(r.id.action_cart).getactionview(); ui_hot = (textview) badge.findviewbyid(r.id.count); } return super.oncreateoptionsmenu(menu); } but following message: java.lang.nullpointerexception: attempt invoke virtual method 'android.view.view android.widget.relativelayout.findviewbyid(int)' on null object reference following xml menu file: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".mainactivity"> <item android:id="@+id/action_cart" android

Inserting a block of JavaScript code into a PHP script -

a friend of mine wanted me gather statistics website gave him following code insert in page footers: <div> <script> var wandtopsitesuserid; match = document.cookie.match(new regexp("wandtopwildlifesites" + '=([^;]+)')); if (match) wandtopsitesuserid = match[1]; else { wandtopsitesuserid = (+new date * math.random()).tostring(36).slice(2, 12); document.cookie = 'wandtopwildlifesites=' + wandtopsitesuserid + '; expires=tue, 1 jan 2030 00:00:00 utc; path=/'; } document.write('<div style="visibility: hidden;"><a href="http://www.www.fxxxxx.com/"><img src="http://xxxxxx.azurewebsites.net/log/logvisit/?siteid=2&userid=' + wandtopsitesuserid + '&pagename=' + location.pathname + '" alt="wand top wildlife sites" /></a></div>'); </script> </div> what

jsf - Running XHTML and HTML on the same page? -

is possible run html , xhtml on same page? using jsf , need integrate in template. if need give them .html extension, you'd need change default suffix .html well. add following entry web.xml achieve that: <context-param> <param-name>javax.faces.default_suffix</param-name> <param-value>.html</param-value> </context-param>

objective c - Working with data in iOS Apps (What to choose? NSData, CoreData, sqlite, PList, NSUserDefaults) -

when develop iphone app (time tracker, todolist etc) never know whats best way deal data. once used plist, next time sqlite or coredata. how decide whats best project? (only talking data management) for example if want develop: time tracker app > plist choice? rss reader app > coredata? photo app > sqlite? email client > ? for beginner can point me proper directions? (i know depends lot on app , thought help) i'm far away developing complicated apps, still pretty simple. thanks help, marc you can use these rules of thumb decide storage model work app. if data fits in memory entirely , relatively unstructured, use plist if data fits in memory entirely , has tree-like structure, use xml if data not fit in memory , has structure of graph, , app not need extraordinary query capabilities, use core data if data not fit in memory, has complex structure, or app benefits powerful query capabilities provided relational databases, use sqlite i

ruby on rails - Nested attributes not being inserted into table -

i have situation 1 of nested fields being passed parameters not being inserted table. my model company has_one :incorporation . incorporation has, right anyway, 1 field, nested company form follows <%= simple_form_for @company, url: url_for(action: @caction, controller: 'incorporations'), html: {id:"incorporationform"}, remote: false, update: { success: "response", failure: "error"} |company| %> ... <%= company.simple_fields_for :incorporation |f| %> <div class="padded-fields"> <div class="form_subsection"> <%= f.input :trademark_search, as: :radio_buttons, label: 'would trademark search , provide advice regarding issues identify in relation name have selected?', input_html: { class: 'form-control radio radio-false' } %> </div> </div> <% end %> ... <% end %> the new , create