Posts

Showing posts from May, 2012

React-router <Link> has no active class -

i <link> s have active class when match route. resulting <a> tag doesn't change, when i'm on route referenced link. my links created this: <link to="/status">status</link> the routes: <router> <route path='/' component={app}> <indexroute component={status} /> <route path='about' component={about}/> <route path='status' component={status}/> <route path='settings' component={settings}/> </route> </router> does feature exist? if so, need change work. ps: i'm using react-router redux-router. use default hashhistory because it's nwjs -app use activeclassname property specify class add when link active. <link to="/status" activeclassname="active">status</link>

c# - Crosswords schema recognize using photo grabbed by camera -

Image
i create software provided crossword puzzles image, give me following information: - number of rows , columns - position of black boxes i made ​​this guy sudoku: http://sudokugrab.blogspot.it/2009/07/how-does-it-all-work.html i use similar system obtain schema of crossword puzzle photo grabbed camera phone. is possible such application? start search. algorithm need use? this crossword puzzle use: http://i.stack.imgur.com/xl815.gif update: the image source have use this: update: hi guys, after many tries able find black fields applying filters: grayscale adaptive thresholding (bradley local threshold) invert blob counter this result image: now, how find white fields? suggestion? help!!

multithreading - C# Threading without locking Producer or Consumer -

tldr; version of main questions: while working threads, safe read list's contents 1 thread, while write it, long not delete list contents (reoganize order) , reads new object after new object added fully while int being updated "old value" "new value" 1 thread, there risk, if thread reads int value returned neither "old value" or "new value" is possible thread "skip" critical region if busy, instead of going sleep , wait regions release? i have 2 pieces of code running in seperate threads , want have 1 act producer other. not want either thread "sleeping" while waiting access, instead skip forward in internal code if other thread accessing this. my original plan share data via approach (and once counter got high enough switch secondary list avoid overflows). pseudo code of flow original intended it. producer { int counterproducer; bufferedobject newlyproducedobject; list <buffered_object> objectsp

string - When writing junit test cases, which one of the following is best to use for empty list? -

when writing junit test cases, 1 of following best use empty list ? list<string> list = new arraylist<string>(); or collections.<string> emptylist(); ? whenever possible prefer collections.emptylist() on arraylist , because ensures main code doesn’t try modify given list, in cases correct behavior. in practice use guava’s immutablelist , since covers not empty lists nonempty ones.

How to use local XML feed for Android TV live channels app -

i'm getting feel android tv live channels sample app , im trying figure out how , change video src sample channels. can point me in right direction. if helpls sample activity takes me webpage xmltv feed , says modify {@link com.example.android.sampletvinput.rich.richfeedutil#use_local_xml_feed}. if helps any. there 2 ways modify video source channels - set use_local_xml_feed true , update the local xml feed video. - or, if can host xml file on http server, can upload feed , change path xml feed here .

asp.net - TextBox with Default value -

Image
i want use textbox shows text. for example : someone@example.com. when user clicks on it, textbox cleared , ready user type. if working on newer browsers can use placeholder property new in html 5 <asp:textbox id="textbox1" runat="server" placeholder="someone@exmaple.com"></asp:textbox> otherwise can use onfocus , onblur event described here

android - Close the App launched using intent when back pressed -

from application "myapp", launching separate applications(say application a,b,c , on) using respective packagename in intent following code: intent launchintent = getactivity().getpackagemanager().getlaunchintentforpackage(packagename); if(null!=launchintent) { startactivity(launchintent); } now, when press back, want close application launched. don't have control on application launched. right now, when press come "myapp", launched application's audio keeps playing in background. appreciated. thanks. from understand, audio played in service or activity , not familiar activities , activity lifecycle . if audio played in service, must stop service in onbackpressed method. if audio in activity, should add stop audio playback in overriden onpause method of playing activity. if launch third party app (and can't access code) can't make stop app.

osx - Cocoa: WKWebView local storage -

i trying local storage working wkwebview . i have created small demo project . mac app shows window buttons , wkwebview . the 3 buttons show 3 variations of same page: sticky notes webkit demo : remote loads sticky notes webkit demo page in wkwebview . local loads same content copy in app bundle. safari loads sticky notes webkit demo in browser. the first 2 not work; latter does. what should happen should appear 1 default sticky note, , enabled new note button add new sticky notes. in remote , local variations, no note appears, , new note button disabled, indicating couldn't access local storage. i'm hoping i'm doing wrong in loading wkwebview , it's possible isn't supported. here's code remote variation: wkwebviewconfiguration *config = [wkwebviewconfiguration new]; config.websitedatastore = [wkwebsitedatastore defaultdatastore]; self.webview = [[wkwebview alloc] initwithframe:self.container.frame configuration:config]; se

javascript - How does jquery return functions like success and error -

i've looked though jquery code, , it's not clear me. how make own function return success or error in following code: $.ajax({ type: "get", url: "/some.xml", success: function() { /** found! **/}, error: function(xhr, status, error) { if(xhr.status==404) { /** not found! **/} } }); $.ajax passes in object has success , error properties on functions. in function call either success or error depending on result. example might understand better. jsfiddle function iftrue(bool, params) { if (bool) params.success(); else params.error(); } iftrue(true, { success: function () { alert('success'); }, error: function () { alert('error'); } }); iftrue(false, { success: function () { alert('success'); }, error: function () { alert('error'); } });

visual studio express - Internal server error with azure project -

i following tutorial http://blogs.msdn.com/b/jmeier/archive/2010/03/24/how-to-use-asp-net-forms-auth-with-sql-server.aspx , running project. on running project though getting internal server error: page cannot displayed because internal server error has occurred. i using visual studio express 2012 web. have altered connection string in web.config file shown below not sure if causing problem or not. is there way in can see exact error , fix it? the critical part in configuration network configuration. how making sure azure cloud service machine able connect on-premise machine? have configured firewall , ports make sure connectivity not issue. network specific problem might general error may need troubleshoot network specific issue correctness. you use this updated document connecting on-premise sql server azure cloud service. document uses azure connect (which still on beta , depricated) can understand how network should visible windows azure cloud application.

jquery parent() issue -

i speak english not well , show code , problem right now. here code: html: <td class="yyyy"> <a id="delete" href="#" >anchor</a> </td> js: $(function(){ $("a#delete").click(function(e){ e.preventdefault(); var s = $(this).parent("td").attr("class"); alert(s); }); }); it returns alert "undefined". think must "yyyy". can me? thanks! http://jsfiddle.net/nguyenthanh/weayw/4/ i fixed problem write html content of table (tr,td). again! <table> <tr> <td class="yyyy"> <a id="delete" href="#" >anchor</a> </td> </tr> </table> $(function(){ $("a#delete").click(function(e){ var s = $(this).parent("td").attr("class"); alert(s); e.preventdefault();

jsp - Drop down list with values from database shows empty in Liferay -

i want display values in drop-down list comes database. code follows in <form> : <aui:select id="empname" name="empname"> <% employee employee; employee newemployee = new employeeimpl(); int totalemployees = employeelocalserviceutil.getemployeescount(); for(int i=0; i<totalemployees;i++) { %> <aui:option name = "opt" value ='<%=string.valueof(newemployee.getempfname())%>' /> system.out.println("newemployee.getfname string value in loop: " +newemployee.getempfname()); <% } %> </aui:select> it shows big empty list. what should values in drop down list database? i can make out following code have given: employee newemployee = new employeeimpl(); int totalemployees = employeelocalserviceutil.getemployeescount(); this code before for loop, doing getting total-count instead of actual list of employees . and here inside for-loop: <aui:option name = "opt"

How can I resize a picture before displaying it in a view with Android Universal Image Loader? -

i applied universal image loader library (1.8.3 version) app, , i'm trying resize image before displaying in gridview item (because sometime image big cache in memory.) here trying: ... bitmapfactory.options resizeoptions = new bitmapfactory.options(); resizeoptions.insamplesize = 3; // decrease size 3 times resizeoptions.inscaled = true; options = new displayimageoptions.builder() .showstubimage(r.drawable.blank) .showimageforemptyuri(r.drawable.no_image) .cacheinmemory() .cacheondisc() .decodingoptions(resizeoptions) .build(); ... this code doesn't make image 3 times smaller reason. does have better way resize image specified density? read java docs attentively: options.insamplesize of incoming options not considered. library calculate appropriate sample size according imagescaletype(...) options. also imagesizeutil.definetargetsizeforview(imageview imageview, int maximagewidth, int maximageheight) defines target size image: size defined

html - CSS Button Borders Not Working In Chrome -

i have simple website, contains button link styled css. <div id="contact_button"> <a href="mailto:contact@fakemail.com" class="button">contact</a> </div> the border displays fine on ie , firefox, not displaying on chrome (mobile or desktop). thoughts? a.button { -webkit-appearance: button; -moz-appearance: button; appearance: button; -webkit-transition-duration: 0.4s; /* safari */ transition-duration: 0.4s; margin: 0 auto; width: 143px; display: block; background-color: #fff; /* white */ border: 2px solid black; color: #000; padding: 15px 32px; text-align: center; text-decoration: none; font-size: 16px; } a.button:hover { background-color: #000; /* black */ color: white; } removing style -webkit-appearance: button; selector a.button , see same output (white background , 2px-width black border) both in chrome , in firefox.

symfony - Duplicate control using ShtumiUsefulBundle Symfony2 -

Image
i'm using shtumiusefulbundle. config section in application: shtumi_useful : dependent_filtered_entities: ciudad_by_dpto: class: gestionbundle:ciudad parent_property: dpto property: nombreciud role: is_authenticated_anonymously no_result_msg: 'no hay regiones encontradas' order_property: nombreciud order_direction: asc this configureformfields $formmapper ->add('nombre') ->add('email') ->add('urlcurriculum') ->add('cargo') ->add('departamento') ->add('ciudad', 'shtumi_dependent_filtered_entity', array( 'entity_alias' => 'ciudad_by_dpto', 'empty_value' => 'select', 'parent_field' => 'departamento', 'required' => true, )) ; when loading page works perfect de

.htaccess - Redirect www.domain.com to sub.domain.com -

this question has answer here: generic htaccess redirect www non-www 21 answers i'm trying redirect www.domain.com sub.domain.com except when url www.domain.com/something , in case keep way. couldn't find solution on google , anytime try implement in own, www.www.domain.com. in advance! options +symlinksifownermatch options -indexes rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] enable mod_rewrite , .htaccess through httpd.conf , put code in .htaccess under document_root directory: options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{http_host} ^(www\.)?domain\.com$ [nc] rewritecond %{request_uri} !^/something/?$ rewriterule ^ http://sub.domain.com%{request_uri} [r=301,l]

Refreshing ListBox items every few seconds C# -

list<string> listbox = new list<string>(); private void form1_load(object sender, eventargs e) { process[] processes = process.getprocesses(); foreach (var proc in processes) { if (!string.isnullorempty(proc.processname)) listbox.add(proc.processname); } listbox1.datasource = listbox; } while using code, listbox (listbox1) shows of running processes, can adjust of code/add make refresh listbox every 5 seconds, since shows programs open when application opened, , if application closed/opened while opened, won't added listbox, hence why want refresh every 5 seconds or so. you can use timer this: private timer m_timer; private void form1_load(object sender, eventargs e) { refreshprocesses(); m_timer = new timer(); m_timer.interval = 5000; m_timer.tick += timer_tick; m_timer.start(); } void timer_tick(object sender, eventargs e) { refreshprocesses(); } private void refreshprocesses() {

static linking - How can I produce a Crystal executable with no dependencies? -

i'm writing program in crystal , intend compile , move other systems execution. ideally, should have no dependencies, target systems fresh installations of linux. sadly, can't around libc dependency, presumably have compile executable on system possessing lowest version of libc wish target. figure should forward-compatible. i'm having difficulty libssl, however. default installations of debian wheezy don't seem come libssl, error when running executable: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: no such file or directory i assume dependency exists because require "http/client" in source. however, make no ssl-related calls, use connect unsecured websites. i apparently have dependency on libevent-2.0.so.5 . presumably crystal programs do. knows how many other dependencies crystal has? my executables have run on freshly-installed linux system. so, how can produce crystal executable no dependencies? oth

asp.net - Data Table loads only last record of mysqlDataReader -

in page mysqldatareader returns 4 records.whenever load mysqldatareader datatable using datatable dt = new datatable(); dt.clear(); dt.load(dr); datatable shows last record. my code is: datatable dt = new datatable(); (int = 0; < gvdemobatches.rows.count; i++) { checkbox cb = (checkbox)gvdemobatches.rows[i].findcontrol("checkselect"); if (cb.checked == true) { panel2.visible = true; objbebatch.batchid = convert.toint32(((label)gvdemobatches.rows[i].cells[0].findcontrol("lblbatchid")).text); mysqldatareader dr = objbladdnewdemo.getparticulardemodata(objbebatch); dt.clear(); dt.load(dr); } } "getparticulardemodata" stored procedure returns 7 rows.but datatable shows last record. thanks in advance, ratnam. first please write proper/full code 1 can understand ! according code, dr data row,and dr contain single row @ time, seems may have taken dr in loop,so @ last c

html - Responsive Design - Columns Not Staying Within Div Tag -

Image
i'm creating generic responsive web page 3 columns supposed contained within div tag. unfortunately, page looks right now: as can see, 3 columns (content 1, content2, , content 3) should contained within red "3 column layout" section, this: this second image class project working on, when tried copy , paste code, went sh*t. provide code both of these pages. here code first image (the 1 i'm trying fix): html: <!doctype html> <html> <head> <meta charset="utf-8"> <title>resposnive layouts</title> <link href="layout1.css" type="text/css" rel="stylesheet"> </head> <body> <div id="container"><!--opens container--> <header> <h2>header</h2> </header> <nav id="skipto"> <ul> <li><a href="#">link 1</a></li> <li><a href="#">link 2</a></li

database - Access form fill based on combobox -

i'm trying create booking form access database. have "id" combobox link following fields: forename surname address 1 address 2 postcode city date of birth i have achieved link forename , surname fields including information in lookup of combo box , using "=[combo33].[column](x)" control source. id prefer not put entire lot of information in combo box. i'd appreciate help. edit have far using "=[combo33].[column](x)" https://lh4.googleusercontent.com/-zsysc-yxcig/uvlzjtrwyji/aaaaaaaafha/7lmey04h7ms/s1460/screenshot+%289%29.png

git - How do I use an optional extension in a .gitignore file? -

i have following 2 files ./file ./file.text ./file.yo now want exclude of these git , not sure how. thinking regex **/file(?:\..*) , cannot translate gitignore. see there optional char based on documentation appears ! . documentation not provide examples , not sure correct. how write .gitignore line excluding these files @ once? to match 3 files 1 line, use file* , matches files beginning 'file'. if files in specific directory, can use <directory>/file* reduce match scope.

c# - Devexpress master-detail in 2 gridcontrols -

Image
how display master-detail view in 2 grids instead of 1 grid. here's how populate grid , show master-detail view. i don't know how set relation or datamember property (as shown in examples use database) in case of using 2 grid controls create relation current data structure. public class master { public int id { get; set; } public list<sub> subs { get; set; } } public class sub { public int id { get; set; } public string name { get; set; } } //filling data master , sub objects private void filldata() { master = new list<master>(); (int = 0; < 10; i++) { master tmpmaster = new master(); tmpmaster.id = i; tmpmaster.name = "master " + (i + 1).tostring(); tmpmaster.subs = new list<sub>(); for(int j = 0; j < 5; j++) { sub tmpsub = new sub(); tmpsub.id = j; tmpsub.name = "sub " + (j + 1).tostring(); tm

ios - UI loads off centre whilst the Facebook login button works perfectly -

Image
i relatively new user-interface design. question when setting storyboard of ui lined expected when run on ios simulator , ui pushed on right whereas facebook button laid out expected. doing wrong? how dealing autolayout ? if don't use autolayout views randomly appear placed correctly when run in simulator . make think there wrong when in fact expected behavior when not using autolayout . if want "sign in", "forget password", , "create account" labels centered, follow these steps. command click on labels. go bottom of storyboard pane , select little button looks smaller rectangle on top of longer one. in menu select "horizontally in container" click "add constraints" button below. you should other view appear horizontally centered.

c# - NullReferenceException when calling Sitecore Database.Templates[] inside WCF service -

i'm new sitecore development, apologies if question basic. i've created both agent (scheduled task) , wcf service , have them both added sitecore project. agent calls same code wcf service code calls. the issue having when call database.template[id template] passing in id container of corresponding template item want process, works inside agent task, not inside wcf service. any call database.template[id id] inside wcf service giving me nullreferenceexception , exact same call inside agent gathers template properly. is due structural reason dependent on calling application being webpage instead of webservice? edit #1: have svc allowed extension, , have tried both sitecore.configuration.factory.getdatabase("master") and var sitecontext = sitecore.configuration.factory.getsite("websitemaster"); sitecontext.database.template[]; both return nullreferenceexception . i can obtain item, using getitem , when try access template property o

Excel VBA formula as text issue -

in excel 2016 vba have code: range("m2").select activecell.formular1c1 = "=iferror(if(e2=""sgl"",k2,l2),"")" when gets placed in cell formula not result. manually fix have change text general , actual code needs changing: cell m2 says: =iferror(if(e2="sgl",k2,l2),") should say: =iferror(if(e2="sgl",k2,l2),"") " @ end before closing parenthesis this recorded (i removed rc absolute cell reference when wouldn't work), i'm not sure caused or how resolve it. appreciated. thanks i think need add quote @ end. because quote denotes string, need make 2 of them yield 1 -- means need 4 yield two. range("m2").formula = "=iferror(if(e2=""sgl"",k2,l2),"""")" other notes of interest: you don't need range().select , work against activecell . invoke methods/properties directly on range object i think in case

MySQL issue when importing specific CSV files with blank values in random rows -

i had brought before earlier, after doing research, realized looking in wrong place. here situation. create table: create table pc_contacts ( poc varchar(255) primary key not null, phone_1 varchar(255), phone_2 varchar(255) ); i import csv file mysql has values table pc_contacts: use network load data infile 'c:\\programdata\\mysql\\mysql server 5.7\\uploads\\pc_contacts.csv' table pc_contacts fields terminated ',' enclosed '"' lines terminated '\n' ignore 1 rows; my output after importing looks this: +------------------+--------------+---------------+ | poc | phone_1 | phone_2 | +------------------+--------------+---------------+ |april wilson | 123-456-5000 | 123-456-5006 | | 123-456-2222 | | | 123-456-5331 | | | 123-456-7772 | |anton watson | 123-456-1258 | 123-456-6005 |elisa kerring | 123-456-1075 | 123-456-4475 now may recall, based on code inpu

javascript - Eventhandler Safari -

i want generate html file javascript processes eventhandling in safari. following code works safari in static html file. this code fine, need have more! creating html file javascript followed, name of javascript file c.js: c.js function createwindowsec(){ wsec = window.open("security.html","tester","width=400,height=400,left=10,top=10,scrollbars=no,toolbar=no,menubar=yes,location=yes,status=no"); wsec.document.open(); wsec.document.write('<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"><title>bernhard</title><script type="text/javascript">function unloading(e) { return "hello here!"; } function load() {this.addeventlistener("beforeunload", unloading, false);}</script&g

ruby - Validation of a username with regex -

trying solve regex sign-on problem. here rules: allowed characters are: lowercase letters, numbers, underscore. length should between 4 , 16 characters. here test cases must pass: test.describe("basic tests") test.assert_equals(validate_usr('asddsa'), true) test.assert_equals(validate_usr('a'), false) test.assert_equals(validate_usr('hass'), false) test.assert_equals(validate_usr('hasd_12assssssasasasasasaasasasasas'), false) test.assert_equals(validate_usr(''), false) test.assert_equals(validate_usr('____'), true) test.assert_equals(validate_usr('012'), false) test.assert_equals(validate_usr('p1pp1'), true) test.assert_equals(validate_usr('asd43 34'), false) test.assert_equals(validate_usr('asd43_34'), true) end this code: def validate_usr(username) if (username.length > 3 && username == username.downcase) return true elsif username.incl

c# - Export MS ChartImage to PPT in asp.net -

i trying export chart images ppt i.e each image in 1 slide, below code string strtemplate, strpic; strtemplate = "c:\\program files (x86)\\microsoft office\\templates\\presentation designs\\maple.gif"; //strpic = @"c:\users\rongala.ganesh\pictures\arrow_left_green_large.png"; bool bassistanton; microsoft.office.interop.powerpoint.application objapp; microsoft.office.interop.powerpoint.presentations objpresset; microsoft.office.interop.powerpoint._presentation objpres; microsoft.office.interop.powerpoint.slides objslides; microsoft.office.interop.powerpoint._slide objslide; microsoft.office.interop.powerpoint.textrange objtextrng; microsoft.office.interop.powerpoint.shapes objshapes; microsoft.office.interop.powerpoint.shape objshape; microsoft.office.interop.powerpoint.slideshowwindows objssws; microsof

c# - System.Convert.ToSingle(value) always throws FormatException -

i have several strings need convert float . when try so, using system.convert.tosingle(mystring) , formatexception . i have tried creating strings "12.123" , make sure numbers okay, again got exception. question is, correct format then? in format should number in string be? example of 1 of many strings convert: 50.105128 it down system's culture may set using , separator. setting format invariantculture use . separator. convert.tosingle("12.123", cultureinfo.invariantculture)

osx - How to make AppleScript change the time in system preferences -

okay goal script make changes time 1 second every 1 second. in way stop time on mac. got far script. note in () script there suppose do. aka me. set pasword ("my password") tell application "system preferences" activate end tell delay 3 tell application "system events" tell process "system preferences" click menu item "date & time" of menu "view" of menu bar 1 delay 2 tell window "date & time" (click authentication lock.) tell application "system events" keystroke pasword delay 1 tell application "system events" keystroke return delay 1 (uncheck set time data , time automatically checkbox) delay 1 repeat (select seconds above clock) (click top arrow right next it) (click save) delay 1 end repeat end tell end tell end tell end tell end tell so whole script, got stuck in areas , i

python - Update the mysql table row of column type JsonBlob -

consider structure of table field 'extra' follows: extra = sql.column(sql.jsonblob()) so of jsonblob type. now need update values in field 'extra'. when trying update 'extra' value, ends in error follows: file "basic_test.py", line 38 sql = "update project set extra=('{"creation_date": "%s"}') id=('%s')" % (date, tenant_id) ^ syntaxerror: invalid syntax code have tried follows: import datetime mylist = [] today = datetime.date.today() mylist.append(today) date = mylist[0] tenant_id = '1578f81703ec4bbaa1d548532c922ab9' sql = "update project set extra='{"creation_date": "%s"}' id=('%s')" % (date, tenant_id) cur.execute(sql) note: for example, providing here same type of data used in table. i have selected rows table , providing sample here.

drupal - Set up for working offline and uploading to remote site -

i using komodo edit coding, , have set using mamp , local install of drupal, , sass build site offline. once ready test online, upload onto remote site. however, working on remote site , on local one, , finding problems. i'm not using sass on remote site, working in css file. don't have drupal panels in code yet, i'm having rebuild them on remote site, , i'm making tweaks , changes on fly. i end 2 different versions of site , need keep track of changes want keep both. can clean workflow? it better if work entirely locally , sync remote environment. with netbeans think have local copy of site running , right click , upload each file onto remote server there 2 copies of file. i advice cleanest set is. i have actual dev server own ip , live server own ip both connect same mysql server. there 2 databases set up, db1 , db2. i use php script basic sql instructions to: check db in use. backup db (say, db1). sync databases import db db2. once done

node.js - What is the difference between 'session' and 'cookieSession' middleware in Connect/Express? -

there 2 session-related middlewares bundled connect/express. difference? how choose? i'm assuming session middleware same cookiesession middleware, store mechanism. the session middleware implements generic session functionality in-memory storage default. allows specify other storage formats, though. the cookiesession middleware , on other hand, implements cookie-backed storage (that is, entire session serialized cookie, rather session key. should used when session data going stay relatively small.

Haskell: [String] to IO () -

i new haskell , trying list of values input , print 1 item out list each line. func :: [string] -> io () i having trouble trying figure out how print out item in list, when list size 1. func [] = return () func [x] = return x i getting error message when trying compile file: couldn't match expected type `()' actual type `string' in first argument of `return', namely `x' in expression: return x i lost , have tried searching haven't found anything. thanks! you can use form_ this: func :: [string] -> io () func l = form_ l putstrln if want write own version directly, have problems. for empty list, have nothing create value of io () , can return. for non-empty list want output line putstrln , process rest of list. non-empty list of form x:xs x head of list , xs tail. second pattern matches one-element list. func [] = return () func (x:xs) = putstrln x >> func xs

sed - How to replace second column of csv file with a specific value "XYX" -

to replace last field of csv file xyz use following command: awk -f, '{$nf="xyz";}1' ofs=, file how can overwrite second column of file value xyz ? in awk variable nf number of fields on current line. can refer each field $1 , $2 ... $nf $1 first field , $2 second field, upto $nf last field on current line (i.e. if nf 5 $nf $5 ). $ cat file 1,2,3,4,5 $ awk '$2="xyx"' fs=, ofs=, file 1,xyx,3,4,5

Iceface 1.8 not working properly in IE11 -

i come across wired issue icefaces in ie11. once submit page via partial command button. page has no response @ all. there nothing happened @ all. , issue cannot simulated in computer ie11. cannot figure out what's going on? i'm concern ie issue. versions of ie cannot compatible icefaces stuff well. cannot find evidence. have same or similar issue? clue great me. appreciate much.

javascript - Update xml file using fs-extra in Node JS -

i want read specific xml tag , update it. here xml file <?xml version="1.0" encoding="utf-8" standalone="yes"?> <widget id="com.ionicframework.myapp450442" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>myapp</name> <description> ionic framework , cordova project. </description> <author email="hi@ionicframework" href="http://ionicframework.com/"> ionic framework team </author> <content src="index.html"/> <access origin="*"/> <preference name="webviewbounce" value="false"/> <preference name="uiwebviewbounce" value="false"/> <preference name="disallowoverscroll" value="true"/> <preference name="android-minsdkver

jsplumb - JavaScript Drawing library for Flow charts and attaching data to the view dynamically -

i looking javascript library in can make simple flow chart, includes, a start point, end point, few conditions, changing data, , adding view when double click box, can fork flow. went through few libraries. d3.js not suited kind of visualization. other libraries, jsplumb, cytoscape, jointjs (and not rappid. looking open source) any suggestions. the solutions listed either generic graph theory libraries or generic visio/dia-like diagramming libraries. each, you'll have add own logic on top restricted flow chart case. or, you'll have in-depth searching find that's flow charts.

ruby on rails - Error using `self` object in after_save callback -

i have 2 tables: people , car : person has_many cars car belongs_to person . i want send email person when license_plate of car changed. i have made mail code have problem in setting if condition inside after_save callback. #inside person models after_save :send_mail_notification, if: (self.cars.first.order('updated_at desc').changed?) def send_mail_notification(person) ... end i got error nomethoderror: undefined method `cars' #<class:0x4852ba8> so, guess self isn't usable in callback? solution? thanks after_save :send_mail_notification, if: proc.new { |model| model.cars.order('updated_at desc').first.changed? }

android - USB host has confusing documentation -

i working android host mode usb. in documentation host mode api , manifest requirements suggest using: android.hardware.usb.action.usb_device_attached this causing me confusion usbmanager docs suggest using: android.hardware.usb.action.action_usb_device_attached can explain difference between two? furthermore, usbmanager (2nd) version not inform app when device attached, host (1st) version does. i cannot detached intent work using either version: android.hardware.usb.action.usb_device_detached android.hardware.usb.action.action_usb_device_detached please advise. edit here manifest: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cs.android.terminal" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="12" android:targetsdkversion="15" /> <uses-feature android:name="android.hardware.usb.accessor

php - How to increment each digit in a variable by 5? -

i need php function adds 5 each number of string given , go 0 once reaches 10. let's $number = 281621 , need 5 added each of digits, end result should like: 736176 each digit should go 0 once reaches 10. how accomplish this? this thing. function addtonumber($number, $add){ $string_number = strval($number); for($i = 0; $i < strlen($string_number); $i++) $string_number[$i] = strval((intval($string_number[$i]) + $add) % 10); return intval($string_number); } $number = 281621; echo addtonumber($number, 5); ?> addtonumber() takes number self first argument , second argument number want add each digit, in case 5. it's pretty straight forward , don't think explanation required still if have doubts, leave in comments.

serialization - cannot create a file for writing - iOS -

so have encoded bunch of objects writing, i'm having trouble file management. can't seem open existing file, or create new file. i've tried creating empty file of same name, or creating new file. doesn't seem respond (or @ matter). edit i've followed of advice here, , i'm getting bad access crash. here's path: nsstring *documentsdirectory = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; filepath = [documentsdirectory stringbyappendingpathcomponent:@"/bucketlistdata.dat"]; and here's modified method. -(void) writefile { nsdata *encodedobject; encodedobject = [nskeyedarchiver archiveddatawithrootobject: bucketitems]; nsfilehandle *file; file = [nsfilehandle filehandleforreadingatpath:filepath]; if(file == nil) { nslog(@"failed open file handle writing. attempting create file."); [[nsfilemanager defaultmanager] createfile

c++ - Variadic template argument deduction fails when passing initializer lists -

bar holds std::vector of std::pair s of std::array s of foovalueadaptor s. foovalueadaptor implicitly converts int bool foovalue , makes little sense in contrived example, perfect sense in application. implemented convenience function bar::addentries adding multiple entries @ once, calling more 2 arguments fails compile using gcc 4.8.0. see error messages below. #include <array> #include <utility> #include <vector> enum class foovalue { a, b, c }; class foovalueadaptor { public: foovalueadaptor(bool value) : m_value(static_cast<foovalue>(value)) { } foovalueadaptor(int value) : m_value(static_cast<foovalue>(static_cast<bool>(value))) { } foovalueadaptor(foovalue value) : m_value(value) { } operator foovalue() { return m_value; } operator bool() { return m_value == foovalue::c; } private: foovalue m_value; }; template<std::size_t nfir

c# - There Was No Endpoint Listening at http // That Could Accept The Message in WCF -

i trying develop webservice . in application need connect webservice without referencing, use code: static void main(string[] args) { basichttpbinding binding = new basichttpbinding(); endpointaddress address = new endpointaddress("http://confdemo.spadsystem.com/wcfservicelibrary1.service1.svc"); channelfactory<iservice1> factory = new channelfactory<iservice1>(binding, address); iservice1 channel = factory.createchannel(); console.writeline(channel.getcategoryname(1)); console.readline(); } but in line channel.getcategoryname(1) error : there no endpoint listening @ http://confdemo.spadsystem.com/wcfservicelibrary1.service1.svc accept message. caused incorrect address or soap action. see innerexception, if present, more details. here service webconfig : <?xml version="1.0" encoding="utf-8" ?> <configuration> <appsettings> <add key="aspnet:usetaskfriendlysynch

java - JTabbedPane minimum size incorrectly calculated -

i found bug in java , i'd know what's best way workaround it. when create jtabbedpane left alignment (the tabs on left side) , if add icons in tabs, minimum size of component incorrect. here simple way reproduce: import java.awt.borderlayout; import java.awt.dimension; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jpanel; import javax.swing.jsplitpane; import javax.swing.jtabbedpane; public class minsizecomponent { // +-------------------------------- // | constructor // +-------------------------------- // +-------------------------------- // | methods // +-------------------------------- public void createandshowgui() { system.out.println("createandshowgui()"); jframe.setdefaultlookandfeeldecorated(true); jframe frame = new jframe("selection"); frame.setdefaultcloseoperation(jframe.exit_on_close); // +----------------