Posts

Showing posts from June, 2012

jersey - Which JerseyClientBuilder to use? -

so i'm developing application on top of dropwizard , in 1 component have call external rest service. want using jerseyclient. now there 2 implementations available, 1 dropwizard , 1 jersey. using builder have choose between io.dropwizard.client.jerseyclientbuilder.jerseyclientbuilder and org.glassfish.jersey.client.jerseyclientbuilder now former requires environment jerseyclientconfiguration being passed it. is there reason using dropwizard implementation on vanilla one? what's difference (except timeout)? thank you after more digging , asking around, got answer (below). seems better use jerseyclientbuilder comes dropwizard better integrated: one can use jerseyclientconfiguration in order configure jerseyclientbuilder via application configuration (service.yml file). passing environment information enables use of managed thread pool integrated within dropwizard's lifecycle, when dropwizard gets shut down, client. dropwizard's metrics inte...

arrays - Converting 32x32 StdPicture icons to PNG -

i trying convert stdpicture png before encoding base64 sent on xml. i've gotten base64 encoding portion down (see near end of function encodeimagetobase64() ) having trouble converting stdpicture object png byte array. here's function: private function encodeimagetobase64(byref image stdpicture) string dim xmldoc domdocument60 dim xmlnode msxml2.ixmldomelement dim bcolor() byte dim bmask() byte dim bimage() byte dim lcrctable() long dim lwidth long dim lheight long encodeimagetobase64 = vbnullstring if image nothing exit function end if call makecrc32table(lcrctable) call iconpictoarrays(image, bcolor, bmask, lwidth, lheight) if not createpngbytearray(bimage, lwidth, lheight, bcolor, bmask, lcrctable) debug.assert false exit function end if 'call getpicturebits(bimage, image) set xmldoc = new domdocument60 set xmlnode = xmldoc.createelement("b64") xmlnode.datatype = "bin.base64" xmlnode.nodet...

java - Cursor throwing NullPointerException when calling moveToFirst() -

i've had crash report on play store looks this: java.lang.nullpointerexception @ android.database.sqlite.sqlitecursor.fillwindow(sqlitecursor.java:144) @ android.database.sqlite.sqlitecursor.getcount(sqlitecursor.java:133) @ android.database.abstractcursor.movetoposition(abstractcursor.java:196) @ android.database.abstractcursor.movetofirst(abstractcursor.java:236) @ com.myapp.myactivity(myactivity.java:283) @ java.lang.thread.run(thread.java:856) at first thought cursor being null, can't because check if it's null before call movetofirst() mcursor = getcursordata(); if (mcursor != null) mcursor.movetofirst(); // line 283 can tell me why crashing? edit: the code above pretty @ start of method it's inside. running inside onconfigurationchanged() can update tabs on activity new set cursor. getcursordata() method inside sqliteopenhelper : reason i'm using rawquery due actual query using inner join. query fine it's w...

objective c - iOS - Wireless Communication Lagging -

so i'm making game involves wireless communication between multiple iphones, 1 being host. attempting via multipeerconnectivity framework, , i've made mcmanager class (an instance of put appdelegate it's available throughout app) handle sending data 1 system another. how sending implemented in code: - (void) sendstate: (nsstring*) str; //used host send commands other connected systems { if(appdelegate.mcmanager.connected && iamhost){ nsdata *datatosend = [str datausingencoding: nsutf8stringencoding]; nsarray *allpeers = appdelegate.mcmanager.session.connectedpeers; nserror *error; [appdelegate.mcmanager.session senddata:datatosend topeers:allpeers withmode:mcsessionsenddatareliable error:&error]; if (error) { nslog(@"%@", [error localizeddescription]); } } } ...

c# - Does Nancy model bind to fields as per the documentation or not? -

i have tried simple nancy example model binding , documentation ( https://github.com/nancyfx/nancy/wiki/model-binding ) says fields usable properties, in practice seem bind when use properties. is documentation right (if so, why isn't model binding?) or documentation wrong (if so, why?) model binding fields wasn't supported until v1 . long you're using v1 or newer should work out of box. if doesn't provide code reproduces issue along version of nancy you're using? since documentation targets recent version can confusing features supported in each version. @ moment best place find version information changes on breaking changes page .

knockout.js - When required Knockoutjs custom binding -

trying learn knockoutjs.i have found knockoutjs custom binding related code not good. <input data-bind="value: name" /> <hr/> <div data-bind="fadeintext: name"></div> ko.bindinghandlers.fadeintext = { update: function(element, valueaccessor) { $(element).hide(); ko.bindinghandlers.text.update(element, valueaccessor); $(element).fadein(); } }; var viewmodel = { name: ko.observable("bob") }; ko.applybindings(viewmodel); i not understand when people go custom binding ? 1) if possible tell me few situation when custom binding option? 2) if see code can understand custom binding fadeintext , viewmodel has no relation still working. how ? 3) if there multiple view model how specify viewmodel name binding name @ time of binding ? jsfiddle link of above code http://jsfiddle.net/rniemeyer/smkpz/ 4) how achieve same output without custom binding ? possible ? please answer question p...

android - Make the RecyclerView load more items from database -

i using recyclerview cursors following set up, recyclerview adapter cursorrecyclerviewadapter . items have image , textviews. recyclerview not going have more 5-7 items @ max. my question is, there way tell recyclerview load more items ones shown in screen? because of imageviews, 2 present on screen , when scrolling others load not smooth should be. there way tell recyclerview load 4 if 2 not showing on screen? well, basic concept of recyclerview recycles views go out of screen , reuses them (when not visible) show next items in list. minimum number of views loaded memory , views recycled in loop according position. is there way tell recyclerview load more items ones shown in screen? if want load more items user can see on screen, think might not possible recyclerview . workaround : if have small list (as suggest) use listview or gridview can desire.

php - Get email from bitbucket -

i need implement bitbucket authorization on symfony2 project. i`m using hwioauthbundle , guzzle forming request. emails need json response https://bitbucket.org/api/1.0/users/ {accountname}/emails every time client error response [url] https://bitbucket.org/api/1.0/users/ {accountname}/emails [status code] 401 [reason phrase] unauthorized" but i`m authorized @ bitbucket . here code: $url = 'https://bitbucket.org/api/1.0/users/'.$response->getusername().'/emails'; $client = new client(); $request = $client->createrequest('get', $url); $emails = $client->send($request); it seems not providing access token when making requests, therefore bitbucket rejecting them 401. from docs : once have access token, per rfc-6750, can use in request in of following ways (listed least desirable): send in request header: authorization: bearer {access_token} include in (application/x-www-form-urlencoded) post body ...

java - Registration activity freezing on phones -

i'm stuck @ registration page of app. i've tested on avd , works fine there noted logcat heavily stormed system logs. the scene right when test app on phone login activity works fine when go registration page activity freezes & have no option other force closing myself or wait phone ask me if want force close it. here code of registration page. the activity name enroll.java package com.example.dell.iblood; import android.content.intent; import android.os.bundle; import android.os.strictmode; import android.support.v7.app.actionbaractivity; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.button; import android.widget.edittext; import android.widget.spinner; import android.widget.toast; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.namevaluepair; import org.apache.ht...

Java XML Create Fragment/Elements Without Namespace -

i trying construct xml document using org.w3c.dom.document create xml existing tool. problem having tool seems have xml namespaces in strange way. how can replicate using java api's? <ns1:myroot xmlns:ns1="http://foo.com/ns1/"> <ns2:bar xmlns:ns2="http://foo.com/xml/bar/"> <ns2:bar_thing>abc</ns2:bar_thing> </ns2:bar> <ns3:data xmlns:ns3="http://foo.com/xml/special-ns"> <!--these not namespaced reason. if use ns3 prefix, or use default xmls="...", tool fails load document, saying elements have invalid values. --> <a>element without namespace</a> <b> <bi>1</bi> <bii>2</bii> </b> </ns3:data> </ns1:myroot> i can build of document createelementns , setattributens . can't ns3:data contents correct. trying use non-namespace createelement still left xmlns="htt...

node.js - how do you run "npm install" inside of a folder from chef? -

i attempting install nodejs project git via chef script. banging head trying npm install run inside of installed projects directory , leveraging included "package.json" coming git. i tried dwith deprecated npm cookbook: 18>> npm_package 19: path node[:deploy_nodejs_from_git][:destination] 20: action :install_from_json 21: end but isn't working - , don't know if worth effort make work since deprecated: [2015-05-15t08:50:25-04:00] error: must supply name when declaring npm_package resource i have looked @ nodejs cookbook - requires list out packages , not defer package.json. is not right approach? small shop , being able leverage package.json , not have replicate seems ideal. this using, pending identification of better altternative: if node[:deploy_nodejs_from_git][:destination] path = node[:deploy_nodejs_from_git][:destination] cmd = "npm install" execute "npm install @ #{path}" cwd path ...

python - Reshaping/Pivoting data in Spark RDD and/or Spark DataFrames -

i have data in following format (either rdd or spark dataframe): from pyspark.sql import sqlcontext sqlcontext = sqlcontext(sc) rdd = sc.parallelize([('x01',41,'us',3), ('x01',41,'uk',1), ('x01',41,'ca',2), ('x02',72,'us',4), ('x02',72,'uk',6), ('x02',72,'ca',7), ('x02',72,'xx',8)]) # convert spark dataframe schema = structtype([structfield('id', stringtype(), true), structfield('age', integertype(), true), structfield('country', stringtype(), true), structfield('score', integertype(), true)]) df = sqlcontext.createdataframe(rdd, schema) what 'reshape' data, convert rows in country(specifically us, uk , ca) ...

c# 80% Cpu at once. Can't find where the bug is / (on a game server with 250 online) -

hello made game server in c# big online game. problem out of no 90% cpu usage. it got stuck on 90% when bug there stays on 90% ever.. so question how can find code failure on simple way because server huge. there .net profilers foor or that? it got stuck on 90% when bug there stays on 90% ever that's awesome! got handed holy grail right there friend! simply attach debugger when gets in state , break. chances you'll break in buggy code, if not keep running , breaking. should there quick if it's using 90% of cpu. alternatively run through vs's profiler , zoom graph in zone extremely high sustained cpu usage, you'll list of functions use time (assuming it's cpu bound issue, if it's i/o don't think show).

django rest framework perform_update or post_save return custom response -

how can return custom response json error when object older 8 minutes. here code, response doesn't work: def perform_update(self, serializer): instance = serializer.save() diff_minutes = (datetime.now() - instance.ordered_date).total_seconds() / 60 if diff_minutes > 8: return response({'expired': true}, status=status.http_500_internal_server_error) self.post_save(instance) same when use post_save . i don't response, pass. any suggestion? since want return 500 error can raise apiexception . example: from rest_framework.exceptions import apiexception def perform_update(self, serializer): instance = serializer.save() diff_minutes = (datetime.now() - instance.ordered_date).total_seconds() / 60 if diff_minutes > 8: raise apiexception("expired") self.post_save(instance) raising apiexception trigger .handle_exception(self, exc) function. default return result like: {detail : ...

email - Store new files in IMAP folders -

is possible create new file (simple text file) , store within imap folder? so e.g. program analyzes mails , wants store file statistics in imap folder, it's stored on server , not locally can information through platforms. of course may misuse of these folders (normally supposed store emails), exists functionality in imap lets me upload whatever want specific folders on server? what want metadata extension. not supported, perhaps goal server happens support it. the people voted question down should penance reading rfc5464.

memcached - PHP Startup: unable to load dynamic library 'C:\xampp\php\ext\php_memcached.dll' -%1 is not a valid Win32 application -

php startup: unable load dynamic library 'c:\xampp\php\ext\php_memcached.dll' -%1 not valid win32 application. this error keep showing whenever restart apache server(using xampp). have installed memcached , started using command prompt, memcached.exe -d start , running fine checked task manager. now, how fix it? not using right .dll file? try phpinfo() , check right on top, says compiler, if downloaded correct vc8/9/10 32/64bit version of .dll, exchange - if needed - restart apache , should fine. can bit tedious find corresponding .dll's, luck!

javascript memory leak with requre js and js anonymous functions -

after executing below lines of code, user object not being collected gc. showing on chrome heap snapshot. can help? define("mockmodule", [], function () { function user(name) { var = this; this.name = name; this.column = [{ id: 'xyz' }]; this.createobj(); } user.prototype.createobj = function () { var = this; this.column[0]['formatter'] = outerfunction(that); }; user.prototype.dummymethod = function () { } ; function outerfunction(that) { return function () { return that.dummymethod(that) }; } return { user: user }; }); define("mockmoduleimpl", ["mockmodule"], function (mockmodule) { function init() { var user = new mockmodule.user("hello"); user = null; } return { init: init }; }); require(["mockmoduleimpl"], function (mockmoduleimpl) { mockmoduleimpl.init(); });

Project java with struts and tomcat encoding UTF-8 for POST requests -

i'm trying save data in utf-8, i'm getting problems encoding : in post request, when watch firebug can see post request "content-type: text/html". however, when watch action, httpservletrequest object has object connector attribute uriencoding = utf-8 jsp page encoding in utf-8, (firefox told me , checked notepad++) put -dfile.encoding="utf-8" in debug configurations/arguments tomcat server have uriencoding = utf-8 in file server.xml @ right connector, , in file web.xml have following filter : <filter> <filter-name>setcharacterencodingfilter</filter-name> <filter-class>org.apache.catalina.filters.setcharacterencodingfilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> what doing wrong, can me ?

android get actual time -

i designing app. facing 1 problem. want time user's device if user has changed time(which not exact correct time). + if user changes time or time-zone, somehow; application should notify app. however, need check offline. please suggest me suitable way tackle candy crush-like scenario in app. thanks in advance. you can use utc time. system.currenttimemillis() ref

javascript - Remove unwanted text from link using jquery -

hello friends want make function remove specific group of words input link before doing search : i got coding : jquery : <script type="text/javascript"> function getidinfo() { var q = document.getelementbyid("graph").value; window.open("http://graph.facebook.com/" + q,"", "width=500px, height=300px"); } </script> html : <form action="index.php" method="get"> <input id="graph" type="text" name="q" size="20" placeholder="guru.of.fun or 100xxxx"/></td> <input type="button" name="graph" value="get facebook data" class="submit" onclick="getidinfo()" /> and want remove https://graph.facebook.com/ , read text after slash / for example : 100008622 full link https://www.facebook.com/100008622 if user enter in search text...

java - tomcat 6 stability issue on windows 2012 -

i have internal workflow web-based app. running fine @ 6 requests per second. using jvm 1.6, tomcat 6, windows 2003, sqlserver 2005. tomcat located on same vm sqlserver. no clustering. then there port sqlserver 2012, , web app moved jvm 1.8, still tomcat 6, , upgrade jdbc driver jtds 1.2.1 1.3.1 support new sqlserver version. , tomcat moved own vm. and happened after upgrades (above) once week network traffic on tomcat vm drops 0, cpu goes 60% , tomcat unresponsive until tomcat gets restarted, runs ok week. we tried downgrading jvm 1.7, 1.6 , jtds 1.3.1 microsoft jdbc driver. no improvement. want try next put tomcat 6 on own pc, windows 2003 , monitor because concerned vm configuration/ network configuration causing problem. thoughts? thanks! tom

python - pycharm console unicode to readable string -

Image
studying python this tutorial the problem when trying cyrillic characters unicode in pycharm console. import requests bs4 import beautifulsoup import operator import codecs def start(url): word_list = [] source_code = requests.get(url).text soup = beautifulsoup(source_code) post_text in soup.findall('a', {'class': 'b-tasks__item__title js-set-visited'}): content = post_text.string words = content.lower().split() each_word in words: word_list.append(each_word) clean_up_list(word_list) def clean_up_list(word_list): clean_word_list = [] word in word_list: symbols = "!@#$%^&*()_+{}|:<>?,./;'[]\=-\"" in range(0, len(symbols)): word = word.replace(symbols[i], "") if len(word) > 0: clean_word_list.append(word) create_dictionary(clean_word_list) def create_dictionary(clean_word_list): word_c...

c - Extract or set private key parameters in cryptoki library -

i ran issues writing small test programme using cryptoki library. want (have) hold of rsa private key (all parameters). thought either generate keys , extract parameters or use generated parameters set keys manually. far, don't of working. code @ end of post. extraction i know there c_getattributevalue() can extract attributes such public exponent or modulus. works both public , private key objects ckr_attribute_sensitive error when try extract private parameters private key object. there way extract these attributes? can/do have set parameters when logging session or during initialising? setting keys manually my second approach read key material (generated openssl) file , use generating key objects c_createobject() . file contains rsa parameters (n,e,d,p,q,dmp1,dmq1,iqmp). after reading, convert them ascii hex representation , store them in ck_byte[] . far good. now, when pass c_createobject() in order create private key receive ckr_attribute_value_invalid error ...

curve - Is there any way to draw curved lines or rectangles in Andengine? -

i have draw curved lines or rectangles in andengine. please tell me way if know. ok, rectangle class draws rectangles, line class draws lines. rectangle rect = new rectangle(float px, float py, float pwidth, float pheight, vertexbufferobjectmanager pvertexbufferobjectmanager) you set position, width , height here. put vertex buffer object manager there too, , you're go. bezier curves harder do, since there no curve class nor beziercurve. use linestrip class: final vertexbufferobjectmanager vbom = engine.getvertexbufferobjectmanager(); final highperformancelinechainvertexbufferobject pleftcurblinechainvbom = new highperformancelinechainvertexbufferobject(vbom, trianglecount * 3, drawtype.dynamic, true, leftcurb.vertexbufferobjectattributes_default); linestrip leftcurb = new linestrip(0, 0, 2f, 300, pleftcurblinechainvbom){ @override protected void onmanagedupdate(final float psecondselapsed) { super.onmanagedupdate(pseconds...

How to know or calculate empty or blank cells on google sheets? -

i have big list of products on google sheets 900 rows. , on these rows information every product, when customers buy 1 put id of product in id product column. now want how many cells blank or empty can't calculate manually every 900 cells. how can create function helps me calculate empty cells on list on google sheets? google sheets has formula that. =countblank(range)

c# - Inherting and Customizing WPF controls -

we developing piece of software intended work both stand alone plugin different cad programs. note meant discrete versions of software. not 1 monolith version functions plugin stand alone version. developing interface using wpf. depending on context (i.e. whether stand alone version or hooked cad program) want able change , importantly behaviour of interface. rather not have rewrite entire interface. i give brief overview of failed idea hope provide additional context want achieve. initial idea create project defines default interface creating necessary controls , assembling them interface in page or window. if want customize interface use specific cad program inherit controls , pages , override parts want customize given context. found inherit wpf controls not straight forward. a quick mock of setup tried outlined here . the default view contains basic interface called defaultui collected in page. contains custom canvas(called defaultcanvas) type wrapped in scrollviewer. xam...

datepicker - How to select date in Primefaces <p:calendar/> popup with keyboard -

i have requirement make application accessable handicapped useres, using screenreaders. recognized date on popup can selected mouse. is there way use keyboard it? ok, worst case user can make input directly field thats not customers wants.

angularjs - how to get selected element in angular js -

i trying selected value of menu option .actually in demo when click button show menu option want selected element text when user click select option menu , hide menu . how selected item menu or selected text menu .first click button show menu item select element menu element menu. http://codepen.io/anon/pen/rpaoqy link:function(scope,element,attr){ $(element).menu(); $(element).bind('click',function(){ alert('--') ismenuvisibles=false; }) directives designed integrate 3rd party libraries (such jquery-ui menu in use case) use proper convention nope - <ul custommenu ismenuvisible="ismenuvisible" good - <ul custommenu is-menu-visible="ismenuvisible" when using directive parameters, case changes in html , in definition. read more here normalization angular normalizes element's tag , attribute name determine elements matc...

scala - spray authenticate directive returns different HTTP status codes -

i trying basic authentication on post request in spray.io 1.3.2 using authenticate directive. code looks following: val route: route = { pathprefix("ato") { pathprefix("v1") { path("orders" / "updatestatus") { post { authenticate(basicauth(userpasswordauthenticator _, realm = "bd ato import api")) { user => entity(as[string]) {e => complete { s"hello $e " } } } } } } } } def userpasswordauthenticator(userpass: option[userpass]): future[option[string]] = future { if (userpass.exists(up => up.user == ato_import_v1_usr && up.pass == ato_import_v1_pwd)) some("ato_v1") else none } this works fine, authorized status ok 200, unauthorized 401. when order of directives changed follows: val r...

JSF + primefaces spiner ajax invoking other submits -

i'm using ajax in spinner call action in backing bean. this code: <b:panel> <p:datatable id="orderdatatable" var="order" value="#{orderviewbean.orders}" widgetvar="ordersdatatable" tablestyle="table-layout: auto;"> <p:column headertext="created" filterby="#{order.creationdate}" filterstyle="display: none" filtermatchmode="contains"> <h:outputtext value="#{order.creationdate}"/> </p:column> <p:column headertext="created by" filterby="#{order.createdby}" filterstyle="display: none" filtermatchmode="contains"> <h:outputtext value="#{order.createdby}"/> </p:column> </p:datatable> <b:panelgrid colspans="4,4,4"> <b:commandbutton acti...

java - onResume stops my application -

my application gets serial usb input ftdi chip, managed it. press button 3 input float type numbers displayed on app. here onclick : public void onreadclick(view view) throws unsupportedencodingexception { // [ftdriver] create read buffer byte[] rbuf = new byte[27]; // 1byte <--slow-- [transfer speed] --fast--> 4096 byte // [ftdriver] read usb serial len = mserial.read(rbuf); for(i=0; i<len; i++) { mtext1.append((char) rbuf[i]); } text = mtext1.tostring(); string[] splited = text.split("#"); long r = long.parselong(splited[1], 16); float f = float.intbitstofloat(r.intvalue()); d1 = f.tostring(); val.settext(d1); long r2 = long.parselong(splited[2], 16); float f2 = float.intbitstofloat(r2.intvalue()); d2 = f2.tostri...

ssh - Accessing remote linux server's localhost:8080 from windows desktop -

i complete beginner linux. have ssh access (i think that's is) linux server. have program called spagobi installed on server, , needs accessed through localhost:8080 in browser. have changed xml file points localhost ip of server still can't access it. have suggestions on how access localhost through ip? with spagobi configured answer on localhost (the default), can use putty on windows create ssh tunnel local system spagobi system. if redirect local 8080 (of local system) 8080 of spagobi system, access remote spagobi server http://localhost:8080/spagobi while ssh tunnel up. now... configure spagobi server correctly answers on specific fqdns... you'll need modify tomcat server.xml go tomcat config directory , edit server.xml. these 2 entries you'll need modify. restart tomcat , try access spagobi using fqdns , url. <environment name="spagobi_service_url" type="java.lang.string" value="http://spagobi.example.com:8080/spago...

javascript - Using jQuery $.when and $.then with two functions -

i know can use $.when().then() if have $.ajax call in $.when method. thing i'm trying use these methods while call function in $.when method , function in $.then method. function call in $.when method calls $.ajax method. my problem won't respond if try doing it. want in $.when method , continue $.then method. my initial function (called when clicking button) is: function hideform(elem) { var valid = validateemailpass(elem); var user, email; if (valid) { user_info_all.style.display = "none"; showmessage(regerrmsg, "נירשם, אנא המתן.."); var email = document.getelementbyid('<%= reg_email.clientid %>'), pass = document.getelementbyid('<%= reg_pass.clientid %>'), age = document.getelementbyid('<%= reg_age.clientid %>'), username = document.getelementbyid('<%= reg_user.clientid %>'); $.ajax({ type: "post", ...

xaml - WPF Changing the style of a UserControl in a ListView -

i'm having issues setting style of usercontorl. have usercontrol called busyindicator defined in file. below xaml. <usercontrol x:class="foo.client.ui.svgs.busyindicator" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" d:designheight="300" d:designwidth="300" datacontext="{binding relativesource={relativesource self}}" > <usercontrol.template> <controltemplate> <border width="{binding width}" height="{binding height}" visibility="{templatebinding control.visibility}"> <...

javascript - How to get the 1st character after a pattern using regex? -

i'm trying first character after pattern. i.e. border-top-color padding-top /-[a-z]/g selects: border[-t]op[-c]olor padding[-t]op i want select: border-[t]op-[c]olor padding-[t]op how first character after selected pattern? example here! :) just use capturing group: "border-top-color".replace(/-([a-z])/g, "-[$1]") result: "border-[t]op-[c]olor"

java - nullpointer exception in parsing string to date -

i getting null pointer exception when parsing string date. using simpledateformat parsing. pls see code below , me. error in below line date datefrom = formatter.parse(from2); code maindatabasehandler.java `public list<string> gettimeslotatt(string text2, string from2) { // todo auto-generated method stub list<string> list = new arraylist<string>(); simpledateformat formatter = new simpledateformat("dd-mm-yyyy"); string selectquery = "select * "+ table_labels + " "+ key_name + " ='"+text2+"' , "+from_date+"='"+from2+"'"; string selectquery1 = "select * "+ table_labels + " "+ key_name + " ='"+text2+"'"; sqlitedatabase db = this.getreadabledatabase(); cursor cursor = db.rawquery(selectquery, null);//selectquery,selectedarguments cursor...