Posts

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...