Posts

Showing posts from January, 2015

Arduino (C/C++) Code To Display Contents of Array on LCD -

i've tried researching before posting this, new programming, general ignorance @ point preventing me being able know how ask right questions. current goals: building array stores 50+ english words/phrases; access array on arduino, , have individual words/phrases display on lcd; and toggle through words/phrases clicking button on arduino. hardware specs: sainsmart unor3, lcd based on hd44780 issue: writing code display new word when push button. code "hello, world!" lcd void setup() { // set lcd's number of columns , rows: lcd.begin(16, 2); // print message lcd. lcd.print("hello, world!"); } void loop() { // set cursor column 0, line 1 // (note: line 1 second row, since counting begins 0): lcd.setcursor(0, 1); // print number of seconds since reset: lcd.print(millis()/1000); } code random string array #include <stdio.h> #include <stdlib.h> int main() { const char *messages[] = { "hello!&

debugging - UIImage not writing to or appearing on Desktop -

for whatever reason, i'm not having uiimage appear on desktop. i'm using code means of debugging. however, i'm pretty sure receiving image since uiimage in debugger not null. uiimage *imgageprofile = [uiimage imagewithdata: [nsdata datawithcontentsofurl: [nsurl urlwithstring: surlpic]]]; // use code debug images nsurl *alocalurl = [nsurl urlwithstring:@"file:///users/snuffles753/desktop/"]; nsdata *imagedata = uiimagepngrepresentation(imgageprofile); [imagedata writetourl:alocalurl atomically:yes]; -[nsdata writetourl:…] takes url includes name of file you'd created. ` not take url of folder, , automatically create file inside of that. current code attempting overwrite existing directory, fails. instead, specify filename explicitly: nsurl *alocalurl = [nsurl urlwithstring:@"file:///users/snuffles753/desktop/debug.pn

flex - Smooth scrolling a Spark List with variable height items using the mouse wheel -

we have list of variable height items display in spark list control. when user clicks , drags vertical scrollbar list scrolls smoothly. when up/down arrows used moves in small , discrete steps. when mouse wheel used list scrolls in large discrete steps problematic user. we enable smooth scrolling mouse wheel. height of our items vary , easy lost when scroll moouse due discrete scrolling. our implementation simple: <s:list id="chartlist" dataprovider="{pm.charts}" itemrenderer="charts.chartitemrenderer" horizontalscrollpolicy="off" verticalscrollpolicy="on" usevirtuallayout="false" cachepolicy="auto"> </s:list> <?xml version="1.0" encoding="utf-8"?> <s:itemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="li

linux - How to launch a shell script with an emacs keybinding, passing the word under the cursor as a variable -

executing script below on osx via emacs, didn't work, got permission denied message, answer question solved problem: https://stackoverflow.com/a/12276562/912475 tldr: how can set system automatically pass word under cursor in emacs directly shell script variable , run script? i've created rudimentary system "linking" folders plain text files in robust way. uses timestamp that's generated script , set "value" of clipboard. clipboard, timestamp pasted txt related notes , name field of folder. to find folders when reading txt use emacs function keybinding makes possible copy timestamp (as word, it's numbers) clipboard , search in spotlight (on osx). i'd instead automatically launch shell script searches directory name ends string , opens it. have script that, don't know how tie elisp function , shell script together. i'd appreciate solution works on either osx , linux (i use both). easy "port" solution works on either 1 u

python - Split a string into all possible ordered phrases -

i trying explore functionality of python's built-in functions. i'm trying work takes string such as: 'the fast dog' and break string down possible ordered phrases, lists. example above output following: [['the', 'fast dog'], ['the fast', 'dog'], ['the', 'fast', 'dog']] the key thing original ordering of words in string needs preserved when generating possible phrases. i've been able function work can this, cumbersome , ugly. however, wondering if of built-in functionality in python might of use. thinking might possible split string @ various white spaces, , apply recursively each split. might have suggestions? using itertools.combinations : import itertools def break_down(text): words = text.split() ns = range(1, len(words)) # n = 1..(n-1) n in ns: # split 2, 3, 4, ..., n parts. idxs in itertools.combinations(ns, n): yield [' '.join(words[i:j])

c# - Checkboxlist loop is not working -

i have dropdownlist control , button in asp.net page. dropdownlist populated method. if select item other first item, after clicking button, lose selected item in ddl , selects first item , getting value of first item in button click event. how can fix problem? <asp:dropdownlist id="userdropdown" runat="server" datatextfield="customername" datavaluefield="customerid"> </asp:dropdownlist> protected void button1_click(object sender, eventargs e) { if(!page.ispostback) { userdropdown.datasource = cc.getcustomers(); userdropdown.databind(); } } it sounds binding dropdownlist datasource @ ever request. instead bind if page.ispostback false below; (you may not need objectdatasource ) protected void page_load(object sender, eventargs e) { if (!page.ispostback) { //bind datasource here (something below) userdropdown.datasource = getcustomers(); userdropdown.databind(); } } as databind() m

iBatis logging log4j - how to get sql id in the log -

i have ibatis log working prints sql stmt, parameters etc. in log file. not print select id. for example: select id="getuserinfo" parameterclass="string" resultclass="string" i want print getuserinfo in log. how do that? thank you, robert are using logging framework or something? use log4j logging consoleappender class "org.apache.log4j.consoleappender" , fileappender class , have conversionpattern set "%d{iso8601} %-5p %m%n" , works me. console appender settings <appender name="a1" class="org.apache.log4j.consoleappender"> <param name="target" value="system.out"/> <param name="threshold" value="debug"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d{iso8601} %-5p %m%n"/> </layout> </appender> my log4j.xml f

html5 - Prevent jQuery Mobile Page navigation (PhoneGap) IF -

using phonegap... i find way prevent navigation data-role='page', if user has no network connection. i'm having hard time finding resources this, few hours deep on google searching, although using wrong terms. i want user able navigate here if there network connection: <div data-role="page" id="location"> <div data-role="header" data-theme="e"> <a href="#" data-rel="back">incid..</a> <h1> location</h1> <a href="#" data-rel="back" onclick="updateloc()" data-theme="g">use current</a> </div> <!-- /header --> <div data-role="content"> <!--<div id="panel"> <input id="target" type="text" placeholder="search box">

ios - Button size is automatically changing -

i'm adding buttons (image button) on viewcontroller modal connections other viewcontroller. when buttons in iphone simulator, buttons size changing(by itself). , created new buttons problem can again. problem? solution issue? disable auto layout in interface builder

c++ - Why are duplicate messages being logged -

i'm new log4cplus. have following configuration: log4cplus.rootlogger=trace, stdout log4cplus.logger.zios.utl.thread=debug, stdout log4cplus.appender.stdout=log4cplus::consoleappender log4cplus.appender.stdout.layout=log4cplus::patternlayout log4cplus.appender.stdout.layout.conversionpattern=%d{%h:%m:%s} [%t] - %m%n which load following code: try { log4cplus::propertyconfigurator::doconfigure("log4cplus.properties"); } catch (...) { cout << "exception occured while opening log4cplus.properties" << endl; } it loads without incident whenever log something, 2 messages appearing in log. example, log using code: logger log = logger::getinstance("zios.utl.thread"); log4cplus_debug(log, "thread created"); and appears in log is: 17:10:48 [3075459952] - thread created 17:10:48 [3075459952] - thread created any idea why happening? you have 1 appender , use twice, 2 loggers: log4cplus.rootlogger=tra

PHP Warning: Division by zero -

i'm learning php , built experimental form-based calculator (also using html & post method) returns values table. calculator functional when enter values , click submit, keep getting 2 "division zero" errors on last line when first run code. can't seem seem find logical solution or explanations when searching here or via google. explanation can provide newb appreciated. <?php error_reporting(e_all ^ e_notice); //calculate difference in price $itemqty = $_post['num1']; $itemcost = $_post['num2']; $itemsale = $_post['num3']; $shipmat = $_post['num4']; $diffprice = $itemsale - $itemcost; $actual = ($diffprice - $shipmat) * $itemqty; $diffpricepercent = (($actual * 100) / $itemcost) / $itemqty ; ?> you need wrap form processing code in conditional doesn't run when first open page. so: if($_post['num1'] > 0 && $_post['num2'] > 0 && $_post['num3'] > 0

sql - Distinct,REGEXP apply to Field and CONCAT_GROUP in MYSQL to remove repeated words to stored procedure -

context: i've following table(example): | id | name | country | --------------------------------------------- | 1 | cristian | francia,holanda,alemania | | 2 | andrea | francia,espaÑa,belgica | | 3 | fabian | belgica,alemania | i need put countries in field, need there aren't repeat values. so, i'm trygin following query: select group_concat(distinct(country)) usuario; or using regular expresion : select group_concat(distinct(country)) usuario group_concat(country) regexp 'somepattern' the wrong answer next: francia,holanda,alemania,francia,espaÑa,belgica,belgica,alemania the expected answer is: francia,holanda,alemania,espaÑa,belgica or make stored procedure ? how expected answer, to n values , differing values ? thanks knowledge , time!. there's no builtin function in mysql. it's possible boatload of string processing in mysql, it's ugly, , there has known finite l

ios - Decreasing images in TableViewController when scrolling -

Image
i'm trying display uitableview list of artists read last.fm api. store artists in array, show table name , picture. initially photos good, when scroll images small. this initial appearance: this appearance after scrolling, problem: this code create cells: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"topartistcell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; jscartist *artist = self.artists[indexpath.row]; cell.textlabel.text = [artist name]; [cell.imageview setimagewithurl:[nsurl urlwithstring:[[artist photo] thumbnail]] placeholderimage: [uiimage imagenamed:@"default_photo.jpeg"]]; return cell; } the default imageview uitableview acts little odd. create custom uitableviewcell subclass , own layout.

linux - what is PATH on the MAC (UNIX) system -

im trying setup project , storm git https://github.com/nathanmarz/storm/wiki/setting-up-development-environment download storm release , unpack it, , put unpacked bin/ directory on path my question path mean, want me ? sometimes see /bin/path , $path, echo path can explain concept of path , can setup in future without blindly following instructions? this techincal question. maybe trival professionals. entry people me need guides. dont understand why people trying close question. path special environment variable in unix (and unix-like, e.g. gnu/linux) systems, used , manipulated shell (though other things can use it, well). there's terse explanation on wikipedia , it's used define search executable files (whether binaries, shell scripts, whatever). you can find out current path set simple shell command: : $; echo $path (note: : $; meant represent shell prompt; may different you; know whatever prompt is, that's i'm representing string

c++ - Avoid buffering in ZMQ for a determined time? -

we reading messages kinect broadcasting in zmq. we use more or less following code: socket_t subscriber_eeg(context, zmq_sub); subscriber_eeg.connect("tcp://127.0.0.1:5559"); while(true) { random stuff if (pressedpause) { //shows message continue; } subscriber.recv(&kinect_msg); //code process message //code plot hand movements. } the objective pause execution of code on given event pressed pause. pause event running on thread independently. everything works fine, problem that, since zmq buffers messages, starts plotting every movement captured in paused state. is there way tell zmq stop receiving message in event of pause, or clear buffer? just toggle connection state: subscriber.connect("tcp://127.0.0.1:5559"); //do work //user presses 'pause' subscriber.disconnect("tcp://127.0.0.1:5559"); //user un-'pauses' subscriber.connect("tcp://127.0.0.1:5559"); i tested separate threads, when subs

mysql - Codeigniter batch insert query -

i try insert data in mysql table using codeigniter. first retrieve columns config xml should insert data , targeted nodes should give xml insert values. foreach ($sql_xml $children) { foreach ($children $index => $child) { if ($child != 'feed_id') { $keys[] = $index; $into[] = $child; //this holds table columns } } } then retrieve multiple values per row want insert. $products = array(); $data = array(); foreach ($target_xml $feeds) { $feeds = $this->xml2array($feeds); //simplexmlobject array $columns = new recursiveiteratoriterator(new recursivearrayiterator($feeds)); //get recursive iteration foreach ($columns $index=>$column) { if (in_array($index, $keys)) { //here values on matching nodes $data[] = $column; }

jquery - Twitter Bootstrap Datatable not working properly with AJaX -

Image
using piece of html code working fine expected: <table class = 'table table-bordered table-striped' id = 'example'> <thead><tr><th>col1</th><th>col2</th></tr></thead> <tbody> <tr><td>foo</td><td>foo</td></tr> <tr><td>foo</td><td>foo</td></tr> </tbody> </table> here it: but when store same snippet in variable as: content = "<table class = 'table table-bordered table-striped' id = 'example'>" + "<thead><tr><th>col1</th><th>col2</th></tr></thead>" + "<tbody>" + "<tr><td>foo</td><td>foo</td></tr>" + "<tr><td>foo</td><td>foo</td></tr>" + "</tbody>" + &quo

Yeoman yo command -

Image
i've updated version of yeoman today stable 1.0 version. when run yo command following: i hoping this: are these options available mac users? you don't see generators in below screenshots, because don't have them installed. follow instructions "install generator" menu entry , install like.

android - Custom font is only applied on first textview and button -

custom font applied on first textview , button, not on rest.i had used findviewbyid views. had used fontfam id textview , btfontfam button xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:layout_margintop="100dp" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:textsize="24sp" android:text="@string/l1" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/lbtn" android:textsize="24sp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" andr

java - Thread-safe updating of a cached resource -

the logic pretty straightforward: foo foo = cache.get(); if (isuptodate(foo)) { return foo; } else { foo = getupdatedfoo(); // slow or expensive cache.put(foo); return foo; } however, want make sure that only 1 thread calls getupdatedfoo() @ time if thread calling getupdatedfoo() , thread b doesn't call it, instead waiting thread a's results i cobble based on memoizer pattern jcip, suspect there's simpler way -- possibly using guava cachebuilder? not obvious how, though. update: implemented double-checked locking pattern per frankpl's answer below: foo foo = cache.get(); if (!isuptodate(foo)) { lock.lock(); // block if other thread refreshing try { // see if other thread refreshed foo = cache.get(); if (!isuptodate(foo)) { // guess not, we'll refresh ourselves foo = getupdatedfoo(); cache.put(foo); } } { lock.unlock(); } } return foo;

How to set environmental variable from Scala? -

i need set environmental variable (path) scala. i tried this: val cmd = seq("export", "path='bla'") cmd.lines but got error: java.io.ioexception: cannot run program "export": error=2, no such file or directory @ java.lang.processbuilder.start(processbuilder.java:1041) @ scala.sys.process.processbuilderimpl$simple.run(processbuilderimpl.scala:68) @ scala.sys.process.processbuilderimpl$abstractbuilder.lines(processbuilderimpl.scala:140) @ scala.sys.process.processbuilderimpl$abstractbuilder.lines(processbuilderimpl.scala:106) @ .<init>(<console>:12) @ .<clinit>(<console>) @ .<init>(<console>:11) @ .<clinit>(<console>) @ $print(<console>) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.me

jquery - Getting history.js to work without Ajax loaded pages -

i don't know why isn't working , i've been trying everything. most of tutorials online using ajax i'm not , i've tried adapting can't work. i'm using has bang urls , content loaded in index page it's being shown , hidden dynamically. use getting history working. here script... history.adapter.bind(window, 'statechange', handlestatechange); $('nav a').on('click',function(e) { var target = $(this).attr('href'); history.pushstate(null, null, target); }); function handlestatechange() { alert("state changed..."); } if alert happen can go there alert never fires , don't know why. just define function before binding event, in way: function handlestatechange() { alert("state changed..."); } history.adapter.bind(window, 'statechange', handlestatechange); $('nav a').on('click',function(e) { var target = $(this).attr('href'); his

qt4 - How I can add an object to a list in python? -

def guardar(self): saux="" combobox=self.ui.cmbitems.currenttext() cantidad=str(self.ui.spinbox.value()) subtotal=self.ui.txbseleccion.text() costounidad=self.ui.txbcostou.text() saux=cantidad+"--"+combobox+" $(unidad)"+costounidad+" $(total)"+subtotal self.ui.textbrowser.append(saux) i want pull sum of subtotal (i'm using qt4 if in doubt) anyone know how can do?, thanks

Return value from HTTPResponse closure Grails HTTPBuilder to outer method -

i have code this def lookuptickets() { user currentuser = webauthservice.currentuser() def http = new httpbuilder(zdurl) http.auth.basic("${zduser}/token", zdapikey) http.get(path: "/api/v2/users/search.json", query: [query: currentuser.emailaddress], requestcontenttype: contenttype.json, { resp, json -> println "response status: ${resp.statusline}" def zendeskuserid = json?.users[0]?.id }) return myresult } the line def zendeskuserid = json?.users[0]?.id gives me result looking return browser. how can return value in outer method when in scope within inner closure? do think not work? def lookuptickets() { def zendeskuserid user currentuser = webauthservice.currentuser() def http = new httpbuilder(zdurl) http.auth.basic("${zduser}/token", zdapikey) http.get(path: "/api/v2/users/search.json", qu

c - strcmp isn't comparing strings properly -

this question has answer here: strcmp behaviour in 32-bit , 64-bit systems 3 answers so have (not full code) char list[1000][10]; strcpy(list[0],"ab"); printf("%d\n",strcmp(list[0],"ab")); and strcmp returning 0. can explain why it's doing so? thanks in advance. the strcmp method return 0 if list[0] contains "ab" in case. it returns: returns integral value indicating relationship between strings: a 0 value indicates both strings equal. a value greater 0 indicates first character not match has greater value in str1 in str2; , value less 0 indicates opposite.

cloudbees - Configuration of CloudAMQP Connection -

i'm having difficulty configuring connection cloudamqp in deployed grails application. can run application locally against locally installed rabbitmq instance can't figure out how correctly define application run on cloudbees using cloudamqp service. in config.groovy, i'm defining connection info , queue: rabbitmq { connectionfactory { username = 'username' password = 'password' hostname = 'lemur.cloudamqp.com' } queues = { testqueue autodelete: false, durable: false, exclusive: false } } when application starts , tries connect, see following log messages: 2013-08-23 21:29:59,195 [main] debug listener.simplemessagelistenercontainer - starting rabbit listener container. 2013-08-23 21:29:59,205 [simpleasynctaskexecutor-1] debug listener.blockingqueueconsumer - starting consumer consumer: tag=[null], channel=null, acknowledgemode=auto local queue size=0 2013-08-23 21:30:08,405 [simpleasynct

eclipse - GNU Make Incremental Build: Force rebuild of specific file -

i'm using eclipse (juno) + cdt on windows 7 drive gcc, automatic makefile generation. worked great until used gcc's __date__ , __time__ preprocessor macros add build date/timestamp in project configuration header file. on clean build, these macros work great - on incremental build, make doesn't rebuild associated object file; jumps straight linking. i tried doing windows equivalent of touch pre-build step (described here: https://stackoverflow.com/questions/51435/windows-version-of-the-unix-touch-command ) make still skips file. tried "touch" source file includes header; still no dice. how can tell make rebuild files depend on particular header, on incremental build? mark header .phony . ensure considered not date: .phony: particular_header.h

asp.net - Write excel file in C# 2.0 without using any third party dlls/interop/sdk -

i want write excel file (xls/xlsx) in c#. constraints: don't want use following things while writing: 1. third party dll( client not allowing me use third party dll ) 2. sdk(same above reason not allowed download) 3. not allowed use interop in target server there no office installed. 4. openxml info: 1. using vs 2005. 2. using asp.net (c# 2.0) write csv file can opened directly excel.

javascript - Parse.com JS API - wildcard search -

i have been searching , can't find instruction on how create simple wildcard search search fields in class. for example have listing like: title: new listing state: florida city: joe if user searches: "listing florida" the above listing included in results. please let me know think! thanks, mitch what want take each string in input ("listing florida" -> ["listing", "florida"]) , search using big and lots of or parts. ugly query. it easier if copied text of every searchable field field called searchdump or (you in cloud code afterupdate or something), this: var query = new parse.query(myclass); (var word in wordlist) { query.contains('searchdump', word); }

matlab - Patch with transparency and timestamp indexes breaks figure -

Image
i having trouble plotting patch on figure transparency , timestamp index varying in datenum range of 735k, more or less datenum acquire actual dates. the following example illustrate issue: k=[735172.912437674 735172.941375799 0 7830]; figure; axis(k); p=patch([k(1) k(1) k(2) k(2)], [k(3) k(4) k(4) k(3)],[0 0 0 0],'r', 'facealpha', 0.1); are able reproduce bug? suggestions? i've seen this other post , searched it, no clue. wouldn't remove minimum time stamps, have adapt code because of x( i learning other question , led me study bit new handle graphics may appear this or next year (?) — looks trying discovering trends @ financial business, guess when go out, if haha. may used adding -hgversion 2 option @ matlab launch. , doing so, resulting figure looks \o/: great… beware there differences on usage hg1 hg2 may lead code not work (specially if using listeners) if want explore even more undocumented code add if in codes breaks: if

iphone - How to get a fully transparent TabBar in UITabBarController -

this question has answer here: uitabbar transparent 1 answer i have spent last few hours trying tabbar in uitabbarcontroller transparent (clear background). use custom subclass of uitabbarcontroller , managed change tintcolor, alpha, background color remains 1 defined in ib. help, i'm getting crazy... here 1 way accomplish that. cgrect frame = cgrectmake(0.0, 0.0, 320, 48);//setting frame. mytabview = [[uiview alloc] initwithframe:frame];//making tab view // not supported on ios4 uitabbar *tabbarr = [self.tabbar tabbar]; if ([tabbarr respondstoselector:@selector(setbackgroundimage:)]) { // set instance [tabbarr setbackgroundimage:[uiimage imagenamed:@"hot-1.png"]]; // set // [[uitabbar appearance] setbackgroundimage: ... } else { // ios 4 code here //[tabbarr setbackgroundcolor:c]; } //[mytabview setbackgroun

android - How to switch between activities without using intents -

i got interview question , cannot figure out... the question is: if have 3 activities a, b , c, how go activity b, b c , c sequentially without using intents? thanks in advance! ok, after reading few more times see interviewer may possibly mean still using intents . need them through each. once c a without intent if call finish() in b before going c . either way, unless terribly missing something, seems have asked million better questions. have asked for. technically, application, afaik, never launched without intent because use intent filters ( launch , main ) in manifest start app.

c# - Object Reference not set to an object (calling Razor model from View) -

Image
this question has answer here: what nullreferenceexception, , how fix it? 29 answers using c# mvc4 my view: @using universe.models @model usermodel @section css { <link href="@url.content("~/content/assets/charcreation.css")" rel="stylesheet"/>} @using (html.beginform("adduser","home", formmethod.post)) { <div class="row-fluid"> <table id="tblbio"> <tr> <td class="span3"> <span class="labeltext">alias:</span> </td> <td class="span5"> @html.textbox(model.alias) </td> <td class="span4"> <span

r - Subsetting on all but empty grep returns empty vector -

suppose have character vector, i'd subset elements don't match regular expression. might use - operator remove subset grep matches: > vec <- letters[1:5] > vec [1] "a" "b" "c" "d" "e" > vec[-grep("d", vec)] [1] "a" "b" "c" "e" i'm given except entries matched "d" . if search regular expression isn't found, instead of getting expect, nothing back: > vec[-grep("z", vec)] character(0) why happen? it's because grep returns integer vector, , when there's no match, returns integer(0) . > grep("d", vec) [1] 4 > grep("z", vec) integer(0) and since - operator works elementwise, , integer(0) has no elements, negation doesn't change integer vector: > -integer(0) integer(0) so vec[-grep("z", vec)] evaluates vec[-integer(0)] in turn evaluates vec[integer(0)] , char

character encoding - Java URLEncode giving different results -

i have code stub: system.out.println(param+"="+value); param = urlencoder.encode(param, "utf-8"); value = urlencoder.encode(value, "utf-8"); system.out.println(param+"="+value); this gives result in eclipse: p=指甲油 p=%e6%8c%87%e7%94%b2%e6%b2%b9 but when run same code command line, following output: p=指甲油 p=%c3%8a%c3%a5%c3%a1%c3%81%c3%ae%e2%89%a4%c3%8a%e2%89%a4%cf%80 what problem? your mac using mac os roman encoding in terminal. chinese characters incorrectly been interpreted using mac os roman encoding instead of utf-8 encoding before sending java. as evidence, chinese characters exist in utf-8 encoding of following (hex) bytes: 指 = 0xe6 0x8c 0x87 甲 = 0xe7 0x94 0xb2 油 = 0xe6 0xb2 0xb9 then check mac os roman codepage layout , (hex) bytes represent following characters: 0xe6 0x8c 0x87 = Ê å á 0xe7 0x94 0xb2 = Á î ≤ 0xe6 0xb2 0xb9 = Ê ≤ π now, put them , url-encode them using utf-8: system.out.p

SQL How to add parentheses to output data -

for college assignment need show last column of output data in parentheses shown below. my current query is: select substring(firstname,1,1) '', '.' '', lastname '', upper(title) '' employees (title != 'sales representative'); this query shows output as: b . brown storeman c . carr receptionist d . dig driver i need show: b . brown (storeman) c . carr (receptionist) d . dig (driver) you should able using concat function select substring(firstname,1,1) '', '.' as'', lastname '', concat('(',upper(title),')') '' employees (title !='sales representative');

javascript - jquery stops execution after trying to append element -

my function supposed copy insides of element twice, , append them, reason jquery stops executing after first append. not understand why. $(".testowyul").prepend(function () { var $temp = $(this).children().clone(); var $temp2 = document.createelement("div"); $temp2.append($temp); $temp2.append($(this).children().clone()); return $temp2.children(); }); you calling append on non jquery object @ $temp2.append($temp); resulting in object #<htmldivelement> has no method 'append' update: you try using var $temp2 = $("div"); instead of var $temp2 = document.createelement("div"); see working fiddle here

android - Multiple Listviews using same Adapter class and same CallBack Interface to Activity -

i have 2 custom listviews each own adapter, of same class. each has same callback interface activity. i struggling how activity can distinguish listview running callback. listener sends selected value activity. however, each listview has similar select-able values (i.e. 1,2,3,4). selected value alone isn't enough distinguish between listview selection originated. callback listener should not implemented same activity class. can implement listeners 2 listviews on own. for example: listview1.setonitemclicklistener(listener1); listview2.setonitemclicklistener(listener2);

gruntjs - How do I get Yeoman to continuously run tests -

when run grunt server, file edits picked , browser refreshed through livereload. when run grunt test, runs once , shuts down. this behavior can simulated running yo angular --minsafe mytest grunt test when change karma.unit.singlerun = false in gruntfile, grunt test says watcher running, no file changes seem trigger running tests again. how reload capability tests similar way linemanjs works? you there! there's additional option can set in gruntfile called autowatch , monitors files specified in karma.conf.js changes. complete entry in gruntfile this: karma: { unit: { configfile: 'karma.conf.js', singlerun: true, autowatch: false }, server: { configfile: 'karma.conf.js', singlerun: false, autowatch: true } }

scala - Why can I assign null to an Option? -

the following valid statements in scala: scala> var x: option[int] = some(3) x: option[int] = some(3) scala> var x: option[int] = none x: option[int] = none the following invalid: scala> var x: option[int] = 3 <console>:7: error: type mismatch; found : int(3) required: option[int] var x: option[int] = 3 so far these examples make sense me; value of type option[t] can either of type some[t] or none, compiler prevents assigning value of neither type. however, scala compiler appears accept this: scala> val x: option[int] = null x: option[int] = null if try pattern match on option (e.g. below), i'll failures didn't expect - why doesn't compiler protect me rejecting assignment of null? x match { case some(y) => println("number: ", y) case none => println("no number") } if @ scala class hierarchy , you'll see classes deriving anyref super classes of null , , such super class can assigned

android - Eclipse dont show to ADT and SDK -

i confused eclipse problems. created project in android yesterday , today morning opened eclipse. saw there not option creating new android project. checked windows - > preference -> android , android option not available here , android sdk option not in eclipse. import android project , see red color error on it. i have installed both adt , sdk http://developer.android.com/sdk/installing/installing-adt.html please me there many possibilities query: 1) first of please check whether have installed correctly: help --> install new software then add link adt - http://dl-ssl.google.com/android/eclipse/ and read too 2) try window > customize perspective > command groups availability tab. check "android sdk , avd manager" option , hit ok button. if "android sdk , avd manager" hasn't shown up, think there may kind of file miss match in eclipse. 3) if so, better start fresh: you can find step step guidance here

java - How do I determine what android widget is calling my function? -

i have several seekbar s in android app practically same thing (set bass, treble, volume). save typing out new local classes onseekbarchangelistener per seekbar , tried make single class in onstoptrackingtouch determine widget calling it, , proper action. public class myseekbar implements seekbar.onseekbarchangelistener { int progresschanged = 0; public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser){ progresschanged = progress; } public void onstarttrackingtouch(seekbar seekbar) {} public void onstoptrackingtouch(seekbar seekbar) { // want case statement here switched on widget id/name, // can set appropriate string s (bass, treble, volume) string s = "set_treble " + progresschanged; client.sendmessage(s); } } how figure out widget calling onstoptrackingtouch ? or there cleaner or better way of doing this? 100 % can determine this; public void onstoptrac

c# 4.0 - Lo4net in a Windows service -

i have c# solution contains 3 services , number of projects. added class log4net calls configuration details sql table. using same class logging in entire project. the logging working fine when debug through code, when deploy in server , while works using service, logging not working properly. have 3 services , logging depends on service start first. if start service 1 first, logs details service's classes, , doesn't log other classes. i tried add idisposable in logger class , destroy each time, not getting expected results. add assemble(classname) in appender: <appender name="urlappender3" type="omidlogappender.urllogappender, omidlogappender"> that omidlogappender log4net class log web service !

Visual Studio 2012 designer screen gone black -

Image
i have been developing windows store app on visual studio 2012, few days back, installed update 3, following ide information microsoft visual studio professional 2012 version 11.0.60610.01 update 3 microsoft .net framework version 4.5.50709 installed version: professional but now, the designer screen has turned black , can select elements, black. check image below: i've tried repairing. idea whats wrong it?

mercurial - hg can't merge branch -

i have mercurial repository named branch brancha. revision looks this default --a-------------------------g \ brancha \---b---c---d---e---f the output of hg branches is: default 193:817540244f12 brancha 192:b7cac921fec3 what want merge change g in default brancha . when try update brancha hg update brancha , hg branch shows it's still in default . hg merge default , mercurial complains "abort: nothing merge (use 'hg update' or check 'hg heads')". hg heads output is: changeset: 193:817540244f12 tag: tip parent: 188:7ccc08b69f25 ... changeset: 192:b7cac921fec3 branch: brancha

gcc - How to compile c code in php - linux environment -

i using fedora 14 , gcc compiler compile c code. using php(lampp) trying call helloworld. trying following code exec('gcc hello.c', $x,$y); echo $x; //line 4 echo "<br/>>>> "; echo $y; notice: array string conversion in /opt/lampp/htdocs/learning/index.php on line 4 array >>> 1 any idea how compile , output. plz :) i did the $compilecode=shell_exec("gcc -o hello hello.c 2>&1"); output: failed create /var/cache/ccache/tmp (permission denied) in echo. what permission issue. yum remove cache did trick

php - Where can I find detailed resource about application structure with Laravel 4 and AngularJS? -

i started develop social network, problem started mix laravel view angularjs led me few problems. i searching around net not able find info this. could me out or give me hint? i prefer decouple angular.js application backend (any backend). can pick tool linemanjs or yeoman . with lineman (which 1 use) develop app without backend, in "isolated way". can use fake backend while in development mode or can have laravel running @ port 4567 (just example) , tell lineman there real backend @ 4567 create proxy (so can use real backend when app in different folder). the advantages many. decoupled backend, can switch others without change in angular. can take advantage of pre-configure set of tasks grunt coffeescript, lint, sourcemaps, auto creation of $templatecache, ngmin avoid minification problems, minification, concatenation... , more if want. you have unit , e2e tests preconfigured... in short, using workflow can create angular.js app plays backend , prov

jquery - Image slider inside (ajax) .load breaks -

this first question on forum , relates .load element in ajax. have unordered list in list items clickable links: <ul id="menubutton"> <a href="index.html" rel="address:/home" id='home'><li id="html/home.html" class="current"><p>home</p></li></a> <a class="clickable" href="html/projects.html" rel="address:/projects" id='projects'><li id="html/projects.html" class=""><p>projects</p></li></a> <a class="clickable" href="html/designers.html" rel="address:/designers" id='designers'><li id="html/designers.html" class=""><p>designers</p></li></a> <a class="clickable" href="html/contact.html" rel="address:/contact" id='contact'><li id="htm

Is this a NHibernate bug or by design? -

i have following in mapping code file contact entity, lazy default: this.bag<int>( "prioritycodes", map => { map.access(accessor.field); map.table("prioritycodes"); map.key(k => k.column("contactid")); map.cascade(cascade.all); }, r => r.element(m => m.column("prioritycode"))); the code in entity class is: private readonly ilist<int> prioritycodes= new list<int>(); when contact list obtained repository, notice contactproxy has interceptor field contains targetinstance. contactproxy inherits contact class, , base class contains private prioritycodes field. the thing don't understand targetinstance private prioritycodes field empty, whereas base class prioritycodes field populated? i have expected targetinstance contain populated private field, calls delegated targe

C++ Link List error going to next node -

i need read words file , put link list. have these codes here(below) inserting link list part. vector contains words i've read file list( vector <string> &v ) { listnode *cur = head; ( int = 0 ; < v.size() ; i++ ) { //cout << v[i] << endl; listnode *newnode = new listnode; newnode->item = v[i]; if ( == 0 ) // first node { newnode->next = null; head = newnode; } else // insert node { listnode *prev = cur; newnode->next = prev->next; prev->next = newnode; } cout << cur->item << endl; system("pause"); } } my problem here node doesn't go next node after inserting word node. tried put cur = cur->next; on between cout <<

css - JQuery bounce effect broken by Bootstrap -

i'm trying bounce popup on hover. want popup bootstrap (v3.0.0) panel. problem is, panel changes it's width after bounce effect. example: http://fiddle.jshell.net/yxrvp/ anyone knows how fix this? add min-width:315px; .poppy http://fiddle.jshell.net/yxrvp/10/ #poppy { position: absolute; top: 200px; left: 250px; width: 315px; height: 200px; overflow: hidden; background: #f9f9f9; display: none; z-index: 2; min-width:315px; }

c - pow() cast to integer, unexpected result -

i have problems using integer cast pow() function in c programming language. compiler i'm using tiny c compiler (tcc version 0.9.24) windows platform. when executing following code, outputs unexpected result 100, 99 : #include <stdio.h> #include <math.h> int main(void) { printf("%d, ", (int) pow(10, 2)); printf("%d", (int) pow(10, 2)); return 0; } however, @ this online compiler output expected: 100, 100 . don't know causing behavior. thoughts? programming error me, compiler bug? you found bug in tcc. that. patch has been commited repository. included in next release, might take while. can of course pull source , build yourself. patch here http://repo.or.cz/w/tinycc.git/commitdiff/73faaea227a53e365dd75f1dba7a5071c7b5e541

Using input-block-level with input-prepend in Twitter Bootstrap 2.3.2 -

i'm wondering how make input field fill available width input-prepend icons in twitter bootstrap 2.3.2 responsive layout? there css style in bootstrap input-block-level witch works fine until prepend input icon... how same functionality prependet input? <div class="control-group"> <label class="control-label" for="inputicon">email address</label> <div class="controls"> <div class="input-prepend "> <span class="add-on"><i class="icon-envelope"></i></span> <input class="span2" id="inputicon" type="text" class="input-block-level"> </div> </div> </div> <div class="control-group"> <label class="control-label" for="inputpassword">password</label> <div class="controls"> <input type="pa

jsf - Scopes and @PostConstruct -

i'm using jsf 2, primefacces 3.4 , cdi. i've 2 pages: page1.xhtml , page2.xhtml . each page has own managed bean: page1bean , page2bean . page1.xhtml has <p:remotecommand> actionlistener displays page2.xhtml . page2.xhtml contains 3 components under <ui:include> , 1 submit button. each of 3 components bound different managed beans component1bean , component2bean , component3bean . submit button shows page1.xhtml . those 3 componentxbean s have @postconstruct method initialization code. tried following scoped on beans: @sessionscoped : works fine single submit operation. when repeat it, beans not reinitialized @postconstruct because session scoped. @viewscoped : @postconstruct gets called multiple times. @conversationscoped : same behavior @viewscoped . why @postconstruct called multiple times in view , conversation scope? how can let them called once per submit operation? running initialization code under 'prerender' ev

evolutionary algorithm - NSGA-II implementation -

i have studied non dominating sorting algorithtm (nsga-ii). want use multi objective optimization algorithm. me addressing free implementation of nsga-ii in java or matlab. thanks in advance jmetal java framework of moea, nsga-ii included in. website here .

html - CSS: position changing on changin resolution -

i making header website. have search box in header , search results should appear right below it. adjusted position of search results div when changed resolution of screen div moved away. have following code in html: <div id = "header"> <div id = "header_wrapper"> <div id = "search_results"> </div> </div> </div> and in css: *{ margin:0px; } #header{ width:100%; border:1px solid #f1f1f1; height:100px; } #header_wrapper{ width:1000px; margin:auto; border:1px solid #f1f1f1; height:100px; } #search_results{ position:absolute; left:30%; height:100px; width:500px; border:1px solid #f1f1f1; top:100px; } how can adjust div not change relative position it's parent div on changing screen resolution.please help just replace css this, hope work want. *{ margin:0px; } #header{ width:100%; height:100px; } #header

video - Android: Save Mediarecorder-Stream as playable file -

i want record videos android device (nexus 10) , upload later youtube. so far i'am recording android mediarecoder , stream via localsocket save data multiple files. files not playable. i read articles sine api-level 18 possible convert files mediacodec and/or mediamuxer. , found this code, not understand how handle it. has easy example shows how convert raw data localsocket playable file (i.e. mp4 files)? my mediarecoder looks this: recorder = new mediarecorder(); recorder.setaudiosource(mediarecorder.audiosource.default); recorder.setvideosource(mediarecorder.videosource.default); camcorderprofile camcorderprofile_hq = camcorderprofile.get(camcorderprofile.quality_high); camcorderprofile_hq.fileformat = mediarecorder.outputformat.mpeg_4; camcorderprofile_hq.videocodec = mediarecorder.videoencoder.mpeg_4_sp; recorder.setprofile(camcorderprofile_hq); recorder.setpreviewdisplay(surfaceholder.getsurface()); clientsocket = new localsocket(); clientsocket.connect(new loca

javascript - Serialize function with PhantomJS bridge -

i have array of links use link parametr function scraped data phantomjs. how serilize function? for statemant runs paralely 3 function in 1 time , recive event error . in case proper use async , how use in series? time of running functions different, how async should understood it's done , start new url? var phantom = require('phantom') , async = require('async'); var urls = [ 'http://en.wikipedia.org/wiki/main_page', 'http://es.wikipedia.org/wiki/wikipedia:portada', 'http://de.wikipedia.org/wiki/wikipedia:hauptseite' ]; async.mapseries(urls, gettitle, function(err, result){ console.log(result); }) function gettitle (link, callback) { phantom.create(function(ph) { return ph.createpage(function(page) { return page.open(link, function(status) { return page.evaluate((function() { return document.title; }), function(result) { callback(null, result); return ph.exit