Posts

Showing posts from September, 2015

ruby - Trying to change last to "x"s to 23 -

i have been playing around irb , have string looks this: irb(main):072:0> puts ["[\"4354 5432 5432 xxxxx\", \"6547 6547 8543 xxxxx\", \"2344 6543 6674 xxxxx\", \"2346 6236 7543 xxxxx\", \"1273 5585 5587 xxxxx\"]"] => nil irb(main):073:0> what want gsub last 2 "x" s of each 17 digit combination, 23 . what i've tried far (i've been using rubular): a.gsub(/\d[x]/,"23") <= grabs "x" s i'm close a.gsub(/\w[x{2}]/,"23") <= grabs "x" s grabs two digits each combination. is there easier way i'm not understanding? a.gsub(/\d{4} \d{4} \d{4} xxx\kxx/, '23') \d{4} = 4 digits what \k drop matched far. can use don't replace entire number, still able validate have in desired format.

jquery - Clone last and append item to closest class -

this bare-bones code on page: <div class="list-container"> <div class="single-list-item"> <button>remove</button> </div> <div class="single-list-item"> <button>remove</button> </div> <div class="single-list-item"> <button>remove</button> </div> </div> <p><button class="add-list-item">add</button></p> <div class="list-container"> <div class="single-list-item"> <button>remove</button> </div> <div class="single-list-item"> <button>remove</button> </div> <div class="single-list-item"> <button>remove</button> </div> </div> <p><button class="add-list-item">add</button></p> <di...

javascript - Jquery bind event on element fails -

we using jquery 2.1.4 , have written out own javascript class should take care of event. simple "application". taking care of submitting form. before that, processes data. our initial method call on rendering page: owebform.prototype.init = function(){ console.log("init method called"); ... $("#submit_message").on("click", this._submit); console.log($("#submit_message")); ... } owebform.prototype._submit = function(e){ e.preventdefault(); console.log("_submit method called"); ... } once button " #submit_message " clicked, supposed call _submit method of owebform class. when looking @ element within console can see not bound anything, when page loaded. hence code not executed once button clicked. in html have following code: <script type="text/javascript"> var _owebform = new owebform("0bcfwqx23xv02dfaqfujdqyafziic4b07uxkkg1y6lkof7x0px0vjm2tp...

java - What does the following program? -

this question has answer here: is java “pass-by-reference” or “pass-by-value”? 74 answers class ideone { int x; public static void main (string[] args) throws java.lang.exception { ideone i; = new ideone(); i.x = 25; system.out.println(i.x); f(i); system.out.println(i.x); g(i); system.out.println(i.x); } public static void f(ideone j){ j = new ideone(); j.x = 55; // changes new instance of j. not changing actual object } public static void j(ideone j){ j.x = 52; // modifies actual object } } i have doubt in this. in case of j function, modifies actual object. not pass reference? passing object , modifying inside j. but doing samein function f also. passing object , modifying it. not m...

Android SDK: Show one line at a time and proceed with onClick -

i'm new java , android sdk i'm willing learn. want build app take sentence, or generic string , displays 1 line of text, coded. want proceed "next" line clicking button called "proceed". in short offers read little amount of text @ time , proceed b clicking button. this how far i've got: activity_main.xml <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".displaymessageactivity" android:orientation="horizontal" > <textview...

css - Can I use the :after pseudo-element on an input field? -

i trying use :after css pseudo-element on input field, not work. if use span , works ok. <style type="text/css"> .mystyle:after {content:url(smiley.gif);} .mystyle {color:red;} </style> this works (puts smiley after "buu!" , before "some more") <span class="mystyle">buuu!</span>a more this not work - colors somevalue in red, there no smiley. <input class="mystyle" type="text" value="somevalue"> what doing wrong? should use pseudo-selector? note: cannot add span around input , because being generated third-party control. :after , :before not supported in internet explorer 7 , under, on elements. it's not meant used on replaced elements such form elements (inputs) , image elements . in other words it's impossible pure css. however if using jquery can use $(".mystyle").after("add smiley here"); api docs on .after to ...

javascript - How to change format of the phone number? -

at time, format next phone 123-123-1123 i want have next form: (123)456-7890 how can change format whatever shape want? <input class="" type="text" name="primary_phone" id="primary_phone" maxlength="10" placeholder="1234567890"> $("#primary_phone").blur(function() { text = $(this).val().replace(/(\d{3})(\d{3})(\d{4})/, "$1-$2-$3"); $(this).val(text); }); http://jsfiddle.net/xxk3f/2864/ var phone = "123-123-1123"; var newphone = "(" + phone.replace("-", ")"); alert(newphone);

Wpf ListBox – change default selected-item style *inside* the ContentPresenter -

Image
i have listbox in each item stackpanel. stackpanel consist of image , textblock below it: <listbox.itemtemplate> <datatemplate> <stackpanel margin="10"> <image> <image.source> <bitmapimage urisource="{binding path=imagefilepath}"/> </image.source> </image> <textblock text="title" textalignment="center"/> </stackpanel> </datatemplate> </listbox.itemtemplate> it looks this: when user select item, default blue rectangle surround stackpanel: now, want make different border selected-item, want surround image . i know how make control template , put custom border around contentpresenter, this, of course, surround whole stackpanel, not image. i don’t know if making changes contentpresenter possible, , if idea @ all. if there other way achieve want...

bar chart - How to set the width within axis label in highcharts -

do know setting in hightcharts can change width marked red arrow example? please take @ image below i want set width of red arrow example you using categories, axis divided evenly between existing categories. in other words, can remove unnecessary categories, example: http://jsfiddle.net/mwqto4n6/ $('#container').highcharts({ xaxis: { categories: ["2016", "2025"] }, series: [{ type: 'column', data: [200, 120] }] });

symfony - Fetcing dynamically added fields in forms - Symfony2 -

i have data added in hidden input fields inside form. now since i'm using symfony2 forms fields don't submitted. i.e. $form->getdata() not data fields. how data dynamically added (hidden) input fields well? fetch post values in context of form type: $postdata = $request->request->get('form_name'); $name_value = $postdata['title']; fetch post values not in context of form type (maybe need): $data = $request->request->all(); $name = $data['input_name'];

php - MySQL query between two dates as timestamps -

i have been trying select items database between 2 default dates: , 60 days ago. queries try not work. here have tried: $now = date("y-m-d"); $before = date("y-m-d", strtotime("-60 days"); // try1 $sql = "select * mytable mytimestamp between " . $before . " , " . $now; // try2 $sql = "select * mytable mytimestamp >= " . $before . " , mytimestamp <= " . $now; i out of guesses of how this. have looked @ other questions same one, none of solutions presented work. please note: these queries not give errors. don't retrieve anything. have used get_defined_vars() print dates onto page. show: [now] => 2016-01-07 [before] => 2015-11-08 "please note: these queries not give errors." - " . $before . " , " . $now; , you're using 2016-01-07 , 2015-11-08 being strings , not integers . same " . $before . " , mytimestamp <= " . $no...

C++ program gives different results in Debug and Release mode -

i'm doing algorithmic exercises , encountered strange problem. wrote code below solve problem http://main.edu.pl/en/archive/oi/21/pta . tested , looks works fine in debug mode, switch release (or submit site) gives wrong answers tests. eg 9e.in (i uploaded test here: https://www.dropbox.com/s/ki4vfk2p5140xwo/pta9e.in?dl=0 ) answer debug build correct: 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 however, in release (and after submitting site) get: 543 530 530 530 530 530 543 530 530 530 543 530 530 543 530 530 530 543 530 530 543 530 530 530 530 i have no idea can causing problem :/ code: #define _crt_secure_no_warnings #include <iostream> #include <cstdlib> #include <queue> #include <cmath> #include <stdio.h> using namespace std; int numoftrees = 0; int* trees = null; int numofbirds = 0; int computebird(int birdstamina) { int tired = 0; int position = 0; int lastt...

asp.net mvc - Need Port redirection pattern for IIS Windows -

i have application running under http://localhost/testapp inside i'm making ajax call node.js app running under port 3000 i.e. http://localhost:3000 now want configure iis whenever request comes http://localhost/node wanted redirect http://localhost:3000/ example: if make request url http://localhost/node/sample want handled server redirect request http://localhost:3000/sample i tried .net installer url rewrite , tried config pattern didn't work me. guys please me out? my index.cshtml @{ viewbag.title = "index"; } <h2>this index page</h2> <script> $(function () { $.ajax({ url: "/node/sample", success: function () { alert('done'); } }); }); </script> error i'm getting below.. url redirection not happening , throws resource not found exception try out: <rewrite> <rules> <rule name="redire...

Ruby on Rails with twitter APIs -

is possible in ruby on rails update blog posts on twitter account using twitter apis , omniauth. please suggest me. more: have blog, create new post on blog, update should go twitter account tweet , tweet should shown home of blog. please suggest me. how possible. regards, vieenay siingh when post website, expecting have done background search before. anyway, should find need on rubygems website

entity framework - Dynamic database connection using Asp.net MVC and Identity2 -

i'm developing web application in asp.net mvc. application uses multiple databases. database on working on depends logged user. manage login on 2 levels: level1 on "master" database have info login username/email , "specific" database use. level2 on "specific" database manage users , roles identity2. example: in "master" database have record in user table with: - username = user1 - databasetouse = "specificdb1" in "specific" database called specificdb1, same user, have record in user table need manage user authentication , more. what want achieve is: start website, click on login, insert username , password, click on login. search username in master database, if exist specific database name associated user. set here, dynamically, connection string "specific" database , perform identity 2 login operations. no problems points 1 , 2. problem in point 3. use entityframework 6 code first both (...

show two different series with different start intervals with the same xAxis highcharts -

http://jsbin.com/enotab/39/edit i want show data 2 different years on same xaxis without using 2 x axes. in case following result i want have overlay graph 2 series 2012 series becomes shadow graph. how possible? static code: var mychart = new highcharts.chart({ chart: { renderto: 'container', zoomtype: 'x' }, title: { text: 'chart title' }, xaxis: [{ type: 'datetime', minrange: 31 * 24 * 3600000, labels: { formatter: function () { return highcharts.dateformat('%e %b %y', this.value); } } }], yaxis: { title: { text: 'current values' }, gridlinecolor: 'transparent', plotlines: [{ value: 0, color: 'green', dashstyle: 'longdashdot', width: 1 }, { value: 30, color: 'orange', dashstyle: 'longdashdot...

Matlab: Count values if signal changed for 0.1 in the last 2 seconds -

i have continuous signal rising , falling. found peaks- maxima values , locations. i wondering how write code count in case signal changed in kind of rule: amplitude exceeded 0.1 , peak occurred less 2 seconds after beginning of increase. thanks lot. a general answer be: loop through peak vector , check appropriate part of value vector smallest element: for = 1:len(peaks) peak = peaks(i,:) peak_value = peak[1] peak_time = peak[2] cut_values = values(max(1,(peak_time-2)*f):peak_time*f) if min(cut_values) < peak_value - 0.1 peak_count += 1 % or edit - adding explanation: peaks matrix (nx2) of peak values , times values signal vector f sampling frequency (hz), considered uniform edited again accomodate peaks before 2s. matlab's 1-indexing bit tricky here: sample 1 @ time 0, sample 2 @ time f . correct thing signal starts @ 0 time is: cut_values = values(max(0,(peak_time-2)*f)+1:peak_time*f+1)

why use not operation in regex function salesforce -

could of pls explain following code. why not used for? not(regex(zip_postal_code__c, "[0-9]{5}")) it looks code in validation rule. validation rules show error if result of evaluating code true. regex(zip_postal_code__c, "[0-9]{5}") evaluate true if zip code in field valid , false if value not valid cause validation throw error if zip valid. since intention throw error when zip code not valid, not() function used invert or negate result of regex() function.

php - laravel firstOrCreate not working properly? -

i importing data foursquare api. database contains multiple foursquare_id duplicates. doing wrong code here? i thought way set check database column value of foursquare_id? bar::firstorcreate([ // not check these 2 below because mandatory 'foursquare_id' => $item['venue']['id'], 'name' => $item['venue']['name'], 'postalcode' => isset($item['venue']['location']['postalcode']) ? $item['venue']['location']['postalcode'] : '', 'city' => isset($item['venue']['location']['city']) ? $item['venue']['location']['city'] : '', ]); that's right. receive 'first' if all elements of passed array exist in row object. the alternative using firstornew: $foo = bar::firstornew(['foursquare_id' => $item['venue']['id']]); // find object foursq...

java - Read mp3 tags in android application -

i use jid3lib java. when i'm working library on file stored in computer works great, when try read mp3 tags of files on emulator's sdcard got exeption. i use following code: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main_activity); file musicpath = environment.getexternalstoragepublicdirectory(environment.directory_music); file[] songs = musicpath.listfiles(); (int i=0; < songs.length; i++){ try { mp3file song = new mp3file(new file(songs[i].getpath())); log.d("test", song.getid3v1tag().getalbum() ); } catch (tagexception e) { log.d("test", "tag exception"); e.printstacktrace(); } catch (exception e) { log.d("test", "exception"); e.printstacktrace(); } } } i put 2 mp3 files in sdcard, still got exceptio...

php - get values in jquery -

i have list of results database choice accept or delete request of inscription : foreach ($data $key ) { ?> <tr> <td><?php echo $key['pseudo']; ?></td> <td><?php echo $key['email']; ?></td> <td>non valider</td> <td><button class="btn btn-success btn-sm" id="ok" data-val="<? php echo $key['id'];?>">valider</button></td> <td> <button class="btn btn-danger btn-sm" id="non" data-id="<?php echo $key['id'];?>">supprimer</button></td> </tr> <?php } ?> i want if click in button value of data-val. use code: $(function() { $('#ok').click(function(){ var t=$("#ok").attr("data-val"); alert(t); ...

From Javascript Int to a Java String -

so have variable in javascript can both string , int, need send java method. though that, since it's easier change number string instead of opposite, set variable string. i'm gonna post code this javascript, variable valore 1 can both int , string $(".save").click(function() { var valore = $("#valore").val(); var connettore = $("#connettore option:selected").text().split(" ").join(""); $.get("select"+connettore+".do", { nomecampo: $("#colonnariferim").val().tolowercase(), valore: valore }, function (data) { (var = 0; < data.connettore.length; i++) { var conn = data.connettore[i]; } } ); this java function @...

surfaceview - video is not playing with aspect ratio of device in android -

i have used surface view play video server. have used async task play view.and shown progress dialog till video prepared play in media player. doinbackground code follows. holder = mpreview.getholder(); holder.addcallback(mediaplayerdemo_video.this); holder.settype(surfaceholder.surface_type_push_buffers); every thing perfect problem video not playing in proper size, means small in big resolution device.how set size of surface view defined in oncreate() , rest code given async task.

python - Beautiful Soup if Class "Contains" or Regex? -

if class names different example: listing-col-line-3-11 dpt 41 listing-col-block-1-22 dpt 41 listing-col-line-4-13 cwk 12 normally do: for eachpart in soup.find_all("div", {"class" : "classnameshere"}): print eachpart.get_text() there way many class names work here bunch of these out. i know python doesn't have ".contains" use have "in". though haven't been able work out way incorporate that. i'm hoping there's way regex. though again python syntax letting me down i've been trying variations on: regex = re.compile('.*listing-col-.*') eachpart in soup.find_all(regex): but doesn't seem doing trick. beautifulsoup supports css selectors allow select elements based on content of particular attributes. includes selector *= contains. the following return div elements class attribute containing text 'listing-col-': for eachpart in soup.select('div[c...

Dropdown select in Capybara with no id? -

so have few dropdowns im making automated test cases (just checking make sure links work , go right location. easy test cases toss in there) but don't have id's or work with: here outer html of dropdown text click (which reveals more dropdowns). <a href="#" data-toggle="dropdown"><i class="glyphicon glyphicon-list-alt"></i> main dropdown <b class="caret"></b></a> the rest of items listed this: <li><a href="/quotes"><i class="glyphicon glyphicon-list"></i> option 1</a></li> would make more sense try use clickable text click on "main dropdown" text , clickable text click on "option 1" (names changed concept still same). since that's html in there? capybaras link finder finds link elements id, text, title or contained images alt attribute. html provided best best text - so click_link('main drop...

c# - asp.net with oracle connectivity issue -

i trying add parameters using oracle database using following code : for (int = 1; <= count; i++) { var parametername = ":ref_cur" + i; dbparameter parameter = acidaes.data.dbhelper.createrefcursorparameter( parametername, parameterdirection.output); command.parameters.add(parameter); } following crash occurs while adding parameters [a]oracle.dataaccess.client.oracleparameter cannot cast [b]oracle.dataaccess.client.oracleparameter. type originates 'oracle.dataaccess, version=2.112.2.0, culture=neutral, publickeytoken=89b483f429c47342' in context 'default' @ location 'c:\windows\assembly\gac_32\oracle.dataaccess\2.112.2.0__89b483f429c47342\oracle.dataaccess.dll'. type b originates 'oracle.dataaccess, version=4.112.2.0, culture=neutral, publickeytoken=89b483f429c47342' in context 'default' @ location 'c:\windows\microsoft.net\assembly\gac_32\oracle.dataaccess\v4.0_4.112.2.0__89b483f429c4734...

How can I archive a directory in Perl -

i'm trying archive directory subdirectory , files. below code doesnt work properly. archived files , folders, not content of folders ! how can solve ? my @files = glob( $backup_path.'website/*' ); $tar = archive::tar->new(); $tar->add_files(@files); $date = datetime->now(time_zone=>"local"); $tar->write($backup_path.$websitefoldername."/".$date->dmy('-')."-".$websitefoldername.".tar"); glob ( perldoc ) not recurse subdirectories. need take care of or use module file::find : use archive::tar; use file::find qw(find); @files; find( { wanted => sub { push @files, $file::find::name } }, $backup_path.'website'); $tar = archive::tar->new(); $tar->add_files( @files ); $date = datetime->now(time_zone=>"local"); $tar->write($backup_path.$websitefoldername."/".$date->dmy('-')."-".$websitefoldername.".tar");

Branch.io deeplinking not working on Ionic simulator -

i have set branch.io account , trying deep link website ionic app. app url sampleapp://. when go webpage simulator, has_app on branch.init() set true, seems sees app, doesn't open it. if create normal href sampleapp:// open app. not sure how fix this. couldn't work on simulator, built on xcode, put on device , deep link working.

java - Get list of all names in content provider -

i'm using "calls.content_uri" content provider. retrived column names, let's say, names column name "name" in content provider. i have code below: uri = calls.content_uri; string[] projection = {"name"}; string selection = null; string[] selectionargs = null; string sort = null; resolver = getcontentresolver(); cursor = resolver.query(uri, projection, selection, selectionargs, sort); log.i("tutorial", "counts :"+cursor.getcount()); string s; cursor.movetofirst(); for(int x=0; x<cursor.getcount(); x++){ s = cursor.getstring(x); log.i("tutorial", ""+s); //cursor.movetonext(); } but retrives 1 name. have list of names saved in phone like: john peter mark suzy . . x but got 1 name like: peter. hope i've been clear enough. what's problem? in advance. i think you arraylist<string> ...

java - apache poi - reading comments from blank and missing (null) cells -

i'm trying read comments excel documents cell's (using apache poi). have problem when empty (or missing) cells contains comments. currently solutions found to: iterate every row last not empty column get (even empty) cells check if cell's comment not empty if true: handle comment some code: if (row != null) { cell = row.getcell(cellnum, row.create_null_as_blank); cellcomment = cell.getcellcomment(); if (cellcomment != null) ... } main problems can't read comments empty lines , comments after last not empty cell. increasing performance (comparing reading row cells) nice, main point read documents comments. you can read comments of blank cell or null cell using missingcellpolicy, row.getcell(int cellnum, missingcellpolicy policy) allows deal cells blank or null. for example in sheet, 7th row blank , 5th col have comment (say "hello"), , need read comment. following: comment comment = sheet.getrow(7).getcell(5, row.crea...

jsf 2 - Display html files uploaded by users -

i writing application users can upload zip file contains html files. how can show html files in jsf views? i using wildlfy , upload files , unzip them folder in wildfly standalone/data directory. zip files contains file contains html menu, folder containing html files (which html documents containing divs). right now, in jsf view, display link uploaded folder. when user clicks on link, index.html file of folder displayed. i like, however, able incorporate html menu jsf view , display html files in jsf view when link pointing them clicked. also, html menu includes text input field want use full text search in uploaded html files. so need able value of text field in backing bean. should use <iframe src="#{bean.iframeurl}"></iframe> or there better solution? so in essence: can incorporate uploaded files jsf views , communicate between uploaded html files , backing beans? edit according kukeltje's comment , post think need to this: in...

node.js - getting date in nodejs -

here iam uploading excel file(xslx format) using nodejs.in iam passing dates dd-mm-yy .after uploading response has showing different date means in milliseconds think so.then how our date value xlsx excel using nodejs thanks. node.js javascript environment. that, if have milliseconds, can do var mydate = new date(1452188743178); console.log(mydate); // thu jan 07 2016 18:45:43 gmt+0100 mydate standard javascript date object .

python - Defensive conditions when JSON field is missing in API -

i developing small python script in order weather data forecast.io once json document, call class in order create new record saved in database. problem fields (which attributes in class) not informed in api must include kind of defensive code or script break when field not found. i've found answer of @alex martelli seams pretty good: reading python dict if key might not present if want different using default value (say, skip printing when key absent), need bit more structure, i.e., either: for r in results: if 'key_name' in r: print r['key_name'] or for r in results: try: print r['key_name'] except keyerror: pass but wondering if must include "if" or "try" on every field want save or there prettier way this? (i want save 27 fields , 27 "if" seems ugly) this code have far: from datetime import datetime import tornado.web import tornado.httpclient tornado import gen src.db.ci...

ios - Protocol for adjusting UINavigationController -

in every 1 of view controllers i'm calling function edits appearance of navigation controller , text of left/right buttons. instead of having code in every view controller, i'm trying implement protocol each view controller conforms to. current code in every view controller: func setupnavreg(backbuttontext: string, nextbuttontext: string) { self.navigationcontroller!.navigationbar.bartintcolor = uicolor.whitecolor() self.navigationcontroller?.navigationbar.setbackgroundimage(uiimage(), forbarmetrics: uibarmetrics.default) let leftnavbutton = uibarbuttonitem(title: backbuttontext, style: .plain, target: self, action: selector("backbuttonpressed")) let customfont = uifont(name: "gill sans", size: 14.0) leftnavbutton.settitletextattributes([nsfontattributename:customfont!], forstate: uicontrolstate.normal) self.navigationitem.leftbarbuttonitem = leftnavbutton //nextbutton left out } protocol design protocol navba...

navbar - Bootstrap dropdowns doesn't work -

so in navbar i've 2 dropdowns. 1 when looking @ site on mobile other dropdown. these don't work. i've looked 2 hours solution nothing yet... <!doctype html> <html lang="en"> <head> <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1.0"> <title>index</title> <script src="scripts/jquery.js"></script> <script src="scripts\bootstrap.js"></script> <link href="css\bootstrap.css" rel="stylesheet"> <link href="styles\main.css rel="stylesheet"> </head> <body> <!--aanmaken van een navigatiebar --> <div class="navbar navbar-default navbar-static-top"> <div class="container"> <a href="#" class="navbar-brand">van beeck telecom</a> <button t...

asp.net mvc 4 - Catch 404 Error in MVC4 -

i have problem cacting http error 404.0 - not found. have turned on <customerrors mode="on" defaultredirect="~/error/general"> <error statuscode="404" redirect="~/error/httperror404" /> <error statuscode="500" redirect="~/error/httperror500" /> </customerrors> in web.config. problem still exist. have tried solution( never reaches method): protected void application_error() { var exception = server.getlasterror(); var httpexception = exception httpexception; response.clear(); server.clearerror(); var routedata = new routedata(); routedata.values["controller"] = "errors"; routedata.values["action"] = "general"; routedata.values["exception"] = exception; response.statuscode = 500; if (httpexception != null) { response.statuscode = httpexception.gethttpco...

How to ensure that my response from server has `Content-Length` header with PHP? -

this how response server: include('../connection.php'); connection(); mysql_query('set names utf8'); $response = array(); $words = array(); $query = "select * `$table` order `created_at` desc"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $row['id'] = intval($row['id']); array_push($words, $row); } $response['words'] = $words; echo json_encode($response); but need here content-length header. how can check or add/create such header? php handles if enable output buffeting. when write output stream (via buffer) php knows how you've written , sets header value before sending response body.

html - How to prevent ░ or ▀ changing to &#9617,etc? -

i trying add in source code of page inside comment. however,when save,the characters change http://img.ctrlv.in/5134b28e330fa.jpg to http://img.ctrlv.in/5134b28e7a5b0.jpg i tried encoding characters,but in vain.they still change. is there trick prevent them changing?thanks lot no. you @ mercy of blogger's template processor.

linux - Shell script substring extraction and manipulation -

i able extract substring string; no matter syntax changes try (and i've tried many), unable enter if block in snippet though print out suggests client_name string matches expected 1 (attached output first echo ). first echo prints anything. doing wrong here? ideas appreciated! the idea if client named aa_nnnn , need extract aa , nnnn , check if aa matches known string (say " xx ") , if does, then, calculate version nnnn , if version nnnn exceeds known version mmmm . #! /bin/sh client=$1 ... client_name="${client:0:2}" client_version=2015 echo "before compare; client: $client_name; version: $client_version" if [ "$client_name" == "xx" ]; client_version="${client:3:4}" echo "inside compare; client: $client_name; version: $client_version" if [ $client_version -ge 2016 ]; ... fi fi first echo output: before compare; client: xx; version: 2015 /bin/sh --version returns: gnu ba...

JavaScript - AngularJS promise not returning anything -

i trying return simple http post on unit test jasmine seems not work. application works fine on web. have tested several isolated functions. won't work. describe('service: auth',function(){ beforeeach(function () { module('ui.router'); module('main'); module('users'); }); var authfactory, httpbackend; beforeeach(inject(function($httpbackend, _authfactory_) { httpbackend = $httpbackend; authfactory = _authfactory_; })); it('should return post', function() { authfactory.signin({inputuser: {username: "admin"}, passinput: {password: "adminpass"}}).then( function(result) { console.log('======== success ========'); console.log(result); }, function(err) { console.log('======== error ========'); console.log(err); }, ...

c - GAUT HLS tool error : "No alternatives to process, unable to select best one" -

i trying synthetise following c code using gaut tool: #define n 16 int main (const int tab[n], int* out) { // static const int tab[n] = {98,-39,-327,439,950,-2097,-1674,9883,9883,-1674,-2097,950,439,-327,-39,98}; int k = 0, i=1; for( = 1; < n; i++) { // invariant : k est l'indice du plus petit // élément de x[0..i-1] if(tab[i] < tab[k]) k = i; } *out = tab[k]; return 0; } simple program find minimum in array. compiles, generates dfg seems honest. when try synthetise, error: "no alternatives process, unable select best one" , can't go on implementation flow. does know problem? facing other such small test programs well. hope specialist able answer. thank you. since tagged vhdl, perhaps it's worth looking @ straight vhdl port, bypassing tool completely. took few minutes, , it's in 3 parts: 1) vhdl has quirk in use array port parameter, must named type (int_array). (c has di...

osx - Why Chrome Canary Always Open Chrome Stable? (os x) -

always when open canary, opens chrome stable!! can't have canary running without chrome stable opened. if quit chrome stable, canary keeps opening it!! it's annoying. i could't figure out setting disable that. it's normal? how can disable this? i'm using os x mountain lion. i found it! problem rescue time. if disable it, problem don't happens. this bug have been reported time ago

ecmascript 6 - Getting gulp and es6 set up to reload on saves -

i have been playing gulp , babel past few days. getting solid grasp of setting babel gulp through tutorials. i've noticed newer tutorial more changes develop. here 1 way able set es6 es5 transpiler. var gulp = require('gulp'); var babel = require('gulp-babel'); gulp.task('es6to5', function () { return gulp.src('js/src/app.js') .pipe(babel()) .pipe(gulp.dest('dist')); }); however, not want rerun gulp each time, , want dist/ folder update on each save. i added browser-sync , delete. var gulp = require('gulp'); var babel = require('gulp-babel'); var browsersync = require('browser-sync'); var del = require('del'); gulp.task('clean:dist', function() { return del([ 'dist/app.js' ]); }); gulp.task('es6to5', function () { return gulp.src('js/src/app.js') .pipe(babel()) .pipe(gulp.dest('dist')); }); gulp.ta...

c# - Context and Context Initializer Not Running -

i'm attempting code first development on mvc site , although global.ascx file running code make new initializer, initializer isn't being run. i've placed breakpoint on both start of context , initializer , both not being hit. global.ascx database.setinitializer<abstractcontext>(new abstractcontextinitializer()); context: using system; using system.collections.generic; using system.data.entity; using system.linq; using system.web; namespace abstractthinking2015.models { public class abstractcontext : dbcontext { public dbset<blogmodel> blogs { get; set; } } } initializer: using system; using system.collections.generic; using system.data.entity; using system.linq; using system.web; namespace abstractthinking2015.models { public class abstractcontextinitializer : dropcreatedatabasealways<abstractcontext> { protected override void seed(abstractcontext context) { context.blogs.ad...