Posts

Showing posts from January, 2012

epoll - What file descriptors are available under Linux? -

in linux external resources , kernel mechanisms available file descriptors, can listened on select/poll/epoll. there's standard "file" fd, socketfd, timerfd - there list of available descriptors can use under linux no external libraries?

javascript - how do I format date when using pikaday -

i using pikaday module datepicker, format comes inappropriate format. tried adding line of code still not working: .config(['pikadayconfigprovider', function (pikaday) { pikaday.setconfig({ numberofmonths: 1, format: "yyyy/mm/dd" }); }]) this how html looks like: <div class="modal-body"> <form role="form"> <div class="form-group"> <input type="text" class="form-control" pikaday="mypickerobject" name="time" ng-model="clas.class_.time" placeholder="enter time" tabindex="3"> </div> </form> </div> also tried add inline attribute format = "yyyy/mm/dd" still not working. any help you can use moment.js , set format setting defaultdate : moment().format("mmm yyyy") this initial input date display format. displaying/processing date in other

create delay after dispalying text in TextView in android? -

im getting delay first , after text displayed wanted display text first , create delay??? textview textview=(textview)findviewbyid(r.id.correct_word) textview.settext("delay created"); final handler handler = new handler(); handler.postdelayed(new runnable() { @override public void run() { //your code } }, 2000); just move textview.settext("delay created"); inside runnable 's run() method: textview textview=(textview)findviewbyid(r.id.correct_word) final handler handler = new handler(); handler.postdelayed(new runnable() { @override public void run() { textview.settext("delay created"); } }, 2000);

javascript - grabbing multiple types of tags in one jquery object -

this question has answer here: bind event handler multiple elements jquery? 1 answer from http://jqfundamentals.com/chapter/events , "in of our examples until now, we've been passing anonymous functions event handlers. however, can create function ahead of time , store in variable, pass variable event handler. useful if want use same handler different events or events on different elements." $( 'li' ).on( 'click', handleclick ); $( 'h1' ).on( 'click', handleclick ); is there jquery li , h1 elements in 1 liner? interpret $( 'h1 li' ).on( 'click', handleclick ); to mean "all li items inside of h1 items" thank you separate selectors commas. $( 'h1, li' ).on( 'click', handleclick );

html - PHP / SQL page never stops loading during MYSQL connection -

i´m new sql , php, pardon me asking that´s simple, reason, though don´t have loops in code, when get´s part, continues loading page indefinitely. here snippet of code that. mysql_connect("localhost:8080", "root@localhost") or die("could not connect: " . mysql_error()); mysql_select_db("tickets"); $val1 = $_post["name"]; $val2 = $_post["mail"]; $val3 = $_post["betreff"]; $val4 = $_post["wichtigkeitsstufe"]; $val5 = $_post["nachricht"]; $sql = "insert ticket (name, e-mailodererreichbarkeitbeirückfragen, raumbezeichnungbzwnummer, wichtigkeitsstufe, problembeschreibungausführlich) values ({$val1}, {$val2}, {$val3}, {$val4}, {$val5})"; i values $val1,2,3,... input boxes in html file. in advance, cheers! edit: running both db , webserver on same ports. again help!

android - NoClassDefFoundError for OkHttpClient -

after adding facebook dependency in gradle i'm getting runtime error: compile 'com.facebook.android:facebook-android-sdk:4.6.0' please notice i'm using okhttp: compile 'com.squareup.okhttp:okhttp:2.5.0' and error log is: e/androidruntime: fatal exception: thread-109754 process: com.venkat.project, pid: 4453 java.lang.noclassdeffounderror: com.squareup.okhttp.internal.util @ com.squareup.okhttp.okhttpclient.<clinit>(okhttpclient.java:57) @ com.venkat.project.http.myhttpthread.run(myhttpthread.java:127) @ com.venkat.project.http.myhttpthread.run(myhttpthread.java:61) @ java.lang.thread.run(thread.java:841) 02-23 18:11:02.729 4453-4573/com.venkat.project i/dalvikvm: rejecting re-init on previously-failed class lcom/squareup/okhttp/okhttpclient; v=0x0 note: i'm getting error on samsung mobile 4.4 on emulator , on moto g 5.0 works. you getting java.

unity3d - Can't get rid of desktop.ini file in Unity project -

i had move unity project on google drive couple weeks continue work on game. after moving google drive, windows 10 starting adding desktop.ini file of directories in project folders. have moved project desktop hard drive , deleted of desktop.ini files. reason when try build project error says "invalid resource directory" , points path in android-resources folder desktop.ini file keeps getting generated. doesn't matter if delete or not because gets generated every time try build project. ideas? cloud storage known producing desktop.ini files accompanying problems. when windows creates desktop.ini in folder unity attempting package you'll "invalid resource directory" error since tries bundle file doesn't expect. you must prevent desktop.ini files being generated. there different methods no guaranteed solutions. try registry change: http://jamesisin.com/a_high-tech_blech/index.php/2010/09/nevermore-be-bothered-by-desktop-ini/ then move proj

python - cutting a trapezium (or whatever) in multiple pieces of same size -

i using python @ moment, don't what's wrong code: from sympy.solvers import solve sympy import symbol x = symbol('x') xpos = list([]) in range(6): xp = solve(6*x+22/32*x**2-544/6*(i+1),x) xpos.append(xp) xpos1 = list([]) in range(len(xpos)): xpos1.append(xpos[i][1]) it should give me list x positions cut trapezium pieces of same size... problem list xpos1 first created empty list , deleted within last line of code. when change last line to xpos1.append(xpos[i]) xpos1 created (as copy of xpos, of course). wrong code, don't it? thanks in advance try printing out variable before script terminates: from sympy.solvers import solve sympy import symbol x = symbol('x') xpos = list([]) in range(6): xp = solve(6*x+22/32*x**2-544/6*(i+1),x) xpos.append(xp) xpos1 = list([]) in range(len(xpos)): xpos1.append(xpos[i][1]) print(xpos1) that way see contents of list.

Pass by Reference in Haskell? -

coming c# background, ref keyword useful in situations changes method parameter desired directly influence passed value value types of setting parameter null . also, out keyword can come in handy when returning multitude of various logically unconnected values. my question is: possible pass parameter function reference in haskell? if not, direct alternative (if any)? it depends on context. without context, no, can't (at least not in way mean). context, may able if want. in particular, if you're working in io or st , can use ioref or stref respectively, mutable arrays, vectors, hash tables, weak hash tables ( io only, believe), etc. function can take 1 or more of these , produce action (when executed) modify contents of references. another sort of context, statet , gives illusion of mutable "state" value implemented purely. can use compound state , pass around lenses it, simulating references purposes.

javascript - How can i add permanent word to the text box? -

i trying add permanent word textbox.in text box take users firstname automatically when user enters name in firstname textbox using onkeyup="copytext()" function.what want want s add permanent word sitename textbox after getting automatically typed firstname. here code <td><input type="text" id="fname" name="fname" value="" placeholder="your first name" onkeyup="copytext()" required /></td> <td><input type="text" id="sitename" name="sitename" value="" placeholder="your site name" readonly/></td> here javascript code working <script type="text/javascript"> function copytext() { src = document.getelementbyid("fname"); dest = document.getelementbyid("sitename"); dest.value = src.value; } </script> this pretty doable jquery: $('#fn

c# - Replacement .net Dictionary -

given (simplified description) one of our services has lot of instances in memory. 85% unique. need very fast key based access these items queried very often in single stack / call. single context extremely performance optimized. so started put them them dictionary. performance ok. access items fast possible important thing in case. ensured there no write operations when reads occur. problem in meanwhile hit limits of number of items dictionary can store. die arraydimensionen haben den unterstützten bereich überschritten. bei system.collections.generic.dictionary`2.resize(int32 newsize, boolean forcenewhashcodes) bei system.collections.generic.dictionary`2.insert(tkey key, tvalue value, boolean add) which translates the array dimensions have exceeded supported range . solutions memcached in specific case slow. isolated specific use case encapsulated in single service so looking replacement of dictionary specific scenario. currently can't find 1 suppo

angularjs - Angular 2 AbstractControl runtime -

i following answer https://stackoverflow.com/a/38064881/3874858 implement "add more" ability angular 2 application. project, associated answer uploaded on http://plnkr.co/edit/nhsisciszntqzqjxkxsk?p=preview . unfortunately, start project, have comment these lines this.form.controls.payoffs.push(this.createpayoffformgroup(po)) this.form.controls.payoffs.push(this.createpayoffformgroup(emptypayoff)); console.log("added new pay off", this.form.controls.payoffs) this.form.controls.payoffs.removeat(index); and type "npm start" , uncomment. if not comment them, these errors: app/components/companyinsertion.component.ts(37,28): error ts2339: property 'payoffs' not exist on type '{ [key: string]: abstractcontrol; }'. app/components/companyinsertion.component.ts(56,24): error ts2339: property 'payoffs' not exist on type '{ [key: string]: abstractcontrol; }'. app/components/companyinsertion.component.ts(57,57): error ts2339

javascript - How to setup protractor tests for debugging with Visual studio 2015 -

we use: protractor e2e tests, mocha , chai, node js tools visual studio 2015 node.js project. protractor's conf.js looks this: exports.config = { framework: 'mocha', seleniumaddress: 'http://localhost:4444/wd/hub', specs: ['./tests/**/*_test.js'], mochaopts: { timeout: 30000 // ms } } all need - stop on breakpoints. protractor works fine while run protractr conf.js , can't find way breakpoints inside of ide. read articles, visual studio code , launch.json or remote debugging. both of them looks not common situation. tried brows.pause() , browser.debugger() or deugger; - no reaction. tests run , fails (as expected) same way without these commands. maybe there working configuration settings of project let me run protractor's testrs , debug them inside or @ least in browkser? @artem, note: eddie's requirement, him add answer here comment. the solution: reference: https://misaxionsoftware.word

android - How can I delete a determined row in Sqlite? -

i have listview . add single row in sqlite database checking it.( checkbox ) @ same time need delete row, i've unchecked. need id of row stored in table, due can delete row. how can ? checkbox changing code in adapter . public class mainvacancyadapter extends arrayadapter { private list<vacancymodel> vacancymodellist; private int resource; private layoutinflater inflater; arraylist<boolean> isselected; sqlhelper sqlhelper; public mainvacancyadapter(context context, int resource, list<vacancymodel> objects) { super(context, resource, objects); vacancymodellist = objects; this.resource = resource; sqlhelper = new sqlhelper(getcontext()); inflater = (layoutinflater) getcontext().getsystemservice(context.layout_inflater_service); isselected = new arraylist<>(vacancymodellist.size()); (int = 0; < vacancymodellist.size(); i++) { isselected.add(false); } } //fi

c# - WCF IClientMessageInspector.BeforeSendRequest modify request -

i'm trying modify request in wcf service. public object beforesendrequest(ref message request, iclientchannel channel) { string xmlrequest = request.tostring(); xdocument xdoc = xdocument.parse(xmlrequest); //some request modifications //here have xml in want send request = message.createmessage(request.version, request.headers.action, whathere?); request.headers.clear(); return null; } but don't know can set in createmessage or maybe different way set xml request. you can pass xmlreader object representing modified message. below example taken article how inspect , modify wcf message via custom messageinspector . public object beforesendrequest(ref system.servicemodel.channels.message request, system.servicemodel.iclientchannel channel) { console.writeline("====simplemessageinspector+beforesendrequest called====="); //modify request send client(only customize message body) request = transfo

windows - How to get global IPv6 address via batch-file -

i want global ipv6 address of computer stored inside variable. i found code, gives link-local address. for /f "delims=[] tokens=2" %%a in ('ping %computername% -6 -n 1 ^| findstr "["') (set ipv6=%%a) in vbscript can : to onlyipv6address.vbs strcomputer = "." set objwmiservice = getobject("winmgmts:" & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2") set colsettings = objwmiservice.execquery ("select * win32_networkadapterconfiguration ipenabled = 'true'") each objip in colsettings i=lbound(objip.ipaddress) ubound(objip.ipaddress) if instr(objip.ipaddress(i),":") <> 0 msgbox objip.ipaddress(i) next next and onlyipv4address.vbs strcomputer = "." set objwmiservice = getobject("winmgmts:" & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2") set colsetti

angularjs - How to integrate the Cumulocity DatePicker Directive into existing App? -

i want know if possible integrate existing datepicker directive cumulocity cumulocity app. currently difficult use own datepicker directive because of older angular version in use. best regards, meykel the datepicker used based on datepicker popup available here . is, however, old version of it. here basic example of it's use: <input ng-init="currentdate = new date(); ispopupopen = false" ng-model="currentdate" datepicker-popup datepicker-append-to-body="false" show-button-bar="false" show-weeks="false" is-open="ispopupopen" ng-click="ispopupopen = !ispopupopen">

swing - Choosing a Layout Manager - Java -

i'm having trouble find right layout manager. have images inside jpanel, different size wanted use flow layout let manager handle them. manager fills first row possible , warps line. ok, want stop @ second "warp". want show 2 rows of images , if want see more must click jbutton load others. flowlayout keeps inserting in third line , images cutted half because panel not "tall" enough. tips? i've tried flow layout , mig layout without success. combine flowlayout(outerpanel) gridbaglayout(innerpannel) u can define rows yourself, , u put jscrollpane on wont cut pictures , u still able see them in full size(my suggestion)

dependency injection - How does IoC container know which named instance to inject? -

when there multiple named implementations given interface, how container (i using unity in prism application) know 1 inject unless call container.resolve registered name? here simple example: public interface idependencyclass { void dosomething(); } public class dependencyclassa : idependencyclass { void dosomething() { } } public class dependencyclassb : idependencyclass { void dosomething() { } } public interface iconsumer { void takeuserspecificaction(); } public class consumer : iconsumer { idependencyclass dependencyinstance; public consumer(idependencyclass _dependencyinstance) { dependencyinstance = _dependencyinstance; } public void takeuserspecificaction() { dependencyinstance.dosomething(); } } public class mybootstrapper : unitybootstrapper { protected override void configurecontainer() { base.configurecontainer(); container.registertype<idependencyclass, dependencyclassa>

ios - How to develop iPhone app for iPhone 5 and newer? -

we developing application, targeting iphones, starting 5 , newer models. recently, discovered there no way say, app not support iphone 4s. my ideas are: just don't think 4s. whatever looks there... give message in application, not work on 4s. questions are: are there other options have? is risk of not getting app store? ios 10 not support 4s. if target app ios 10 , later can skip 4s. aside you'll need hardware feature 4s lacks subsequent models have, , make app require feature. (i don't think apple allows pick , choose models support.)

template10 - UWP - CommandBar : more button is "hidden" -

i have issue command bar: use template10, commandbar in grid on bottom of page. set property closeddisplaymode minimal. grid has visibility=collapsed default. when switch grid visibility visible, commandbar appears more button not visible, command bar empty. however, more button here because can click it. , when have click on @ least 1 time, content of button ("...") appears. hope clear... edit 2 here way reproduce issue: 1 - create new blank universal app project (without template10) 2 - replace xaml code in mainpage.xaml following: <page x:class="blankappbarmorebuttonhidden.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:blankappbarmorebuttonhidden" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="

node.js - querying one collection value and send other collections values -

everyone, have 2 schema 1 age , second questions trying find age age scheme , match number of age , if age true sends me question second collection loading... , displaying nothing 1). node js var agegroupquiz = require('../models/agegroupschema.js'); var questionquiz = require('../models/question.js'); exports.agegroupcontroller = function(req,res,next){ try{ var userobj = {}; var projection1 = '-id age_group.age_group_5.max_age'; var projection2 = '-id question'; var = agegroupquiz.findone(userobj,projection1); var age = 'a.age_group.age_group_5.max_age'; if(age===5){ questionquiz.find(userobj,projection2,function(err, data){ if(err){ console.log('getquestions : error while getting questions ' + err); return next(err); } //console.log(question); res.send(question); }); }else{console.l

javascript - How to get index of a key value pair -

var myobj={ age: null, anothercolumn: null, casenum: null, casecount: null, casecountfgfg: null, city: null, country: null, county: null } i have change key name @ 3rd position. information have new key name , position . something like myobj[2] = 'new value' please suggest be really careful ! before es2015 order of property keys not specified. can change , different browser browser. in es2015 order specified order of creation . so can not want . the possible way create new object , apply keys in order want. can recommend not depend on order of object keys !

amazon s3 - AWS Lambda - Is there a way to pass parameters to a lambda function when an event occurs -

i have dynamodb table , whenever new record added, want archive old data s3. thought use aws lambda. lambda function new record newly added/modified. want pass(to lambda function) additional parameter of s3 path record has uploaded. one way have whatever want pass lamda function in table/s3. this(the parameter) change each record inserted main table. can't read lambda function. (by time lambda function gets executed first inserted record, few more records have been inserted) is there way pass params lambda function? p.s: want execute lambda asynchronously. thanks... why not add parameters (s3 path) dynamodb table (where new raw added -not in table, @ same table lambda listening on)

Java representing time class -

i want represent time time class. can't use , set methods.only can use listed methods on code.but doesn't work. returns 0:0:0. public int addhours(int hours) { if(hours>=0&&hours<=23) { return hours; } return 0; } public int addminutes(int minutes) { if(minutes>=0&&minutes<=59) { return minutes; } return 0; } public int addseconds(int seconds) { if(seconds>=0&&seconds<=59) { return seconds; } return 0; } public string showtime() { return hours+":"+minutes+":"+seconds; } } your code nothing. you need this: public void addhours( int hours ){ this.hours += hours; // add hours this.hours %= 24; // roll on @ 24 hours } public void addminutes( int minutes ){ this

Problems retrieving data from controller using Ember.js 2.3.0 -

i trying learn ember following course , have following controller import ember 'ember'; export default ember.controller.extend({ title:'my blog post', body:'body of post', authors:['author1', 'author2', 'author3'], comments:[ { name:'name 1', comment:'comment 1' }, { name:'name 2', comment:'comment 2' }, { name:'name 3', comment:'comment 3' } ] }); and template: <h1>{{title}}</h1> <p>{{body}}</p> <p> <strong>authors:</strong> {{#each authors}} {{this}}, {{/each}} </p> <h4>comments</h4> <ul> {{#each comments c}} <li><strong>{{name}}</strong> - {{comment}}</li> {{/each}} </ul> and has been generating output: my blog post body of post authors: <my-app@controller:post::ember424>, <my-app@contro

c# - Why WPF Application throwing 'Microsoft.AspNet.SignalR.Client.Infrastructure.StartException' after installation? -

i developing chat application in wpf using signalr .there 2 projects in it, namely:- 1)wpf client 2)wpf server i've set multiple project on running(server , client).it running fine locally ,but when install server , client project, server project don't let client connect it. throws microsoft.aspnet.signalr.client.infrastructure.startexception. and when run server project locally , try connecting installed client application. gets connected , works fine onwards. i m not getting actual reason behind exception. googled didn't solution. this line of code exception. await connection.start(); details of exception follows:- statuscode: 500, reasonphrase: 'internal server error', version: 1.1, content: system.net.http.streamcontent, headers:{ date: tue, 19 jul 2016 2:36:32 gmt server: microsoft-httpapi/2.0 content-length: 0 } can please help?

node.js - How can i redo a GET request with request module if i get an error? -

this code: var request = require("request"); request({url:url, qs:propertiesobject}, function(err, response, body) { if(err) { console.log(err); } if (!err && response.statuscode == 200 ) { console.log(response.statuscode); } }); i don't need console.log error need redo request if err true. i'm using nodejs , request module get. can me? var request = require("request"); var options = {url:url, qs:propertiesobject} function handleresponse(err, response, body) { if(err) { request(options, handleresponse); } if (!err && response.statuscode == 200 ) { console.log(response.statuscode); } } request(options, handleresponse);

php - Call to a member function result() on a non-object -

there error message when view being loaded. "call member function result() on non-object" how fix this? this loop in view: discussion/view.php <?php foreach ($query->result() $result) : ?> <tr> <td> <?php echo anchor('comments/index/'.$result->ds_id,$result->ds_title) . ' ' . $this->lang->line('comments_created_by') . $result->usr_name; ?> <?php echo anchor('discussions/flag/'.$result->ds_id, $this->lang->line('discussion_flag')) ; ?> <br /> <?php echo $result->ds_body ; ?> </td> </tr> <?php endforeach ; ?> and function index in comments controller: public function index() { if ($this->input->post()) { $ds_id = $this->input->post('ds_id'); } else { $ds_id = $this->uri->seg

html - Unit testing javascript of a backend driven website -

i implemented nightwatch (behavior driven) testing couple of websites. of them backend driven (java, jsp). now of employees wrong choice, , should unit test framework. but front-end doesn't have 'units', reacts on html present on page, , binds plugins / vanilla js class it. am wrong, unit testing simple impossible front-end, there (almost) no functions return value. bound on page-load html element. for example: <div data-components="mycomponent"><div>inner</div></div> loads javascript (mycomponent), alter/add/remove html page. not 'return' anything. updates page. all advice more welcome. unit testing 1 of many ways test code. if have existing code doesn't have tests yet there's chance you're not going able test unit tests. unit testing has considered when designing application. unit testing popular because design , testability tend go hand in hand. unit tests can seen matter of code quality, ev

Oracle SQL - CASE statement returning multiple rows when not logically required too -

i have 2 tables: order o_no o_date o_co o_type o_list 1653 07/07/2015 12 p 8845 hol hol_no start_date end_date h_list 3 29/01/2014 30/06/2014 8845 9 01/10/2014 30/09/2017 8845 so current query: select o.o_no, o.o_date, o.o_co, o.o_type, h.start_date, h.end_date, case when o.o_date between h.start_date , h.end_date 'head' else 'line' end hol_type order o left join hol h on o.o_list = h.h_list this outputting: o_no o_date o_co o_type start_date end_date hol_type 1653 07/07/2015 12 p 29/01/2014 30/06/2014 line 1653 07/07/2015 12 p 01/10/2014 30/09/2017 head but expected output is: o_no o_date o_co o_type start_date end_date hol_type 1653 07/07/2015 12 p 01/10/2014 30/09/2017 head because o_date falls between condition , 1 line should returned. include date condition in join . select o.o_no, o.o_date, o.

How to test web app performance from a variety of geographical regions? -

i have web app in canada , works well. i have co-worker in arizona says takes 10 seconds web app load, , longer 2 images. is there easy way test performance of web application variety of geographical regions? any suggestions useful!! online tools such pingdom http://tools.pingdom.com/fpt/ allows choose geographic location test from. google analytics has site speed feature allowing see site load times visitor's geographic region if wish filter that. https://support.google.com/analytics/answer/1205784?hl=en

ruby - Rails 5 Address already in use - bind(2) for "127.0.0.1" port 3000 -

after coding got error on running rails s : address in use - bind(2) "127.0.0.1" port 3000 (errno::eaddrinuse) my environment is: $ rails -v rails 5.0.0 $ ruby -v ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux] i've tried: create new project - same checked rails 4.2 - problem solved reinstall rails 5 , ruby - same problem lsof -wni tcp:3000 returns me nothing ps aux | grep "rails" - nothing ps aux | grep "puma" - nothing ps aux | grep "ruby" -nothing use puma instead of rails s - problem solved use rails s -p 3001 - same problem, other ports too updated use rails_env=production bundle exec rails s - problem solved any suggestions? the problem appeared because of bug in puma's code. downgrading oldest version helped me. bug ticket: https://github.com/puma/puma/issues/1022

python - LibraryFunctionLoad and PATH -

Image
i'm using python-c api librarylink. how can specify exact python interpreter used? currently, wrong executable being used: which gives wrong one: (* sys.executable = /usr/bin/python *) with option can change this, , when - during call createlibrary or inside loadlibraryfunction ? what i've tried: playing setenvironment , friends playing "include*" options of createlibrary setting env path in wolframlibrary_initialize(wolframlibrarydata libdata)

Creating an initializer list in C -

how create initializer list in c? have use struct or union? because have written code apparently has problem how many initialized variables have. compiling error: number of initializers cannot greater number struct s { int a, d, p; }; #define s_initializer { 12, 10, 77 } struct s s = s_initializer; you (typically) provide value each member. if provide less, remaining members zero-initialized (c99, 6.7.8.21). if provide more, compiler warning , additional initializer values discarded. edit: olaf pointed out (thanks!), better use designated initializers: #define s_initializer { .a = 12, .d = 10, .p = 77 } this way, initializer robust against changes of struct associated with: struct s { int d, a, o, p; // ^ new value; , d inverted! }; is still initialized before, o initialized 0 (c99 6.7.8.19). , if drop p , compile error – @ least gcc. actually, standard states: if designator has form    . identifier current object (defined

php - how to get field values from database in template page Advanced Custom Fields - wordpress -

Image
i have installed advanced custom fields plugin upload audio , image files in post. each post contains 5 fields new post custom fields i can able publish post, dont know how retrieve each field in wordpress template page post fields just call function name of field in template file <?php while ( have_posts() ): the_post(); // display post if ( have_posts() ):?> <?php echo the_field('slider_name');?> <?php echo the_field('slider_description'); endif; endwhile; ?>

Possible to render and raise exception in Rails controller? -

i have been fighting hours now. have controller action want render page , raise exception automatically. couldn't find information on makes me think looking wrong thing. is below possible? class userscontroller < actioncontroller::base def new # .. stuff begin usermailer::send_confirmation_link(@user) rescue standarderror => e render 'email_error' raise(e) end # .. other stuff end end in case want inform end-user of error , raise exception on application itself. notice can't change de-facto error page since smaller application in same codebase bigger application. no, either render or raise exception, not both. rails provide both static 500.html page in public what's rendered default exceptions, can customize message users see exceptions there. also there's rescue_from method can use customize response specific exception class, , that's way have central spot (usually in applicationcon

sails.js - Sails - Overriding default routes in routes.js -

wondering why not working // routes.js 'get /user/me' : { controller : 'user', action : 'me' }, 'get /user/:id' : { controller : 'user', action : 'findone' } // usercontroller.js module.exports = { me: function(req, res, next) { // code here }, findone: function(req, res, next) { // code here }; } http call "/user/me" never hits usercontroller.me usercontroller.findone . update problem api restprefix defined in blueprints.js restprefix: '/api', so routes should be 'get /api/user/me': { controller: 'user', action: 'me' }, 'get /api/user/:id': { controller: 'user', action: 'findone' }

python - Writing and reading .mat using scipy.io changes dictionary contents -

this question has answer here: python matlab: exporting list of strings using scipy.io 2 answers i trying write dictionary .mat file using scipy.io.savemat(), when do, contents change! here array wish assign dictionary key "genes": vectorizeddf.index.values.astype(np.str_) which prints array(['44m2.3', 'a0a087wsv2', 'a0a087wt57', ..., 'tert-rmrp_human', 'tert-terc_human', 'wisp3 varinat'], dtype='<u44') then genedict = {"genes": vectorizeddf.index.values.astype(np.str_), "x": vectorizeddf.values, "id": vectorizeddf.columns.values.astype(np.str_)} import scipy.io sio sio.savemat("goa_human.mat", genedict) but when load dictionary using goadict = sio.loadmat("goa_human.mat") my strings padded spaces!

arrays - C++ Checking if a double is within .1 of another double (+/-) -

i'm running bit of code need compare 2 2d arrays variance. i've tried using following line of code check , compare values, test fails every time = if(arr1[a][b] != arr2[a][b] || arr1[a][b] + .1 != arr2[a][b] || arr1[a][b] - .1 != arr2[a][b]) { . i know failing because of || statement, because 1 of requirements met. i've got find way determine if double stored in specific location in array matches other array in parallel location. here's full code: int numberoffailedcompares = 0; for(int = 0; < 20; a++) { int b = 0; while(b < 20) { if(arr1[a][b] != arr2[a][b] || arr1[a][b] + .1 != arr2[a][b] || arr1[a][b] - .1 != arr2[a][b]) { numberoffailedcompares++; cout << numberoffailedcompares << endl; } b++; } } is there statement in c++ allow me check if value within +/- .1 threshold? if(arrlocation1 (+/- .1) == arrlocation1) { ... } "variance" means "within x&q

python - what's wrong with my ball/bat collision and reflection? -

i have written breakout style game, , works apart ball bat collision , reflection. supposed work if ball moving left right hits bat: if hits left end bounces in direction came if hits right end bounces in same direction and vice versa right left direction. and: if hits middle area bounces @ same angle if hits centre left/right areas bounces slight change in angle. it goes through bat when on , should rebounding, confusing, think might due `bh == bat.y line, ball moving @ angle , might go on , carry on. code: (baw/h = bat width/height, bw/h = ball width/height) # check bat if theball.y+bh == thebat.y , (theball.x >= thebat.x-5 , theball.x <= thebat.x+batw): # collision in centre - rebounds angle reflection == angle incidence if theball.cx>= thebat.x+40 , theball.cx<=thebat.x+60: theball.dy = -theball.dy return # else find ball direction, areas each direction if theball.oldx < theball.x: # ball moving left right, find area

SOA Web Services Maturity Models -

i quite familiar development of soa web service several languages, time need develop 1 in maturity model 3. have done long search thorugh google have found (summerized): it 3rd step of 5, either focuses create in-organization improvements or providing information external organizations. is it? service targets communication , information sharing external parties, is maturity standard 3b compatible now? if knows soa maturity levels, veeery helpdul. thanks

r - Sparktables: How can I output addition table elements? -

i have data frame (counts of faults in ms office on number of years) using generate sparktable successfully: df_office_final_sparktable component faults time excel 2 2001 excel 1 2002 excel 5 2003 excel 5 2004 excel 5 2005 excel 6 2006 excel 0 2007 excel 0 2008 excel 0 2009 excel 0 2010 excel 0 2011 excel 0 2012 ppt 1 2001 ppt 1 2002 ppt 1 2003 ppt 1 2004 ppt 2 2005 ppt 3 2006 ppt 0 2007 ppt 0 2008 ppt 0 2009 ppt 0 2010 ppt 0 2011 ppt 0 2012 word 5 2001 word 4 2002 word 3 2003 word 1 2004 word 3 2005 word 2 2006 word 5 2007 word 3 2008 word 0 2009 word 1 2010 word 0

sql server - ssms connection timeout expired pre-login handshake error -

i unable connect sql server using ssms 2014/2012. able connect using dbvisualizer. getting below error: connecton timeout expired. tmeout period elapsed while attempting consume pre-login handshake acknowledgement. because pre-login handshake failed or server unable respond in tme. duraton spent while attempting connect server vvas - [pre-login] initializaton=18096; handshake=14271; (microsoft sql server) i have tried below solutions, still no luck: telnet serverip 1433 - works fine computer connection sql server works sometimes - try this, installed sqlserveradvancedservices , then, each listed ip address, set active , enabled yes. when install ssms, these options don't show up. what else can try here working? in advance.

morelikethis - Search around a specific substring elasticsearch -

i'm using "more this" query search similar texts, built templates, making of text useless query, how tell elasticsearch focus on 50-100 terms around substring "subject :", "title :" if appear in field on i'm performing "more this" query ?

ios - upgrading ipad mini device A1455 model -

i have ipad mini devices ios 6 , ios 7. need upgrade them ios 8. apple software update directly upgrades ios 9.2.1. how upgrade ios 8? you can download requred ipsw http://www.iphonehacks.com/download-iphone-ios-firmware or http://www.ipswdownloader.com/ and can install using itunes for mac: option + click on “update” button windows: shift + click on ‘update’ button i'm not sure weather apple allow or not. had done once. don't forget take backup. cheers..

php - Codeigniter 3 consecutive transactions not working -

some context first. have controller manage sites. sites can participate study. when site participates study, empty survey object created. participation has link survey. simplified version of controller code: $survey = new survey(); //set variables $savedsurvey = $this->surveymodel->persist($survey); if ($savedsurvey) $participation->survey_id = $savedsurvey->id; $savedparticipation = $this->participationmodel->persist($participation); the persist function straightforward , looks same models. $sql = "insert table (a, b, c) values (?, ?, ?)"; $params = array($object->a, $object->b, $object->c); $this->db->trans_start(); $this->db->query($sql, $params); $object->id = $this->db->insert_id(); $this->db->trans_complete(); if ($this->db->trans_status() === false) { error_log('survey insert ko'); return false; } else { error_log('survey insert ok'); return $object; } t

sorting - RunTimeError in merge sort function using python -

i trying write merge sort function using python 2 runtimeerror input: unsorted list (ex:[10,9,8,7,6,5,4,3,2,1]) output: [1,2,3,4,5,6,7,8,9,10] my code shown below: lst = [10,9,8,7,6,5,4,3,2,1] def mergesort(array): if len(array) == 1: return array left = [] right = [] in array: if <= len(array)/2: left.append(i) else: right.append(i) left = mergesort(left) right = mergesort(right) return merge(left,right) def merge(left,right): sortedlist= [] while left , right: if left[0]>right[0]: sortedlist.append(right[0]) right.pop(0) else: sortedlist.append(left[0]) left.pop(0) while left: sortedlist.append(left[0]) left.pop(0) while right: sortedlist.append(right[0]) right.pop(0) return sortedlist print mergesort(lst) the runtimeerror is: maximum recursion depth exceeded . know cause of error? you're comparing

Achieve same random numbers in numpy as matlab -

Image
i want know how generate same random (normal distribution) numbers in numpy in matlab. as example when in matlab randstream.setglobalstream(randstream('mt19937ar','seed',1)); rand ans = 0.417022004702574 now can reproduce numpy: import numpy np np.random.seed(1) np.random.rand() 0.417022004702574 which nice, when normal distribution different numbers. randstream.setglobalstream(randstream('mt19937ar','seed',1)); randn ans = -0.649013765191241 and numpy import numpy np np.random.seed(1) np.random.randn() 1.6243453636632417 both functions in documentation draw standard normal distribution, yet give me different results. idea how can adjust python/numpy same numbers matlab. because marked duplicate: normal distribution, wrote in beginning , end. wrote uniform distribution works fine, normal distribution. none of answers in linked thread normal distribution. my guess matlab , numpy may use different methods normal dis

css - Absolute positioned div at the top of overflow scroll-y div hiding -

Image
i have absolutely positioned div @ top of scrolling div. content of absolutely positioned div partially hidden, due scroll. is there away around this? z-index doesn't work it, , padding-top can't used. this image shows top of container, scroll section, , padding added show content box that's being hidden. .hidden-container{ position: absolute; display: block; top: -111px; left: 182px; z-index: 100; }

android - Fragment flashes when removing -

if remove fragment after setting it's view visibility view.gone/ view.invisible removal of fragment causes view flash again before removing. how can avoid this fragment.getview().setvisibility(view.invisible); afterwards: ft.remove(fragment); ft.commitallowingstateloss(); i not using hide because animation myself , @ onanimationend commit remove. then view of fragment flashes , removed. i did setting height 0 , invisible instead of view.gone: fragment.getview().setvisibility(view.invisible); viewgroup.layoutparams params = fragment.getview().getlayoutparams(); params.height = 0; fragment.getview().setlayoutparams(params);

serialization - Example to save and load a sub graph in TensorFlow? -

i created model within variable/name scope , store graph definition , variables disk later load without defining graph again. how can save , load operations , variables within given variable/name scope? conveniently, use tf.saver . save() has option store meta graph restore() not seem import it. moreover, in saver constructor, can specify list of parameters, not name scope control operations saved. there tf.train.write_graph() couldn't find explanation of , how relates saver class , meta graph.

swift - Adding optional tuple to the array -

i have function returning optional tuple (range<string.index>?, range<string.index>?). then, need add tuple array of tuples declares as var arrayoftuples = [(range<string.index>, range<string.index>)]() i adding tuple array this arrayoftuples += [mytuple] it gives me note operator += cannot applied operands [(range<string.index>, range<string.index>)] and [(range<string.index>?, range<string.index>?)] when make declaration of array optional var arrayoftuples = [(range<string.index>?, range<string.index>?)]() there no more complains. but, @ end, need use startindex , endindex tuples array, , when try let myrange = arrayoftuples.first!.0.startindex..< arrayoftuples.first!.0.endindex i have complain value of type range<string.index>? has no member startindex. as can understand, if want startindex , endindex tuples, need use array without optionals, var arrayoftuples = [(range&l

Javascript function not fired on video timeupdate -

currently working on page containing video has paused @ points (like chapters). made function stop video when hits next "time marker" looks this: function vidpause(nextmarker){ var timemarker = nextmarker; if(videoplayer.currenttime >= timemarker) { videoplayer.pause(); videoplayer.removeeventlistener('timeupdate', vidpause()); } }; and i'm trying fire way: videoplayer.addeventlistener('timeupdate', vidpause(nextmarker)); but seems fire when video loaded. nothing happens when video playing (tested using console.log(videoplayer.currenttime); inside vidpause function). note: need function called way can remove event listener when hits time marker, way won't stop when user wants play video point on. thanks in advance suggestions! the function being called once in addeventlistener line, that's not passing callback. try this: function videoupdate(e) { vidpause(nextmarker, video

enums - Change scala Enumeration id -

i want create enum type value can changed. consider following: object type extends enumeration { var = value(0, "some string1") val b = value(1, "some string2") val c = value(2, "some string3") } i gave every enum field value want have option change value . , reading values table enum same value option. possible ? in common parlance, enum not mutable. elements enumerated @ compile time, typesafe constants. also, enumeration relatively fragile. scala> object x extends enumeration { var x = value(0, "a") ; def f() = x = value(1, "b") } defined object x scala> x.x res1: x.value = scala> x.f() scala> x.x res3: x.value = b scala> x.values res4: x.valueset = x.valueset(a, b)

wpf - Style embedded ControlTemplate using Style -

im using infragistics controls theming. template property set on trigger. that template configured further hierarchy cannot edit directly want change 1 of properties set. e.g. template set on trigger (truncated) <style x:key="fxtpanetabitemstyle" targettype="{x:type igdock:panetabitem}"> <setter property="textblock.texttrimming" value="characterellipsis" /> <style.triggers> <trigger property="igdock:xamdockmanager.panelocation" value="unpinned"> <setter property="template" value="{dynamicresource {x:static igdock:panetabitem.dockabletabitemtemplatekey}}" /> </trigger> </style.triggers> </style> the template configured in unreachable code (truncated) <controltemplate x:key="{x:static igdock:panetabitem.dockabletabitemtemplatekey}" targettype="{x:type igdock:panetabitem}"> <border x:name=&

WPF Tooltip binding and open programatically does not work -

i have custom tooltip icon has content bound datacontext. need open tooltop on mouse hover on click event. used following code <image source="/mainui;component\images\home\tooltip_info.png" width="24" height="24" stretch="fill" horizontalalignment="right" name="imagetooltip" margin="0,0,0,0" mouseup="imagetooltip_mouseup" mouseleave="imagetooltip_mouseleave"> <image.tooltip> <tooltip borderbrush="transparent" background="transparent" horizontaloffset="-142"> <textblock textwrapping="wrapwithoverflow" style="{staticresource excalfont-msfd300}" fontsize="14" text="{binding tips}" width="300" padding="15,15,15,15"> <textblock.background>