Posts

javascript - Find array count of fields using lodash or underscorejs -

i have requirement count of each account type in array. have tried normal way of looping array , increment counter each account_type. please me same in lodash or underscore js . your appreciated. thank you. input_array = [ { account_id: '4304bf0381140b8fcccbdddea3571a53facebook', account_type: 'facebook' }, { account_id: '4304bf0381140b8fcccbdddea332434facebook', account_type: 'facebook' }, { account_id: '5824fb40c4a97e21ef9715ea69c1cfb9twitter', account_type: 'twitter' }, { account_id: '5824fb40c4a97e21ef9715ea432423twitter', account_type: 'twitter' }, { account_id: '2c13790be20a06a35da629c71e548afexing', account_type: 'xing' }, { account_id: 'd1376b07b144130c4f041e223dfb1197weibo', account_type: 'weibo' }, { account_id: 'd...

prolog - Swapping a specific number in list 1 with a specific number in list 2 -

i have been brushing on prolog recently. kind of enjoy coming random problems try , solve , working them out. 1 quite tough though, , i'm not 1 give on problem have set out solve. the problem: want make predicate have 2 predetermined lists, 2 numbers swap, , output lists after swapping done. further explanation: made little harder on myself wanting find specific unique number list 1, , swapping specific unique number list 2 if have 2 lists... [7,2,7,8,5], , [1,2,3,8,7,9,8], , give predicate 2 numbers(lets 8 , 7), number 8 , number 7 swapped between lists if , if number 8 in first list , number 7 in second list. (it disregard 8 in second list , 7 in first list). sample query expected answer: ?- bothswap([7,2,7,8,5],[1,2,3,8,7,9,8],8,7,x,y). x = [7,2,7,7,5], y = [1,2,3,8,8,9,8]. i kind of got stuck @ point: bothswap([],l2,n1,n2,[],l2). bothswap(l1,[],n1,n2,l1,[]). bothswap([h1|t1],[h2|t2],n1,n2,x,y) :- h1 == n1, h2 == n2, bothswap(t1,t2,n1,n2,d1,d2), append(d1,[h2]...

Adding CSS using function in PHP -

i try add css file html file using statistic function this: public static function addcss($file){ $csspath = $_server['document_root']. directory_separator. 'new'. directory_separator. 'css/'.$file; return file_exists($csspath) ? " <link rel=\"stylesheet\" href=\"$csspath\" type=\"text/css\" media=\"screen\" charset=\"utf-8\" /> " : "css file not found"; } but doesn't work expected. want produce csspath "http:localhost/new/css/admin.css when i'm called using general::addcss('admin.css'); got address make me fail include: c:/xampp/htdocs\new\css/admin.css. how can fix addressing? you using xampp, document root path "server". thats why path wrong. need exclusively specify path want, until move server. also, if using shared hosting plan, document root not work of time. set constant ...

javascript - Can't cllick submit button -

i'm newb trying learn create form page. can tell me why submit button isn't working? thought having javascript function fix this. thanks <script type="text/javascript"> function submitform() { document.forms["contactform"].submit(); } </head> <body> <div id="contact-form"> <form method="post" id="contactform" action="bespoke-form-handler.php"> <div> <label for="name">name:</label> <input type="text" id="name" name="user_name" /> </div> <div> <label for="mail">e-mail:</label> <input type="email" id="mail" name="user_e...

php - HTTPS returns plain text including headers -

during setting our production environment encounter wierd error, when trying curl through our server, returns plain text representation of response including http headers request on ssl. date: fri, 19 jun 2015 02:15:00 gmt content-type: text/html content-length: 70619 last-modified: thu, 18 jun 2015 05:30:30 gmt connection: keep-alive etag: "55825776-113db" accept-ranges: bytes <!doctype html> <html lang="en-us"> <head> , on... any ideas on how fix this? set curlopt_header false in curl_setopt so: curl_setopt($ch, curlopt_header, false); curlopt_header - true include header in output. ( ref )

java - SBT- Copy File to Output Classes -

i have persistence.xml file in 1 of packages (the file mixed sources) i want copied to: target -> scala-2.11 -> classes -> persistence.xml how can sbt? would consider adding file under src/main/resources ? resource copied target/scala-*/classes/ .

php - Creating a centric REST API for a mobile and website application -

my next project requires me develop both mobile , website application. avoid duplicating code, i'm thinking creating api both of these applications use. my questions regarding are: is approach sensible? are there frameworks me this? how handle authentication? does have affect on scalability? the answers questions - yes possible , in fact makes perfect sense me. yep. using django web , djano-rest-framework rest api. both in same project , share same model , querysets . web url normal , api url starts /api for web use normal session based authentication, rest api use token authentication so far no. both web , api works me. deployed in 3 production environment. links - django django-rest-framework