Posts

Showing posts from August, 2013

java - How to translate the Json in to POJO -

i have following json need able present in pojo, how ? the json has 1 key per day , value each key 2 separate logical arrays, using jackson library. { "2014/01/02": [ {"abc": 2.25, "xyz": 4.05}, {"amazon.com": 3} ], "2014/01/03": [ {"abc": 13.02}, {"amazon.com": 3} ] } you don't have option. that's ugly looking json. there no consistent format, can create pojo. things need consider. {} json object. im java mapping terms, can either map pojo, or map . in order map pojo, need common property names , formatting, of doesn't seem have. seems varying. may need use map . here's how @ it { // start map "2014/01/02": [ // map key: start array ( list<map> ) {"abc": 2.25, "xyz": 4.05}, // start map {"amazon.com": 3} // map you can use @jsonanysetter simplify, using pojo wrapper, still have, in end map<

ruby - Comparing numbers in an array, outputting highest number -

i need write function takes 3 phone numbers in array, adds digits of each number seperately, , outputs phone number biggest value on screen. numbers in form [821-839-1182, 128-389-........] you this: arr = ['821-839-1182', '128-389-4732', '621-411-7324'] arr.max_by { |s| s.each_char.map(&:to_i).reduce(:+) } #=> "128-389-4732" we have: a = arr.map { |s| s.each_char.map(&:to_i) } #=> [[8, 2, 1, 0, 8, 3, 9, 0, 1, 1, 8, 2], # [1, 2, 8, 0, 3, 8, 9, 0, 4, 7, 3, 2], # [6, 2, 1, 0, 4, 1, 1, 0, 7, 3, 2, 4]] b = a.map { |e| e.reduce(:+) } #=> [43, 47, 31] as largest sum @ index 1, max_by return string @ index of arr. note '-'.to_i #=> 0 .

r - Reindent lines in RStudio in .Rhtml doesn't indent braces correctly. Is it configurable? -

reindent lines quick way make sure code clean , cleans code readability no matter python folks think. i noticed in rstudio while editing .rhtml files knitting html reports, code indent aligns braces ({}) incorrectly. <html> <body> <!--begin.rcode #not idiomatic indentation for( in (1:10)){ a=i+1 } # ☹ #ideal indentation for( in (1:10)){ a=i+3 } # ☺ end.rcode--> </body> </html> is there special character fix this? config file? different build of rstudio? thank hints , tips. rstudio developers confirmed bug.

Dart Limiting simultaneous connections -

i have interesting problem dart running in command line mode - fast! the situation code has access web site , retrieve list of files can downloaded, downloads each file write local disk. the problem each download operation running asynchronously , downloads starts failing errors 'socketexception: os error: semaphore timeout period has expired.' , 'connection closed before full header received'. far can determine os on pc failing open required connections or possibly web server been swamped. how should change design limit number of simultaneous connections been made? there several packages wich should make easy: https://pub.dartlang.org/packages/pool https://pub.dartlang.org/packages/rate_limit foreachasync of quiver

javascript - jQuery click function to change the table position -

i have 3 table in #middlebox click list push table top example, position of table starter -> soup ->seafood. when click #seafood_li seafood table show @ top. table set seafood -> starter -> soup. when click #seafood_li again normal. jquery code function of toggle , hide m not sure how modify it <div class="main"> <ul class="top_menu" > <li class="orderlist" id="starter_li">starter</li> <li class="orderlist" id="soup_li"> soup</li> <li class="orderlist" id="seafood_li">seafood</li> <li class="orderlist" id="return_li">return all</li> </ul> <div id="middlebox"> <table class="food_table" id="starters" style="width:100%"> <tbody> <tr> <td>

xcode - Determine When SpriteNode Is Landed On A Rectangle SpriteNode -

i making game there clouds moving, , want clouds fade away when character lands on it. however, when put code, fades away if character goes around , hits bottom or side of cloud while still falling. here code have detecting when character , cloud have hit. is there anyway determine when character has landed on top of cloud not fade cloud away if hits bottom or side while falling? here code declaring objects: person.physicsbody?.usesprecisecollisiondetection = true person.size = cgsizemake(self.frame.size.width / 25, self.frame.size.height / 16.25) person.physicsbody = skphysicsbody(rectangleofsize: person.size) person.physicsbody?.restitution = 0 person.physicsbody?.friction = 0 person.physicsbody?.allowsrotation = false person.physicsbody?.affectedbygravity = true person.physicsbody?.dynamic = true person.physicsbody?.lineardamping = 0 person.zposition = 5 person.physicsbody?.categorybitmask = bodytype.personcategory.rawvalue

shiny - Error in .getReactiveEnvironment()$currentContext() -

please help, error reactive function near code: stockstxtclosure <- reactive({ query <- parsequerystring(clientdata$url_search) stockstweets = searchtwitter(query[["ticker"]], n=10, lang="en") stockstxt = sapply(stockstweets, function(x) x$gettext()) return (stockstxt) }) stockstxt = stockstxtclosure() stockstxt = gsub("(rt|via)((?:\\b\\w*@\\w+)+)", "", stockstxt) error is: error in .getreactiveenvironment()$currentcontext() : operation not allowed without active reactive context. (you tried can done inside reactive expression or observer.)

mysql - How to fix java.sql.SQLException: Server is running in --secure-auth mode, but 'user'@'host' has a password in the old format; (...)? -

after upgrading mysql 5.1 5.6, trying start jboss failed exception: java.sql.sqlexception: server running in --secure-auth mode, 'user'@'localhost' has password in old format; please change password new format how fix issue? first, need locate my.cnf file, should @ following path: mysql server 5.6\my.cnf next find line says old_passwords=0 , change old_passwords=1 . tell mysql use password hashing algorithm compatible going way version 4.0, covers use case. now when start server, password problem should go away. if want upgrade passwords latest version, can use set password each user with flag old_passwords=0 . please keep in mind mysql upgraded password algorithm security reasons, should not view setting old_passwords=1 long term solution. see here more information.

how to set upper limit of memory consumption of MongoDB on Windows7 -

i using mongodb on windows7(not linux) data storage of our application prototype, , have trouble mongodb uses memory. mongodb can set upper limit of memory consumption in linux. not find on windows7. please tell me how set upper limit of memory consumption of mongodb on windows7.

python - How to use regex to remove all symbols but replace blank with '-' -

i know regex, example re.sub(r'[^\w]', '', string) i can remove symbols string. want remove other symbols replace blank '-'. there way that? for example, string = "felix's 3d's" # want "felixs-3d" thanks! if want replace spaces - ignore , str.replace: print(re.sub(r'[^\w\s]', '',string).replace(" ","-")) felixs-3ds

c++ - CreateSemaphoreEx Security Attribute vs Access Mask -

the createsemaphoreex api on windows platform has following parameters: lpsecurity_attributes lpsemaphoreattributes, , dword dwdesiredaccess i understand both serve control access, however, not sure relationships , differences between them. example, if set dwdesiredaccess synchronize, create security attribute empty dacl (i.e. no access @ all), how work together? if can share information on purposes of these parameters , how interact together, great. thanks. if object exists: the lpsemaphoreattributes.lpsecuritydescriptor parameter ignored. the dwdesiredaccess parameter determines access rights given new handle returned function. if these access rights incompatible security permissions on object, call fail error_access_denied . if object not exist: the lpsemaphoreattributes.lpsecuritydescriptor parameter determines security permissions assigned newly created object. if security descriptor not provided, default permissions used. the dwdesiredaccess p

r - knitr: how to reference a plot from a multi-plot chunk -

i have .rnw document want reference plot multi-plot chunk. how do this? example: \documentclass{article} \begin{document} <<single_chunk, fig.cap="hi">>= plot(1:5) @ can reference single chunk fine! see \ref{fig:single_chunk}. <<multichunk, fig.cap="hello">>= plot(1:10) plot(10:1) @ first figure great, \ref{fig:multichunk}. try again \ref{fig:multichunk-1}. \end{document} both these attempts result in ?? . just have @ generated *.tex file! here's relevant part (i took freedom align bit more nicely knit does): \begin{knitrout} \definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe} \begin{alltt} \hlkwd{plot}\hlstd{(}\hlnum{1}\hlopt{:}\hlnum{10}\hlstd{)} \end{alltt} \end{kframe} \begin{figure} \includegraphics[width=\maxwidth]{figure/multichunk-1} \caption[hello]{hello} \label{fig:multichunk1} \end{figure} \begin{kframe}\begin{alltt} \hlkwd{plot}\hlstd{(}\hlnum{10}\hlopt{:}\hlnum{1}

Can't run meteor app in windows 8.1 with tasklist error -

after installed meteor 1.1.0.2 locally in windows 8.1, follow tutorial run first app. when try run it, here came following: d:\git\spi-hw\spi\lab8\simple-todos>meteor run [[[[[ ~\d\git\spi-hw\spi\lab8\simple-todos ]]]]] => started proxy. c:\users\pyjx\appdata\local\.meteor\packages\meteor-tool\1.1.3\mt-os.windows.x86_32\ dev_bundle\lib\node_modules\fibers\future.js:278 throw(ex); ^ error: couldn't run tasklist.exe: {"killed":false,"code":1,"signal":null} @ object.future.wait (c:\users\pyjx\appdata\local\.meteor\packages\meteor-tool\ 1.1.3\mt-os.windows.x86_32\dev_bundle\lib\node_modules\fibers\future.js:398:15) @ findmongopids (c:\users\pyjx\appdata\local\.meteor\ packages\meteor-tool\1.1.3\mt-os.windows.x86_32\tools\run-mongo.js:120:16) @ findmongoandkillitdead (c:\users\pyjx\appdata\local\.meteor\ packages\meteor-tool\1.1.3\mt-os.w

c# - RegEx to replace a particular pattern v-q- to q- and v- to q- . -

i new regex. the sentence string ttt = "becoming <a href=\"/v-abc-q-def-ghi.aspx\">lorem ipsum</a> or <a href=\"/v-xyz.aspx\">lorem ipsum dummy " i want change patterns match v-abc-q-def-ghi q-def-ghi v-xyz q-xyz the requirement if v- , q- present, should remove v-* , if has v-* should changed q-*. var matches = regex.match(ttt, "v-*-q-*"); - 0 matches . tried few mor ethings using ([a-z])\?([a-z]) , characters, not figure out :( kindly me this. achievable ? is looking for? regex.replace(ttt, @"\/(v-[^\.]*?q-|v-)", "/q-"); example

ios - Did SoundCloud API just change without notice? -

i have app using soundcloud's search service (tracks.json). used work fine of sudden it's crashing of our users. this call i'm making: https://api.soundcloud.com/tracks.json?consumer_key=[your_key]&q=music&filter=streamable&order=default&limit=50 i'm either getting array returned, or dictionary array inside "collection" key. result inconsistent. first assumed in middle of deployment it's been 12 hours , still same. i've further discovered following: west coast users getting dictionary west coast users making same call on http (not https) array east coast users getting array on https (unsure of http) i noticed blog post devs: https://developers.soundcloud.com/blog/offset-pagination-deprecated post doesn't mention response format changing. looks changed should have happened 2 months ago. is bug on part? in middle of deployment? else seeing this? response expected dictionary now? update: this problem seems expl

debugging - Find Heap Corruption In C Program -

i've looked around, of answers here questions heap corruption obvious code, or asker has identified source. i have c program (simulating car race) dynamically allocating memory linked list. copies values 1 or more nodes list dynamically allocated 2d array, based on value in node. each node freed after copied, , list head updated. repeats until there no more nodes in list (the end of race). a pointer array returned main , stored in 3d array. the whole process repeats (new linked list, new array). at end of second iteration (second race), getting heap corruption error, , can't figure out causing it. i tried using vld suggested here: memory allocation / heap corruption in std::string constructor but vld included didn't error. i tried enabling debug heap functions: https://msdn.microsoft.com/en-us/library/x98tx3cf.aspx this told me address 0x596ebc5c, doesn't appear contain allocated, i'm not sure if that's meaningful somehow. the best can tell

ruby on rails - Test new controller action with rspec feature test -

i'm using mail form gem handle website's contact form. i'm using rspec , capybara in testing environment. i'm encountering error when trying test contact form page. new action of contacts controller create new instance of contact model, don't know how in rspec fix reason failure. the failed test output: no route matches {:action=>"new", :controller=>"contacts", :format=>nil} missing required keys: [] contact_form_spec.rb require 'spec_helper' require 'rails_helper' rspec.feature "comtact form email", :type => :feature scenario "user sends email via contact form" visit contacts_path fill_in 'name', :with => 'jony ive' fill_in 'email', :with => 'jony@apple.com' fill_in 'subject', :with => 'subject here' fill_in 'message', :with => 'message' click_button 'send message' expe

android - Alertdialog in Material Design -

Image
i follow http://www.laurivan.com/make-dialogs-obey-your-material-theme/ style alertdialog in material design style. however, found out still can't style same site, following code , screenshot: values-v14/styles.xml: <!-- base application theme api 14+. theme replaces appbasetheme both res/values/styles.xml , res/values-v11/styles.xml on api 14+ devices. --> <style name="appbasetheme" parent="android:theme.holo.light.darkactionbar"> <!-- api 14 theme customizations can go here. --> </style> <style name="apptheme" parent="theme.appcompat.light.darkactionbar"> <item name="android:windowcontentoverlay">@null</item> <item name="android:windowactionbaroverlay">true</item> <!-- colorprimary used default action bar background --> <item name="colorprimary">@color/colorprimary</item> <!-- colorprima

Socket.io. How to detect incoming data -

for socket.io, how listen incoming data other emitted "event" types? looking read , detect proxyprotocol string. i did little research. looks proxy string sent initial http request on separate line command this: proxy tcp4 192.168.0.1 192.168.0.11 56324 80\r\n / http/1.1\r\n host: 192.168.0.11\r\n \r\n you can see explained in this article . so, need handled http server fields initial http request starts websocket. occurs in initial connection stage before websocket established. so, not listen afterwards. take study of socket.io code figure out if stores information on socket.io socket or how hook initial http handler see info. little more research.

python - wxPython -- how to use an installed font on Ubuntu -

i have found references how pull font installed windows system, can't find or figure out how on ubuntu. i'm using ubuntu 14.04, wxpython 3.0 , have font installed in usr/share/fonts/truetype. i'm not worried platform independence, strictly personal project used on ubuntu machine. converting comment answer - recommend using fontenumerator widget. allows select , set font installed on system. there example in wxpython demo. here demo uses demo basis: import wx ######################################################################## class testpanel(wx.panel): #---------------------------------------------------------------------- def __init__(self, parent): wx.panel.__init__(self, parent, -1) e = wx.fontenumerator() e.enumeratefacenames() elist= e.getfacenames() elist.sort() s1 = wx.statictext(self, -1, "face names:") self.lb1 = wx.listbox(self, -1, wx.defaultposition, (200, 250

Ruby on Rails - issues with sqlite3 gem install -

this question has answer here: sqlite3 gem rails 3.1 2 answers i learning rails tutorial @ rails tutorial using mac os when try bin/rails server command below errors. bin/rails server not find gem 'uglifier (>= 1.3.0) ruby' in of gem sources listed in gemfile or installed on machine. run `bundle install` install missing gems. successively when try bundle install command bellow issues. gem::installer::extensionbuilderror: error: failed build gem native extension. /system/library/frameworks/ruby.framework/versions/2.0/usr/bin/ruby extconf.rb checking sqlite3.h... yes checking sqlite3_libversion_number() in -lsqlite3... no sqlite3 missing. try 'port install sqlite3 +universal', 'yum install sqlite-devel' or 'apt-get install libsqlite3-dev' , check shared library search path (the location sqlite3 shared library located)

node.js - How to test promise in mocha -

we know when return promise in mocha, test promise. but if throw exception in promise, how tell if exception throw. say, if exception throw in promise, test passes. it("should not take game code same user twice", function (done) { return gamegiftmanage.takegamecode(gamegiftid, userid) .catch(function (e) { expect(e).to.exist; done(); }) }) this test used test exception, won't work in cases. takegamecode: takegamecode: function (giftid, userid) { return gamegiftcode.count({gift: giftid, user: userid}).exec().then(function (c) { if (c) { throw '该用户已经领取过礼包'; } }).then(function () { return gamegiftcode.findoneandupdate({gift: giftid, user: {$exists: false}}, {user: userid}).exec(); }).then(function (a) { if (!a) { throw '礼包领完了'; } else { return a; } }); }, instead of using throw, use reject when

ios - How to find the colour of an individual pixel in UIImage in swift -

i have following swift code. let resolution = [imageview.frame.size.width, imageview.frame.size.height] x in 0...int(resolution[0]) { y in 0...int(resolution[1]) { let coordinate = [x, y] //find colour of pixel here } } i want able find colour being displayed each individual pixel in photo. there way modify code have put "//find colour of pixel here" print rgb value of pixel @ coordinate represented constant coordinate? you can try following: var pixel : [uint8] = [0, 0, 0, 0] var colorspace = cgcolorspacecreatedevicergb() let bitmapinfo = cgbitmapinfo(cgimagealphainfo.premultipliedlast.rawvalue) let context = cgbitmapcontextcreate(unsafemutablepointer(pixel), 1, 1, 8, 4, colorspace, bitmapinfo) hope helps!!

cassandra - Using Custom Classes in Collection Types using DataStax's Java Driver -

is there way use our types (classes provide) in the collection types provide datastax java driver through boundstatement.setset(..) method without using user defined types? perhaps object mapping api? and if so, when create table should use type in set (in other words: set<????> )? we're using datastax java driver v2.1.5 connected dse v4.6.0 (cassandra 2.0.11.83). here's example illustrate: create table teams (uid text primary key, players set<????>); our type: public class player { private string name; public player(string name) { this.name = name; } public string getname() { return name; } public void setname(string name) { this.name = name; } } test: public void testsets(){ set<player> players = new hashset<>(); players.add(new player("nick")); players.add(new player("paul")); players.add(new player("scott")); preparedstatement statement = session.prepare(

wordpress - Links don't open new page in Safari Iphone browser unless you hold and select Open/Open in New Page -

i working wordpress site, , links have become deprecated in mobile safari browser. none of links allow click through usual touch gestures, though links animate if have been clicked. user must hold down link until safari's menu pops , select 'open'. question causing this, , how fix it? this happens wp themes come bundled other plugins. plugins come in these bundles not update or @ until theme developers update theme, causing glitches , compatibility issues. not themes created equal.

add two or more numbers using a turing machine emulator -

i'm playing around turing machine emulator , i'm trying add more 2 numbers together. can make add 2 numbers , halt, cant make halt if add 3 or more numbers (eg 4+3+3 not halt after adding last number instead continues ever). http://i.imgur.com/xxai5my.png - if doesn't work can trying else. this have, i'm not sure need do. appreciated, if need more information don't hesitate ask cheers

Android: How to remove black line below the GridView -

i have gridview. have added paddingbottom view. when scroll gridview there blackish line seen on border of gridview , bottom padding. how rid of blackish line? the gridview xml code follows: <gridview android:id="@+id/slot_gridview" android:layout_width="match_parent" android:layout_height="507dp" android:columnwidth="90dp" android:numcolumns="2" android:scrollbars="none" android:listselector="#00000000" android:layout_margintop="10dp" android:paddingbottom="20dp" android:layout_marginbottom="10dp" android:verticalspacing="31dp" /> use android:fadingedge="none" for disable black strip.

android - How to make one border.xml file which can be configured with a color? -

i have many textview in layout each of border different color. know can create border around textview using <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/border"/> where border.xml follows <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:padding="10dp" android:shape="rectangle" > <stroke android:width="3dp" android:color="#ff0000" /> </shape> but have 8-9 different textviews border 8-9 different border colors. there way without creating 8-9 differert bordercolor.xml (borderpink.xml, borderblue.xml etc) files? you dynamically, using gradientdrawable , setting in textvew. there 2 ways, can define drawable on code (use own properties), this: gradientdrawable drawabl

java - Code not exiting while loop (trying to catch exceptions) -

this question has answer here: java scanner exception handling 4 answers i have written simple code (n1 / n2 = sum) whilst trying learn try / catch exception handling. i have / while loop supposed make x = 2 when run successfully. if not, x = 1, user input can entered again. the code compiles , runs if try, example n1 = 10, n2 = stackoverflow, prinln caught exception runs forever! why loop stuck? thanks in advance import java.util.*; public class exceptionhandlingmain { public static void main(string[] args) { scanner input = new scanner(system.in); int x = 1; // x set 1 { // start of loop try { system.out.println("enter numerator: "); int n1 = input.nextint(); system.out.println("enter divisor"); int n2 = input.nextint();

html - CSS can't be overwritten, no matter how ; Wordpress with responsive style_options.php -

so problem awkward, have wordpress website on can't overwrite css. on i've added google font. the problem when want overwrite css using either id , class selector, or embeding style html, font get's overwritten. how overwrite css (font-face) coded in css in style_options.php generates options.css. did solve problem already? thank answers! strictly speaking, if want attribute not overwritten, need use !important so: p { color: blue!important; } #myid { color: red; } <p id="myid">this text blue.</p> but think should check in theme's option, there's gotta way edit within wordpress such things font. (thanks vineet kaushik pointing out)

javascript - JSSOR Slider - Call images from album hosted online, possibly through RSS Feed? -

first, reason looking loading images slider bogging down site's performance. i'm wondering if there way pull in images album hosted externally, through google picasa albums (i'm open other platforms if better suited it). use slideshow embed code it's pretty horrendous. could done calling rss feed within jssor slider? would improve site performance or have same issues pulling images elsewhere? thanks in advance. sorry if i'm asking isn't best practice or if doesn't make sense approach way, i'm trying improve functionality/performance on personal portfolio. did try lazy loading? if not, please try specify src2 attribute instead of src define lazy loading image. <div><img u="image" src2="image.jpg" /></div>

linux - Schedule cron entries to run script only when not already running -

i have 1 shell script in crontab executing jar file. jar file moving files 1 server server. in peak hours taking more 10 minutes(more crontab entries). how can make sure cron job not execute process until last 1 not completed ? an easy way have cron start bashfile checks if such process exist. cron: */10 * * * * /path/to/bashscript.sh (make sure has correct user , executable) the pgrep command looks process given name, , returns processid when such process found. #!/bin/bash # bashscript.sh pid=$(pgrep -n "yourjarfile") # check if jarfile running if $pid > /dev/null #log syslog logger $pid "already running. not restarting." else # start jar file /usr/bin/java -jar /path/to/yourjarfile.jar fi --edit-- inspired f. hauri's answer (which works fine btw), came shorter version : */10 * * * * pgrep -n "yourjarfile." || /usr/bin/java -jar /path/to/yourjarfile.jar

Python multiprocessing.Pool ignores class method -

i wrote program class research, , i've attempted parallelize it. when i've used python 2.7's multiprocessing.process joinablequeue , managed data, program hangs defunct processes. import multiprocessing mp import traceback class paramfit(object): def __init__(self): pass def _calc_bond(self, index): # calculate data def _calc_parallel(self, index): self._calc_bond(index) def run(self): ts, force in itertools.izip(self.coortrj, self.forcevec): try: consumers = [mp.process(target=self._calc_parallel, args=(force,)) in range(nprocs)] w in consumers: w.start() # enqueue jobs in range(self.totalsites): self.tasks.put(i) # add poison pill each consumer in range(nprocs): self.tasks.put(none) self.tasks.close() self.tasks.join() # w in c

c# - Error when paging in GridView -

i have gridview 2 columns. first shows date , second, year of date in first column. far works when change page, web fails message: "object reference not set instance of object." this code: test.aspx <%@ page language="c#" autoeventwireup="true" codefile="test.aspx.cs" inherits="qq_site_test" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>test</title> </head> <body> <form id="form1" runat="server"> <div> <asp:gridview id="gridview1" runat="server" allowpaging="true" pagesize="5" allowsorting="true" autogeneratecolumns="false" enablemodelvalidation="

Tip: How to add placeholder to textarea in Ninja Forms Wordpress plugin -

this not question. felt needed share small piece of magic peeps out there having hard time getting placeholder in ninja forms textarea field. so, need add following code header.php file in head section, change id of textarea , choose placeholder text. <script type="text/javascript"> jquery(document).ready(function($){ $('#yourtextareaid').attr("placeholder","your placeholder value"); }); </script> hope can save time. can thank me later. a way of doing make work textarea set (in ninja forms) default value of textarea whatever want placeholder , on page load, take content of each textarea, add placeholder attribute, remove content: $(document).ready(function() { // remove textarea content , add placeholder $("textarea").each(function() { var $this = $(this); $this.attr("placeholder", $this.val()); $this.val(""); }); });

Q: How to prevent WCF NetTCP message size quota exceeded -

is there effective ways prevent message size quota exceeded nettcp service returns undetermined-sized collection? example have following service: public list<string> getdirinfo(string path) { list<string> result; result = new list<string>(directory.enumeratedirectories(path)); result.addrange(new list<string>(directory.enumeratefiles(path))); return result; } which returns list of directories , files in given path. @ times, reached message size quota, e.g. return c:\windows\system32 . without changing message size quota, best way handle or prevent sort of service call? few ways can think of: convert stream service call implement pagination as prevention, check size of result prior returning. implement callback mechanism service return series of fixed sized result client. is there wcf configuration returned message split multiple packets , reconstruct clr while confining message size quota. edit: i saw several postings

c++ - Use templates to bind a class method to a specific prototype -

i'm looking way bind functions , class methods specific prototype. let's want bind functions , class methods prototype int (float) to one void () here code class toto { public: int test(float f) { std::cout << "toto::test " << f << std::endl; return 0; } } toto; int test(float f) { std::cout << "test " << f << std::endl; return 0; } template <typename t, t t> void func() { t(4.0f); } template <typename t> void func<int (t::*)(float), int (t::*method)(float)>() { toto::*method(5.0f); } auto main(int, char**) -> int { func<int(*)(float), &test>(); func<void (toto::*)(float), &toto::test>(); return exit_success; } the function binding works properly, method 1 seems have syntax issues don't get. g++ gives me error : src/main.cpp:28:6: error: parse error in template argument list src/main.cpp:28:55: error: function template pa

performance - Insert Speed Compare HashMap, LinkedHashMap -

trying compare speed of insertion between hashmap , linkedhashmap found smaller no of objects until 100000 objects speed faster hashmap. when set insertion count 500000 speed faster linkedhashmap. please use code connected verify scenario. throw light on why speed comparision gets reversed. below class hashmaptest : import java.util.hashmap; import java.util.linkedhashmap; public class hashmaptest { public static void main(string args[]) { final int count = 100000; // create hash map hashmap<string, comparable> hm = new hashmap(); linkedhashmap<string, comparable> lhm = new linkedhashmap(); // put elements map long starttime = system.nanotime(); (int = 0; < count; i++){ hm.put("obj" + i, new string("" + i)); } long estimatedtime = system.nanotime() - starttime; system.out.println("\n time taken insert " + count + " objects (hashmap)= " + estimatedtime / 1000000 + " milliseconds

regex - Remove the data before the second repeated specified character in linux -

i have text file has below data: ab-njcfnjnvne-802ac94f09314ee ab-kjncfvcnnjnwejj-e89ae688336716bb ab-pojkkvcmmmmmjhhgg-9ae6b707a18eb1d03b83c3 ab-qwertu-55c3375fb1ee8bcd8c491e24b2 i need remove data before second hyphen ( - ) , produce text file below output: 802ac94f09314ee e89ae688336716bb 9ae6b707a18eb1d03b83c3 55c3375fb1ee8bcd8c491e24b2 i pretty new linux , trying sed command unsuccessful attempts last couple of hours. how can desired output sed or other useful command awk ? you can use simple cut call: $ cat myfile.txt | cut -d"-" -f3- > myoutput.txt edit: explanation, requested in comments: cut breaks string of text fields according given delimiter. -d defines delimiter, - in case. -f defines fields output. in case, want eliminate before second hyphen, or, in other words, return third field , onwards ( 3- ). the rest of command piping output. cat ing file cut , , saving result output file.

I want to set the following code for SaveAll() in cakephp: -

array( 'student' => array( 'student_name' => array( (int) 0 => '14', (int) 1 => '17', (int) 2 => '18' ), 'fee_name' => array( (int) 0 => '1', (int) 1 => '1', (int) 2 => '1' ), 'standard_name' => array( (int) 0 => '1', (int) 1 => '1', (int) 2 => '1' ), 'section_name' => array( (int) 0 => '7', (int) 1 => '7', (int) 2 => '7' ), 'day_name' => array( (int) 0 => '2015-04-23', (int) 1 => '2015-04-23', (int) 2 => '2015-04-23' ), 'feeplan_name' => array( (int) 0 => '4', (int) 1 => '4', (int) 2 => '4' ) ) ) i want change followin

CPU consumption on a JSON JAVA application -

on quad core cpu machine 4 gb ram, tomcat 6 installed, java 1.6. have software handles communication gateway. handles incoming json messages using jersey (1.19), deserialize , call client send message server using jersey (1.19) rest libraries. handles incoming request other server, serialize json , send outside. 10 users connected, sending 600 byte of message every 4 seconds. global cpu consumption reaches 30%. normal expected behaviour? how can handle more users? code: private string executetogameengine(string text, string urlresource){ clientresponse response = null; try { clientconfig clientconfig = new defaultclientconfig(); client client = client.create(clientconfig); webresource webresource = client.resource(urlresource); response = webresource .accept(mediatype.text_plain) .type(mediatype.text_plain) .post(clientresponse.class, text); if (response == null) { // error... } else if (response.getstatus() !=

java - Error activating Bean Validation Integration - Hibernate -

Image
i have been working on project, simple spring, hibernate, jsf,mysql integration; , run on eclipse. aim of program add person(id, first name, last name, gender, age etc.) database on mysqlworkbench , run on server.i used spring4, hibernate4 , eclipse luna tools.and constructed project maven.i try overcome different errors due different reasons while. my updated-application: https://github.com/fsel/spring-hibernate-jsf-mysql-eclipse-integration when run on server on eclipse, gives "error activating bean validation integration" error.i see due "classnotfoundexception: com.hibernate.data.person".but don't know how solve it. apr 23, 2015 12:31:41 org.apache.tomcat.util.digester.setpropertiesrule begin warning: [setpropertiesrule]{server/service/engine/host/context} setting property 'source' 'org.eclipse.jst.jee.server:spring-hibernate-jsf-mysql-example' did not find matching property. apr 23, 2015 12:31:41 org.apache.catalina.startup.ver