Posts

Help encoding a cURL argument (works fine from the command line, but not from a PHP script) -

i working facebook api, , use following command via terminal post message users wall. curl -f 'access_token=xxxxxxxxxx' \ -f 'message=hello world' \ -f 'to={["id":xxxxxxx]}' \ https://graph.facebook.com/me/feed this works great. trying same via php code; $fields = array( 'access_token' => $t, 'message' => $message, 'to' => '{["id":'.$id.']}' ); $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $fields); curl_exec($ch); curl_close($ch); this code successfuly posts message, own wall (i.e. ignoring 'to' parameter). i'm new curl, , i'm sure encoding wrong, or maybe missing curl flag, i've been through several tutorials on posting via curl, including few answers, , can't see i'm missing. really appreciate help! what print out? if ( 'post...

c# - Should I be using generics to simplify my configuration provider class? -

i attempting write configuration manager can supply configuration settings different providers (e.g. settings files, environment variables, databases etc). i have envisioned settings either strings, ints or doubles , identified name settings provided via classes implementing this: public interface iconfigurationmanagerprovider { t getsetting<t>(string name); ienumerable<configurationsetting> getknownsettings(); } as start trying write provider return environment variables public class environmentvariableprovider : iconfigurationmanagerprovider { public t getsetting<t>(string name) { string value = environment.getenvironmentvariable(name); return value t; } public ienumerable<configurationsetting> getknownsettings() { return new list<configurationsetting> { new configurationsetting("my_tracing", typeof (string)), }; } } however won't compile c...

How do I change my default browser in git's BASH shell? -

for reason, when try @ git pages, opens them in gedit instead of in chrome, how configure launch chrome again? using git's bash console in windows 7. try git config --global web.browser chrome . from manual: the web browser can specified using configuration variable help.browser, or web.browser if former not set. if none of these config variables set, git web--browse helper script (called git help) pick suitable default. see git-web--browse(1) more information this.

asp.net - Intellisense on .LESS files -

i'm introducing less existing asp.net web forms application. in order intellisense work, decided set lesscsshttphandler intercept requests files ending in .less.css . way, visual studio still thinks we're dealing css file. did adding following line web.config file: <add type="dotless.core.lesscsshttphandler, dotless.core" validate="false" path="*.less.css" verb="*" /> in order work, had tweak iis settings .css files handled asp.net framework. unfortunately, doing so, existing .css files (which aren't handled dotless http handler since don't end in .less.css ) aren't returning content. makes sense since asp.net framework doesn't know when sees file extension. is there sort of base http handler can set in addition 1 have above handle normal .css files? like: <add verb="*" path="*.css" type="insert base http handler here return contents of file" /> looks...

c# - locking static variable -

i have following class @ server-side. public class sample { private enum status { notevaluated, yes, no } private static object _lockobj = new object(); private static status _status = status.notevaluated; public static status getstatus() { if (_status == status.notevaluated) { lock (_lockobj) { if (_status == status.notevaluated) { //some evaluation code sets status either yes/no; _status = status.yes; } } } return _status; } } is wrong in locking mechanism above? need lock @ all? because server-side (multiple requests there) , variable static think should locked @ time of evaluation. correct me if wrong. thanks you not/should not have outer check "if (_status == status.notevaluated)". while appears nothing "bad" happen if left it, ...

Where to place SSL certificate for java application -

hello want generate certificate using keystore add sevrer , browse sever using ie. need steps generating certificate in plain english read in internet hard understod. server socket is: sslserversocketfactory ssf = (sslserversocketfactory)sslserversocketfactory.getdefault(); sslserversocket server = (sslserversocket)ssf.createserversocket(1234); string[] cipher = {"ssl_dh_anon_with_rc4_128_md5"}; server.setenabledciphersuites(cipher); the certificate code not sure pu in server: inputstream infil = new fileinputstream("server.cer"); certificatefactory cf = certificatefactory.getinstance("x.509"); x509certificate cert = (x509certificate)cf.generatecertificate(infil); infil.close(); keystore ks = null; ks = keystore.getinstance("jks", "sun"); inputstream = null; = new fileinputstream(new file("./keystore")); ks.load(is,"rootroot".tochararray()); see j...

sql server - Complex string match in SQL Query -

i have complex scenario string matching , want input guys. have table named customers. table contains field customername varchar. data in column prefixed mr. mrs. ms. data mr. john brady ms. abraham lenin mrs. john brady mr. michael king mrs. neil thomas mrs. micheal king now need design search query returns me rows of couples , in sequenced manner. like select customername customer ...?? result needs like mr. john brady mrs. john brady mr. michael king mrs. micheal king any idea ? thanks in advance consideration. declare @t table(name varchar(25)) insert @t values ('mr. john brady'), ('ms. abraham lenin'), ('mrs. john brady'), ('mr. michael king'), ('mrs. neil thomas'), ('mrs. michael king') ;with c ( select name, count(*) over(partition stuff(name, 1, charindex(' ', name), '')) cnt @t ) select name c cnt = 2