Posts

Showing posts from September, 2015

scala - Reverse inheritance -

for custom dsl, have set of data producers , consumers. (it's little more complicated that, suffice set problem.) users set consumer, may require type of data. make sure type system enforces correct type of data sent correct consumer. the possible elaborations of data bounded inasmuch possible write single data producer can @ least fill in sensible default values. thus, there should lower bound data types consists of supplier of default data. also, data shares characteristics, there should upper bound. , data can manipulated in ways preserve suitability given consumer, or widen suitability more consumers. thus, types should like alldata <: d <: anydata what (or most) compact , elegant way encode constraint in scala, assuming not want require alldata extend every other data type d ? right have superclass looks like class anydata { def foo: int => string = defaultinttostringimpl def mapfoo(oo: string => string) = alldata((foo _) andthen oo) } a...

html - Linking to javascript opens code instead of actual program -

this might simple question many of appreciated <li><a href="rpsgame.js" onclick="myjsfunc();">rpsgame</a></li> i trying link tab cool simple game made on javascript, opening in code instead of actual program my program name rpsgame.js why happening ? wrong did ? thank much p.s: i'm new here! what need link js file using script tag. here's how it: <script src="rpsgame.js" type="text/javascript"></script> after that, when user clicks on tab, load using ajax view created above , thats it!

exiftool - How can I write exif data from a json-file into a jpg-image? -

i've created backups of exif information with exiftool -j -w json picture.jpg how can restore exif information image file json-file? thanks ok found it. might interesting others post it: exiftool -json=picture.json picture.jpg this writes exif data picture.json picture.jpg

c# - Separate string array into columns of 32 -

i have string array 96 elements. array formatted 1 string this: str str str str str str str str instead of this: str str str str str str str str but 32 in each column instead of 4. how can this? thanks. if want 32 "rows" , 3 "columns" can use linq query: string[] strings = enumerable.repeat("str", 96).toarray(); ienumerable<string[]> arrays = strings .select((str, index) => new { str, index }) .groupby(x => x.index / 3) .select(g => g.select(x => x.str).toarray()); so each string[] contains 3 strings , sequence contains 32 string[] s.

Add Attribute Jquery data type string + variable -

Image
i have variable called vp_height want put data variable, putting this, prompt error. var vp_height = viewportsize.getheight(); //sample data $(".carol").attr({ "data-" + vp_height : "width:50%;" }); here's error it should in frontend. (visual presentation) <div class="staff-container carol" data-667="width:50%;"></div> any solution stuff? you can use: $(".carol").attr("data-" + vp_height, "width:50%;"); fiddle demo

postgresql - How to run a bat file from a plpgsql function -

is there way run batch file function written in plpgsql ? it's not possible directly pl/pgsql. you can providing helper function in untrusted pl pl/perlu or pl/pythonu in turn runs batch file. in python you'd use like: create function exec_system_cmd (command text) returns return-type $$ import os import sys os.system(command) $$ language plpythonu; or bit more sophisticated , use subprocess module pass array of arguments instead, don't have worry escaping % , > , other special characters in command-string. obviously exec_system_cmd should executable superuser, , if possible, should instead write more specialized function doesn't let user run command like. while possible , doesn't make idea. agree erwin it's better have outside helper program using listen , notify run commands when required.

postgresql - Syntax error at or near ; -

i have many trigger functions, , there strange error: " syntax error @ or near ; " here code: create or replace function zajisti_vyplnenost() returns trigger $$ begin if new.typ_vztahu != 1 return new; end if; if new.nad.typ_sj = 1 if new.nad.vrstva.vypln = true else raise exception 'totožné stratigrafické jednotky musejí být stejného typu!'; end if; return new; end; $$ language plpgsql; create trigger zajisti_vyplnenost before insert or update on s_vztah each row execute procedure zajisti_vyplnenost(); according debugger, error should on line 14 (with end; ). tried find might cause problem, function looks others don't trigger errors. looked on documentation function , end syntax in plpgsql, no joy, , semicolon makes error quite google unfriendly. so part of syntax wrong, , how correct it? looks forgot 1 end if : if new.nad.typ_sj = 1 if new.nad.vrstva.vypln = true else raise exception 'totožné stra...

java ee - Apache Shiro Token based security for Rest service -

i'm creating app using shiro security framework. app have 2 parts; web , rest. the web using shiro's default formauthenticationfilter . i'm happy session based approach. the stand alone app using rest, want limit using formauthenticationfilter , creating session, i'm able via shiro.ini file i need implement token based security on rest service or of sort. browsing on web saw blogs suggesting create own realm , filter handle scenario. no details on how this. is possible implement token based security on apache shiro? if there blog or tutorial shows how achieve this? regards you use basic auth webservice endpoints , form based authentication web. do web users have access webservice? edit: checkout sample app. https://github.com/dominicfarr/skybird-shiro it has 3 url paths configured in shiro. web - uses form authentication. api - uses basic authentication. jersey - anonymous access. cutting shiro.ini config. [main] authc.loginur...

How to write C program for 8259 controller -

i working on interrupts. have understand how use 8259 pic. can guide me how write program in c it. (i worked on 8051) suppose can used 8051. this set of definitions common rest of section. outb(), inb() , io_wait() functions, see page. #define pic1 0x20 /* io base address master pic */ #define pic2 0xa0 /* io base address slave pic */ #define pic1_command pic1 #define pic1_data (pic1+1) #define pic2_command pic2 #define pic2_data (pic2+1) perhaps common command issued pic chips end of interrupt (eoi) command (code 0x20). issued pic chips @ end of irq-based interrupt routine. if irq came master pic, sufficient issue command master pic; if irq came slave pic, necessary issue command both pic chips. #define pic_eoi 0x20 /* end-of-interrupt command code */ void pic_sendeoi(unsigned char irq) { if(irq >= 8) outb(pic2_command,pic_eoi); outb(pic1_command,pic_eoi); } when enter protected mode (or before ...

can you help me in this (C lang)? -

write program takes 2 command-line arguments. first string; second name of file. program should search file, printing lines containing string. because task line oriented rather character oriented, use fgets() instead of getc(). use standard c library function strstr() search each line string. assume no lines longer 255 characters. /* @aduaitpokhriyal */ #include <stdio.h> int main(int argc, char *argv[]) { char command[100]; /* hope large enough! */ sprintf(command, "grep %s %s", argv[1], argv[2]); /* hope arguments there , valid! */ system(command); /* surely "grep" must use strstr() somewhere */ return 0; }

iphone - _itemFailedToPlayToEnd issue in iOS 7 while playing the recorded video using MPMoviePlayerController -

i trying make app record video , play video. video playing nicely times gives error. using mpmovieplayercontroller class _itemfailedtoplaytoend: { kind = 1; new = 2; old = 0; }" please friends. should solve problem? please check url play video. when url wrong error occur.

ssh - How can I use ansible playbook to reboot a ubuntu server? -

i trying build ansible playbook configure ubuntu vagrant box. playbook pretty working exception of controlling ubuntu box reboot after upgrading kernel. i have host file ansible follow : localhost ansible_connection=local dockerhost ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1 the latest iteration tried solve problem follow : - name: restart server shell: sleep 2s && reboot & executable=/bin/bash - name: wait until virtual machine stop ie: ssh port stop responding local_action: wait_for host={{ansible_ssh_host}} port={{ansible_ssh_port}} state=stopped sudo: false - name: wait server come local_action: wait_for host={{ansible_ssh_host}} port={{ansible_ssh_port}} delay=30 sudo: false with playbook steps process block waiting ssh port stop responding, until reach timeout , exit playbook, guessing if reboot particularly fast might happen in between polling intervals of wait_for command , miss short time when ssh port down. error ret...

Custom event in JavaScript like onReadyEvent() -

i need similar functionality own events, such hangout api (and many other apis). for example, there event: onapiready, invoked when api initialized. i found great tutorial -> http://www.nczonline.net/blog/2010/03/09/custom-events-in-javascript/ not know how let create , recall of events spinning each object. regards. javascript solution you have paste following code before script file: function eventtarget(){ this._listeners = {}; } eventtarget.prototype = { constructor: eventtarget, addlistener: function(type, listener){ if (typeof this._listeners[type] == "undefined"){ this._listeners[type] = []; } this._listeners[type].push(listener); }, fire: function(event){ if (typeof event == "string"){ event = { type: event }; } if (!event.target){ event.target = this; } if (!event.type){ //falsy throw new error...

c# - Structuremap ObjectFactory.GetAllInstances inserts null value into list -

i have simple list instantiating structuremaps objectfactory.getallinstances(). private list<userreleasetime> _userreleasetimes = objectfactory.getallinstances<userreleasetime>().tolist() userreleasetime looks this: public class userreleasetime { public string name { get; set; } public double totalreleasetime { get; set; } public double withinreleasehours { get; set; } public double outsidereleasehours { get; set; } } after collection created appears structuremap adds 1 object empty or null values. there anyway stop happening? update: userreleasetime registered structuremap this: for<userreleasetime>().use<userreleasetime>();

I want to delete a user from a list that ID's and rows change dynamically using Selenium in C# -

i in web page names , have users name test user99. want use selenium webdriver/c# command find user , click delete button next him. there id's generated dynamically , user , button have different id's , cells. row different each time. sounds use xpath find user name , walk dom delete button, without html, cannot provide concrete answer

create cron in android app -

i have problem, need make method run every often, problem methods need activity start , not know how need give activity. try create service , work timer problem radico that. leave methods see. public void push(activity activity,string codigoevento){ sessionmanager manager = new sessionmanager(); folioevento = manager.getvalue(activity,"folioevento"); nombrecliente = manager.getvalue(activity,"nombrecliente"); if(!(folioevento.equals("") || nombrecliente.equals(""))){ connectioninternet cn = new connectioninternet(); if(cn.isnetworkavailable(activity)){ string ids = ""; bdtickets = new ticketsbasedatos(activity, "eventrid", null, 1); sqlitedatabase db = bdtickets.getwritabledatabase(); cursor c = db.rawquery("select inscripcion_id inscripcion validado=1 , sincronizado = 1 , codigo_usuario =si-1",null); if (c.movetofirst()) { { ...

node.js - AWS S3 Android sdk added files not visible -

i have uploaded files s3 bucket via android sdk. able process them on nodejs server using both stream , signed url. they not visible when sign s3 though. thought maybe because adding keys folder eg. 'myfolder/myfilename.txt', wasn't issue. so can process them fine need able access them main s3 console on aws. i have user set these permissions: { "statement": [ { "effect": "allow", "action": "s3:listallmybuckets", "resource": "arn:aws:s3:::*" }, { "effect": "allow", "action": "s3:*", "resource": [ "arn:aws:s3:::folder", "arn:aws:s3:::folder/*" ] } ] } any appreciated. are setting access control list? can use canned...

android - How am I going to create a xml file using pullparser for hashmap -

i trying populate xml file user's input values. user give 2 entries key , value. , have model class below: public class person { private hashmap<string, string> hash = new hashmap<string, string>(); public person() { } public person(string key, string val) { hash.put(key, val); } public string getfirstname(string k) { return hash.get(k); } } how make xml object of class? , how retrieve value xml against key? and want xml this: <allentries> <entry key="key1">value1</entry> <entry key="key2">value2</entry> <entry key="key3">value3</entry> </allentries> you need use xml parser java dom or sax . example below java dom , shows how loop through hashmap , add entries your_xml.xml . file xmlfile = new file("your_xml.xml"); documentbuilderfactory dbfactory = documentbuilderfactory.newinstance(); documentbuilder dbuilder = dbfactory.newdocumen...

parsing - How to work with and how to parse a text file with mixed content in Java -

i need advice on how go processing text file in java. have file, have lines on top data, , table. example, in beginning of file have totals like: cars purchased = 1890 cars returned = 130 then there table, contains car ids: id#1 =127974 id#2 =212445 and table: table begin: customer id | price paid | car brand#1 | car brand#2 | car brand#4 id#1 id#2 i have print out cars purchased value, cars returned value, array car ids and create tabular set based on last table. can please explain me logic on how go in java? i not asking code, guidelines/steps/pseudocode . can't understand how can separate text file 3 chunks , have input reader concentrate on 1 of 3 @ time. example, car ids can similar client ids in table, can 1 not let input reader read unnecessary information? another thing - if read file, parts of tab-separated , other parts not , how figure out begin reading tab-separated part only? if beginning of file has cars purchased = 1890 , have return 1...

java - Get Json with i.e 200 objects, but only 100 displayd on one site -

i'm working in twitch irc bot , got problem. we receive alot of information through twitch api (json) followed, dateof .. viewercounts.. amount of followers , stuff that. were making follow-function read names out of whole list , set our database. first off tried read , system.output them error: org.json.jsonexception: jsonarray[100] not found. we noticed "0" holding array set loop 0-99 , should change link adding 100+ (next site) , read json again. should continue loop next site. below main code read-methods. we tried debugging wasn't able find solution yet x( mybot main code snippet: jsonobject follower = null; string followername = null; int listnumber; offsetvalue = 0; for(int = 0; < twitchstatus.totalfollows; i++) { try { follower = twitchstatus.followerarray.getjsonobject(i); } catch (jsonexception e2) { e2.printstacktrace(); } try { followername = follower.getjsonobject("user...

javascript - Find whether a child node has a particular class using jQuery -

i have table row: <tr> <td class>1</td> <td class="check">2</td> <td class>3</td> </tr> i have variable x access above code, x.parentelement . how can find out column <td> tag (the first, second or third) contains class check ? it seems me it's just: $(x.parentelement).find('.check').text(); assuming x.parentelement dom element. here, find first child of dom element has "check" class , return text data.

php - Simple contact form HTML with Captcha? -

i looking simple html contact form has recaptcha or type of anti-spam features. tried multiple tutorials complicated , can't work. need name, email, , message field (and recaptcha , submit button). know can find simple contact form html? if have been struggling implement recaptcha go $a=rand(2,9); // number between 2 , 9 $b=rand(2,9); // number between 2 , 9. can change according wish $c=$a+$b; on php page show echo $a."+".$b."="<input type="text" name="recaptcha" /> and check whether textbox value equal $c. this simple recaptcha sort of thing can implement prevent bots.

php - Back slash to get name space -

so, in router.php file create object of runapp class using namespace. work fine. namespace router; // app/routes.php $runapp= new \core\runapp(); in case slash(new \core\runapp()) means need namespace router , try find runapp class in core namespace. but also, can use link in way: namespace router; use core\runapp; // app/routes.php $runapp= new runapp(); but, why in last case not need set \ befor namespace(use core\runapp)?? note namespaced names (fully qualified namespace names containing namespace separator, such foo\bar opposed global names not, such foobar), leading backslash unnecessary , not recommended, import names must qualified, , not processed relative current namespace. from php - using namespaces: aliasing/importing when use use keyword, namespaces not relative, have qualified. whereas, in other cases, it's relative current namespace.

c# - Gap-less sequence where multiple transactions with multiple tables are involved -

i have requirement (by law) gap-less numbers on different tables. ids can have holes in them not sequences. this have either solve in c# code or in database (postgres, ms sql , oracle). this problem: start transaction 1 start transaction 2 insert row on table "portfolio" in transaction 1 next number in sequence column portfolio_sequence (1) insert row on table "document" in transaction 1 next number in sequence column document_sequence (1) insert row on table "portfolio" in transaction 2 next number in sequence column portfolio_sequence (2) insert row on table "document" in transaction 2 next number in sequence column document_sequence (2) problem occurred in transaction 1 rollback transaction 1 commit transaction 2 problem: gap in sequence both portfolio_sequence , document_sequence . note simplified , there way more tables included in each of transactions. how can deal this? i have seen suggestions "lock...

ios - change color of custom uibarbuttonitem (iOS7) -

i have 5 uibarbuttonitems , change color of 2. how can in xcode 5? thanks lot answering! what have add code in appdelegate.m ? [[uinavigationbar appearance] setbartintcolor:uicolorfromrgb (0x34aadc)]; [[uiapplication sharedapplication] setstatusbarstyle: uistatusbarstylelightcontent]; [[uinavigationbar appearance] settitletextattributes:@{nsforegroundcolorattributename : [uicolor whitecolor]}]; [[uibarbuttonitem appearance] settintcolor:[uicolor whitecolor]]; [[uinavigationbar appearance] settintcolor:[uicolor whitecolor]]; [[uitoolbar appearance] setbartintcolor:uicolorfromrgb (0x34aadc)]; there method follows: [[uibarbuttonitem appearancewhencontainedin:[<the class in want set custom color> class], nil] settintcolor:<mycolor>];

javascript - Slide asp.net content page -

i have web site has master page , content page. have few menu items listed on master page template. want bring pages based on link click such that, pages loaded sliding animation. also, here want slide content page.. not whole page. appreciated greatly. thanks you can in following ways in menu click can call ajax page content , show div in animated way. or put all page content in 1 page , hide non active contents, show contends according menu click (you can refer jquery tab )

java - Tomcat not picking the showing 404 on index.html -

i new servelests , building web application. when create new html file in myproejct under web pages folder in netbeans , compilling file shows 404 error following url http://localhost:8080/myproject/ but when change url http://localhost:8080/myproject/index.html it shows page.. and when creating index.jsp instead of index.html , compile in netbeans shown in browser why happen ????? hint ?? is index.html under web-inf or webcontent ? it should under webcontent folder , map in web.xml.

java - android button continuously generate strings -

when press button prints 1 of strings @ random, can once have restart app , press again print new one. have able continuously press button , continuously print strings @ random? public string converse = randomstarter(); public string randomstarter() { random generator = new random(); int rand = generator.nextint(6); string starter = new string(""); switch (rand) { case 0: starter = "what favorite subject in \n school kid? \n worst?"; break; case 1: starter = "my favorite room in house is..."; break; case 2: starter = "if had 1 million dollars, it?"; break; case 3: starter = "did ever have nickname? \n if so, it?"; break; case 4: starter = "if had magical powers would..."; break; case 5: starter = "if invisible day, \nwhat do?"; break; case 6: starter = "5 ...

Sencha Touch 2 pie chart not displaying -

i attempting follow this example creating pie chart. i added simple code create , dock toolbar top of view still using code example linked above. doing made chart not display. blank page. my code pasted below: ext.define('revivaltimes.view.chart', { extend: 'ext.chart.polarchart', xtype: 'chart', requires: [ 'ext.chart.series.pie', 'ext.chart.interactions.rotate' ], config: { title: 'statistics', iconcls: 'settings', layout: 'fit', /**************** toolbar causes second error - disappearing chart **************/ items: [{ docked: 'top', xtype: 'toolbar', title: 'statistics chart', items :[ { a...

multithreading - Multi-threading for downloading NCBI files in Python -

so have taken on task of downloading large collection of files ncbi database. have run times have create multiple databases. code here works downloads viruses ncbi website. question there way speed process of downloading these files. currently runtime of program more 5hours. have looked multi-threading , never work because of these files take more 10seconds download , not know how handle stalling. (new programing) there way of handling urllib2.httperror: http error 502: bad gateway. with combinations of retstart , retmax. crashes program , have restart download different location changingthe 0 in statement. import urllib2 beautifulsoup import beautifulsoup #this searchquery ncbi. spaces replaced +'s. searchquery = 'viruses[orgn]+not+retroviridae[orgn]' #this database searching. database = 'protein' #this output file data output = 'sample.fasta' #this base url ncbi eutils. base = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/' #create searc...

FTP in C: 331 / 530 Please specify password -

i have issue sending pass command in c, writing simple program connects ftp server , prints out list stdout. /* ----------- set connection ---------*/ //creating socket if((sock=socket(af_inet,sock_stream,0))<0) { perror("main: creating socket:"); return error; } //zero out addr memset(&addr, 0, sizeof(addr)); //getting host name hptr=gethostbyname(url.host); if(hptr==null) { perror("error while getting host name:"); return error; } //setting addr connect addr.sin_addr.s_addr = inet_addr(inet_ntoa(*((struct in_addr *)hptr->h_addr_list[0]))); addr.sin_family = af_inet; addr.sin_port = htons(url.port); if((connect(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr))) < 0) { perror("error: connect socket :"); close(sock); return error; } //wait service ready bzero(buffer, maxbuf); if(recv(sock, buffer, sizeof(buffer),0)<0) { perror("error while receiving socket:"); } printf(...

ruby/rails: push & chat server for android -

why push server? google c2dm not work in regions. how create push server using ruby/rails? well, it's real question. i've been googled few days. options: impp(openfire), juggernaut, faye, androidpn. leads me confusion. requirement simple, light weight push service , light weight text chat. they're small part of project. 1 better? you should @ pusher third-party js-centric push service. think works web socket (which believe android not support), you'll have @ compatibility. i think need. i'll leave details unless want them!

Why are unordered lists used for horizontal menus in HTML and CSS? -

why unordered lists used horizontal menus rather styling <a> tags? have css, , works perfectly: #menu { width: 700px; height: 40px; position: absolute; bottom: 0px; left: 50px; background-color: #00604f; border-radius: 10px 10px 0px 0px; box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5); text-align: center; overflow: hidden; } #menu { height: 20px; margin: 0px 5px; padding: 10px; display: inline-block; background-color: #0c61b4; color: #fff; text-decoration: none; } #menu a:hover, #menu a:active, #menu a.active { background-color: #07396a; } #menu a:active, #menu a.active { box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5) inset; } the html this: <div id="menu"> <a>hello</a> <a>world!</a> </div> the <a> tags can have whatever properties want (such href, onclick, etc.). in reality, can use whatever elements want use. it's site af...

php - Symfony 2 form cascading validation -

i have form in symfony 2 like: $form = $this->createformbuilder(); $form ->add('subscription', 'entity', array( 'class' => 'acmedemobundle:subscription', 'property' => 'name', 'label' => 'subscription', 'cascade_validation' => false, 'constraints' => array( new notblank(), ) )) this failing validation error: subscription: error: value should of type integer. error: value should of type integer. the problem don't want cascade validation subscription entity. want able select entity dropdown. any idea? the reason getting error messages because you're failing type validation on 1 or more properties of child entity. review constraints wherever you've defined them. in c...

iphone - "Implicit Conversion Loses Integer Precision" error -

i have code , following error: implicit conversion loses integer precision size_t bitarray::wordsforbits(size_t bits) { int arraysize = (bits + bitsperword_ - 1) >> logbits_; return arraysize; } how can resolve this?

build - Cross-compiling kernel module for ARM -

i want cross-compile rtl8192cu driver targeting arm angstrom (beagleboard) , on x86 ubuntu 13.04. cross-compile prerequisites: rtl8192cu driver cross-toolchain (codesourcery / arm-angstrom-linux-gnueabi) kernel sources for reason, copied kernel sources usr/src directory of beagleboard, on ubuntu machine (they heve been compiled on beagleboard, needed rebuild kernel) . running make cross-compile, error: make arch=arm cross_compile=/home/demetres/codesourcery/sourcery_codebench_lite_for_arm_gnu_linux/bin/arm-none-linux-gnueabi- -c /home/demetres/desktop/ks1 m=/home/demetres/desktop/rtl3 modules make[1]: entering directory `/home/demetres/desktop/ks1' cc [m] /home/demetres/desktop/rtl3/core/rtw_cmd.o /bin/sh: scripts/basic/fixdep: cannot execute binary file make[2]: *** [/home/demetres/desktop/rtl3/core/rtw_cmd.o] error 126 make[1]: *** [_module_/home/demetres/desktop/rtl3] error 2 make[1]: leaving directory `/home/demetres/desktop/ks1' make: *** [modules]...

Find the mode (most common element) of an array in C++ -

i had on interview question. i'd see how stackoverflow it. what bjarne stroustrop think of way? it's little wordy, don't know how make better, unfortunately. know guys gonna laugh @ stupidity. template <class t> t mode(t* arr, size_t n) // if there's tie, return arbitrary element tied 1st // if array size 0, throw error { if (n == 0) { throw("mode of array of size 0 undefined, bro."); } else if (n == 1) { return arr[0]; } else { std::pair<t, int> highest(arr[0], 1); std::map<t, int> s; s.insert(highest); (t* thisptr(arr + 1), lastptr(arr+n); thisptr != lastptr; ++thisptr) { if (s.count(*thisptr) == 0) { s.insert(std::pair<t, int> (*thisptr, 1); } else { ++s[*thisptr]; if (s[*thisptr] > highest.second) { highest = std::pair<t, int> (*t...

html - CSS background 100% height - How to do? -

Image
in css column, how can make background 100% of height, if content empty? i tried height: 100%; , display: block; , nothing seems working! the background (height) fills till content height. below empty! please check screenshot attached below: css code using follows: .computer-wrapper{ width: 1000px; margin: 0 auto; border: 1px solid #7771a0; border-radius: 5px; min-height: 600px; } .computer-left-column{ width: 200px; float: left; background-color: #7771a0; } .computer-middle-column{ width: 600px; float: left; background-color: green; } .computer-right-column{ width: 200px; float: right; background-color: blue; } in html side, using following: <!-- left column start --> <div class="computer-left-column"> <ul id="treemenu" class="treeview"> <li>scripts <ul> <li><a href="#">asp.net scripts</a...

android - Gradle buildConfigField BuildConfig cannot resolve symbol -

i using gradle build android application. trying use flags based on build type (release or debug). my gradle file looks this: android { buildtypes { debug { buildconfigfield 'boolean', 'preprod', 'true' buildconfigfield 'boolean', 'staging', 'false' } release { buildconfigfield 'boolean', 'preprod', 'false' buildconfigfield 'boolean', 'staging', 'false' } } } and if try call buildconfig.preprod or buildconfig.staging "cannot resolve symbol" error. gradle sync successful, don't know if forgot steps in order able use feature? the generated buildconfig.java file following (in build/source/buildconfig/debug/com.example.myapp ): package com.example.myapp; public final class buildconfig { public static final boolean debug = boolean.parseboolean("true"); public stat...

java - Getting Error While Using Reflection to get Field Data -

i trying fetch field name field value using reflection. i passing dynamic classes per operation needed. i have made method fetch field name , value, getting field name not getting field value. when using following code gives me error java.lang.illegalaccessexception stating can not access private member of class. following updated code : public string serializecommand(icommand command){ stringbuilder command_text = new stringbuilder(); field [] f = command.getclass().getdeclaredfields(); for(field field : f){ field.setaccessible(true); command_text.append(field.getname() + ","); try { system.out.println(field.get(command.getclass())); } catch (illegalaccessexception e) { e.printstacktrace(); } } return command_text.tostring(); } here icommand class name it, suppose if operation add add class passed. any idea solve problem. please try code. public string serializec...

database - Is there any transparent deduplication for large binary data within PostgreSQL? -

we have app stores large binary data large objects within postgresql database , have use case operate on data in such way know parts of saved data saved once again in different combination. going split files , combine them in different ways, want preserve original files additionally new combined ones. this sounds use case consider deduplication. aware of works directly , transparent within postgres, such don't need re-invent wheel? storage layer or plugin add postgres handles deduplication on it's own @ least whole database? or maybe library works wrapper around large object function of postgres our app use , wrapper lib duplication part, maybe adds tables bookkeeping , stuff? we aware of filesystems support deduplication , 1 possibility use backend postgres' data storage. option save new data outside of postgres within deduplicating filesystem. prefer within postgres can dumped , backed transactions etc. thanks hints! no, there not (as of 9.4, anyway). ...

ruby on rails - net::ERR_INCOMPLETE_CHUNKED_ENCODING in Chrome only -

i've been getting error when loading pages: net::err_incomplete_chunked_encoding these pages don't special , seems work in other browsers. pages happens on display data in json. happens when json page has display large amount of items. rails console not displaying errors (200 response). i have met problem yesterday. it's because of server didn't response resources. in page, have large file links like <a href="/file_path">file_name</a> , , happend in chrome. in while ,i recognized maybe caused chrome's 'predict network actions improve page load performance' feature.so turned off feature in chrome://settings , try again. expected, error didn't occur again. after that, changed resource links full_url_path instead of relative_path(in rails, use resource_url instead of resource_path), didn't have turn off chrome's feature. , looks good.

php - REQUEST_URL if statements -

i'm php rookie, have following statement: if(strpos($_server['request_uri'],'/')!=-1) { echo '<span>hello world' .$_server['request_uri']. '</span>'; } else if(strpos($_server['request_uri'],'/blog')!=-1) { echo '<span>blog world' .$_server['request_uri']. '</span>'; } else if(strpos($_server['request_uri'],'/videos')!=-1) { echo '<span>videos world' .$_server['request_uri']. '</span>'; } else if(strpos($_server['request_uri'],'/about')!=-1) { echo '<span>about world' .$_server['request_uri']. '</span>'; } else if(strpos($_server['request_uri'],'/contact')!=-1) { echo '<span>contact world' .$_server['request_uri']. '</span>'; } my issue whenever go elsewhere http://website.com/ still r...

css - Nesting and looping with less incremental -

i not sure how implement in less, not sure start. the purpose increment padding variable(15px in example) depth (increment variable). possible in less? ul { li{ padding-left: 30px; } ul { li{ padding-left: 45px; } ul { li{ padding-left: 60px; } ul { li{ padding-left: 75px; } ul { li{ padding-left: 90px; } } } } } } see loops , e.g.: .make-nested-lists(5); .make-nested-lists(@n, @i: 0) when (@i < @n) { ul li { padding-left: (30px + 15 * @i); .make-nested-lists(@n, (@i + 1)); } }

html - Bootstrap 3.0 Text Disappears on refresh -

i'm trying use bootstrap 3.0 template create website. issue i'm having when refresh page of text disappears. not every time 8/10 times does. here demo have put on website guys check out. http://dwayned.co/jswebsite/ please let me know if have questions or need see code. your html quite messed up. bootstrap structure should this... <div class="container"> <div class="row"> <div class="col-xs-12"> content here </div> </div> </div> in above example i've used 1 col-xs-12 class can use combination of cols here long add 12. see more on bootstrap grid system here in docs: http://getbootstrap.com/css/#grid i notice in code using span12 class bootstrap v2 , not new v3 uses col classes i've outlined in example above.

hibernate - Ejbql query with in in where clause -

i try query : select x compteutilisateur x, mail m m.adresse = :param_mail , m in (x.listemail) i fails, query generated clause : where compteutil0_.id=listemail2_.fk__compte__id , listemail2_.fk__mail__id=mailimpl3_.id , mailimpl1_.adresse=? , ( mailimpl1_.id in ( . ) ) what missing ? possible whant ? :) in using sub query, try member of. select x compteutilisateur x, mail m m.adresse = :param_mail , m member of x.listemail

MATLAB: Plot variance of elements in each bin of histogram? -

data: array of real valued numbers. (say xarray) plot: histogram superimposed plot of variance(/iqr) of elements in each bin. problem: need variance each bin of 'elements in each bin'. (elements numeric.) can done if there way access elements put in each bin , not 'how many element in each bin (count)' i using matlab thanks one solution sort data , divide based on bin width. have access data in each bin perform variance calculation.

mysql - add additional data to duplicate records -

i have code checks how many duplicate codes there are: mysql> select code, count(code) dup tg_user group code having dup>1 order dup; this returns: +------------+-----+ | ccc002 | 5 | | bar003 | 6 | | fir001 | 6 | | njs001 | 6 | | del004 | 6 | | bra009 | 7 | | tsh011 | 11 | | sho005 | 19 | +------------+-----+ 432 rows in set (0.08 sec) the table structure is: mysql> describe tg_user; +---------------+--------------+------+-----+---------+----------------+ | field | type | null | key | default | | +---------------+--------------+------+-----+---------+----------------+ | user_id | int(11) | no | pri | null | auto_increment | | user_name | varchar(30) | yes | uni | null | | | email_address | varchar(255) | yes | uni | null | | | code | varchar(25) | yes | | null | | +---------------+--------------+------...

javascript - Pop image out of div -

how pop image out of div , set width 100% (so takes of screen)? note: don't want use plugins. i have far: <div class="container"> <img src="thumbnail_image.png" /> </div> jquery: $(document).on("click", ".container img", function(event) { /* image name. */ var src = $(this).attr('src').split('/'); var file = src[src.length - 1]; /* load big image container replace thumbnail. */ $(this).attr('src', 'big_images/' + file); }); how this? you can use css position fixed. defining class this: .fullscreen_image { position: fixed; top: 0; left: 0 width: 100%; } you can add , remove class image. $(this).addclass( 'fullscreen_image' );

javascript - Input is not being focused -

i have table in inputs of last column user able type quantity of money. quantity evaluated , if not ok alert() message appears, input val() set $0,00 , same input should focused, seems focus() function not work. the code seems me correct , when debug firebug works others don't. when type on firebug console $("id").focus() works fine. wondering if there's such person in world me problem! $('#table [type=text]').val('$ 0,00').keyup(function () { amf2005_becamecurrency(this, 20); }).blur(function () { if (!validate($(this).val())) { $(this).val('0,00'); $(this).focus(); } amf2005_becamecurrency(this, 20); $(this).val("$ " + this.value); }); this educated guess! in code provided, calling "focus" event inside handler "blur" event. i'm not sure allowed, there simple way see. try replacing $(this).focus() settimeout(function() { $(this).focus(); }, 0) u...

c# - Stored Procedure sql data insert error -

private void btninsert_click(object sender, eventargs e) { empcode = txtcode.text; empname = txtname.text; empcell = txtcell.text; empaddress = txtaddress.text; try { using (cmd = new sqlcommand(" empinsert ", conn)) { cmd.commandtype = commandtype.storedprocedure; cmd.parameters.add("@empcode", sqldbtype.varchar).value = empcode; cmd.parameters.add("@empname", sqldbtype.varchar).value = empname; cmd.parameters.add("@empcell", sqldbtype.varchar).value = empcell; cmd.parameters.add("@empaddress", sqldbtype.varchar).value = empaddress; conn.open(); cmd.executenonquery(); } messagebox.show("succesfully inserted", "congrates"); } catch (exception ex) { messagebox.sho...

jquery - Rails 4 headaches with loading/preloading JavaScript games in specific pages -

i'm hosting games relying on html/css/js on rails server. these games displayed in own specific view. vardarac.us while asset pipeline loads game code no matter visit in server (which i'm fine with), games supposed display in specific div in specific view. resources, sounds , images delivered cdn, preloaded once page containing div visited. <div id="game-goes-here"></div> my current implementation uses preloading scripts each game. these each contain event listener attached $(document).on("page:change", somepreloadingfunction) , along window.page variable, try , ensure game code interacts user when specific div on page. scheme this. in view containing game: <%= javascript_tag %> window.page = "<%= @game && @game.name %>" <% end %> the preloading/ui-setting script: var ready = function() { if(window.page == "specific_game_name") { game.gamecontainer = $("#game-goes-her...

javascript - How to do knex.js migrations? -

i'm still not sure how migrations knex. here have far. works on up , down gives me fk constraint error though foreign_key_checks = 0. exports.up = function(knex, promise) { return promise.all([ knex.raw('set foreign_key_checks = 0;'), /* create member table */ knex.schema.createtable('member', function (table) { table.bigincrements('id').primary().unsigned(); table.string('email',50); table.string('password'); /* create fks */ table.biginteger('referralid').unsigned().index(); table.biginteger('addressid').unsigned().index().intable('address').references('id'); }), /* create address table */ knex.schema.createtable('address', function (table) { table.bigincrements('id').primary().unsigned(); table.index(['city','state','zip']); table.string('city',50).notnullable(); ta...

c# - How to count only elements displayed on WebPage. Selenium -

i have web page 2 tabs. when count of elements on 1 tab gives me count both tabs not on 1 have clicked on. so if want check element present of tab1 , not on tab2 not able getting same results on both tabs. if (driver.findelements(by.xpath("//div[contains(text(), 'dummy text')]")).count != 0) { // failed test message ; } on tab1 expecting count should 0 text not displayed , on tab2 count should 8 on both tabs count 8. how can count of elements displayed on page , not in background? i sure because of tabs on web page , selenium considering both tabs same web page content. selenium return objects in dom not visible user. i not believe there xpath or css selector allows select visible elements. can think of potential nasty xpath ensure no parent had display:none not know if work , sounds horrible , complex contemplate. you need iterate through each returned element , check "displayed" returns false. tempted extend driver class ...

Javascript alternative of jquery load() -

can please give me example of pure javascript alternative jquery load() ? or point me rite site example. thank you update: this not meant ask. need use ajax load url , insert returned html 'div' i don't quite negative points. @ least care explain wrong question? search on , not find example. in order make ajax requests using pure javascript, need this: httprequest = new xmlhttprequest(); // specify function handle response. httprequest.onreadystatechange = function() { // process ajax response in here. } // make ajax request httprequest.open('get', 'http://prajjwal.com/profile.json', true); the first parameter open type of request want make. make 'get' request in case. second argument url of item you're trying retrieve. third argument boolean decides whether request should asynchronous or not. if request async, function not halt & wait request finish. it worth noting won't work in internet explorer 8 or b...

c++ - How do I force a specific instantiation of a templated function without repeating its signature? -

i need instantiate templated function foo() long signature, specific template arguments. i read answers this question suggest copying function signature setting specific arguments. want avoid somehow. reasonable way achieve this? e.g. allow me write instantiate(foo, template_arg1, template_arg2); or maybe myfunctiontype<template_arg1, template_arg2> foo; just illustrative purposes, suppose code foo : template<typename t, int val> unsigned foo( t bar, sometype baz1, someothertype baz2, yetanothertype you_catch_the_drift) { /* code here */ } in explicit instantiations of function templates it's possible omit template parameter list after template-id if arguments can deduced: template<typename t> void foo(t) {} template void foo(int); // explicit instantiation // ^ no template parameter list here not in case, though, since val parameter needs passed explicitly. how explicit instantiation like: tem...

actionscript 3 - Flash Player Settings Panel not showing Privacy or Local Storage tabs on Safari for Mac -

i'm making small flash application website. works apart 1 small thing, have implemented way bring flash settings menu user specified tab. this works expected in cases apart in safari on mac, local storage , privacy tabs missing. bit of problem privacy tab important 1 in system. this happens when swf hosted on subdomain (for example swf hosted on bs5.somewebsite.com , embedded on somewebsite.com) , i'd write off apple security quirk make matters bit more frustrating swf files other sources (which not have source code for, jwplayer example) can access tabs in settings window on safari mac , when hosted on subdomain. i'm authoring in flashdevelop. this happens when trying view swf through iframe. safari has "feature" disables functionality sites loaded in iframes try , prevent 3rd parties tracking you. a simple test directly view page in iframe , see if local storage , privacy tabs appear.

c# - Entity loaded twice in same Context, InvalidOperationException -

i have db-first entity framework application , following associations: customer * <-> 1 country machine * <-> 1 customer everything fine until now. here problem: have class condition associated machine customer: condition * <-> 1 customer condition * <-> 1 machine in 1 special entity condition.machine.customer.country same entity condition.customer.country , invalidoperationexception message an object same key exists in objectstatemanager this exception appears when call db.entry(condition).state = entitystate.modified; also country entites unchanged exception. how can store condition entity? if working in disconnected context can't rely on ef trackchanges mechanism, , graph relationships context saving in has no way of knowing whether child new/updated/no-change. when come save changes error you're seeing because child entity exists , ef attempting add again. julie lerman has method involves managing own mod...

javascript - Caculating function running time -

i want calculate average running time of function in javascript this: time = 0; while(1000) { time1 = performance.now(); function(); time2 = performance.now(); time += (time2-time1); } the problem first loop time interval 60ms , following loop interval zero. changed code to: time1 = performance.now(); while(1000000) { function(); } time2 = performance.now(); time = (time2-time1); the running time 4 seconds . i guess maybe because of automatic optimisation. if case, there approaches close optimisation? you've caused browser hand off code jit compiler. first run through interpreter (slow). hot code gets put through jit , resulting native (fast) code used. this automatic , out of hands control. can disable firefox jit compiler using 'with' in script. with({}) {} add top of script , jit disabled script.

ios - Using NSOutputStream outputStreamWithURL with a custom URLprotocol -

i'm writing custom url protocol (subclass of nsurlprotocol) deal local files need special way of reading , writing. no problem when reading: can create url -for example- "my-funny-file-protocol://...." , things work fine. the problem arises when try write kind of url's. in particular, need use nsoutputstream, need call like: nsstring *urlstring = [nsstring stringwithformat:@"my-funny-file-protocol://%@", path]; nsurl *url = [nsurl urlwithstring:urlstring]; nsoutputstream *writer = [nsoutputstream outputstreamwithurl:url append:no]; no exception raises, no logs on console result nil . same file works, if use standard file: protocol: nsstring *urlstring = [nsstring stringwithformat:@"file://%@", path]; why? in fact nsurlprotocol documentation not explain case. perhaps i'm missing someting in urlprotocol implementation... what? many in advance, rob