Posts

Showing posts from June, 2012

javascript - How to force https redirect on heroku with express 4.0? -

i don't understand why following code not accomplish this? can explain going wrong? http requests should redirected https on heroku, not on localhost. if point me example of working appreciate it. feel should simple , straightforward. var app = express(); var https_redirect = function () { return function(req, res, next) { if(process.env.node_env === 'production'){ if(req.headers['x-forwarded-proto'] != 'https') { return res.redirect('https://' + req.headers.host + req.url); } else { return next(); } } else { return next(); } }; }; app.use(https_redirect()); var server = app.listen(config.port, config.ip, function () { }); exports = module.exports = app; i did searching , looks have should work. your middleware's req, res, next params being lost having been wrapped outer function. try this: var https_redirect = function(req, res, next) { if (process.env.node_env

vb.net - Unhandled exception of type 'System.Data.OleDb.OleDbException' occured in System.Data.dll -

i'm getting error in code, designed create records in access database, can't seem work out why. option explicit on option strict on imports system.data.oledb 'name: customercontroller.vb 'description: class acting intermediary between customer form , customer table ' contains of crud business logic 'author: alastair mcintyre 'date: 12/04/2015 public class customercontroller public const connection_string string = "provider=microsoft.ace.oledb.12.0;data source=assignment 1.accdb" public function insertcustomer(byval htcustomer hashtable) integer dim oconnection oledbconnection = new oledbconnection(connection_string) dim inumrows integer try debug.print("connection string: " & oconnection.connectionstring) oconnection.open() dim ocommand oledbcommand = new oledbcommand ocommand.connection = oconnection

uitableview - Understanding iOS Subclassing -

i working on building application contains couple of uiviewcontroller s uitableview in each. each table view contain custom cell have created subclass of uitableviewcell . since 2 view controllers similar in appearance , functionality, created base class of uitableview others inherit shared properties , methods from. however, unsure of how structure delegate , data source methods within each. example, want custom cells have actions available when user swipes right-to-left, , cells in both view controllers have same actions. code adding actions custom table view cells being implemented in each of view controllers: // enable default swipe-to-delete functionality of cells func tableview(tableview: uitableview, commiteditingstyle editingstyle: uitableviewcelleditingstyle, forrowatindexpath indexpath: nsindexpath) { } func tableview(tableview: uitableview, editactionsforrowatindexpath indexpath: nsindexpath) -> [anyobject]? { var likeaction = uitableviewrowaction(st

android - ShowCase View with fragments -

i'm trying intro tutorial android aplication uses view pager fragments pager adapter , things don't work fragments. i'm using library: https://github.com/amlcurran/showcaseview t1 = new viewtarget(r.id.btngenerate, getactivity()); t2 = new viewtarget(r.id.cbfavorito, getactivity()); t3 = new viewtarget(r.id.txtresult, getactivity()); view.post(new runnable() { @override public void run() { if(isadded()) { showcaseview = new showcaseview.builder(getactivity()) .settarget(target.none) .setcontenttitle("tutorial") .setcontenttext("aprenda como usar o aplicativo") .build(); showcaseview.setbuttontext("next"); showcaseview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) {

c# - @Html.DisplayFor changed to @Html.EditorFor when the Edit link is clicked for inline editing of row of data -

in default mvc project vs2013, when data displayed in table there options edit | delete | details. when edit link clicked, row of data rendered on page editing. but i've change label textbox when @html.actionlink edit clicked i.e change @html.displayfor @html.editorfor . how can that? i trying edit the data in row without rendering page. //<table class="table"> @foreach (var item in model) { <tr> <td> @html.displayfor(modelitem => item.student) </td> <td> @html.displayfor(modelitem => item.course) </td> <td> @html.actionlink("edit", "edit", new { id = item.id }) | @html.actionlink("details", "details", new { id = item.id }) | @html.actionlink("delete", "delete", new { id = item.id }) </t

Get Facebook User ID OnMapLongClickListener android -

i want pass via intent facebook id, in google map. i have onmaplongclicklistener latlng , pass via intent, , want pass facebook user id too...how can this? onmaplongclicklistener googlemap.setonmaplongclicklistener(new googlemap.onmaplongclicklistener() { @override public void onmaplongclick(final latlng latlng) { intent intent = new intent(mainactivity.this,newevent.class); latlng posicao = latlng; latlng posicao1 = latlng; intent.putextra("posicao", posicao); bundle args = new bundle(); args.putparcelable("posicao1", posicao1); intent.putextra("bundle", args); startactivity(intent); } }); i retrieve facebook id in method // methods facebook public void onsessionstatechanged(final session session, sessionstate state, exception exception){ if(session != null && session.isopened()){ toast.maketex

css - Dreamweaver CS6 Fluid Grid: width fixed with padding -

i new dreamweaver fluid grid. set width 100% , change margins 0. when add padding, begins scroll right. want use padding because want have border of space around text/image.i want width stay fixed. please give me solutions. in advance. the padding getting added width. fix add .css file html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } this make padding occur within width rather adding it https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/

java - How to extract String using AutoCompleteTextView? -

i know there multiple posts in stackoverflow addressing query. however, reason still failing extract string autocompletetextview . tried using onitemclicklistener purpose. unable identify going wrong. the code : @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); ... addpurchaseitemname = (autocompletetextview) findviewbyid(r.id.addpurchaseproductname); vivzhelper = new vivzdatabaseadapter(this); string[] autocompletename = vivzhelper.getinventorynamefilterbysuppliername(vivzhelper.getsupplierid(param1)); arrayadapter<string> nameadapter = new arrayadapter<>(this, android.r.layout.simple_list_item_1, autocompletename); addpurchaseitemname.setthreshold(1);// starts working first char addpurchaseitemname.setadapter(nameadapter); addpurchaseitemname.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> arg0, view

Meteor: How to use your own mailer template? -

hi guys have method follow: meteor.methods({ sendemail: function (to, from, name, text) { if (meteor.isserver) { return meteor.mandrill.send({ to: to, from: from, name: name, text: text }); } } }); this method called in contact.js (the html view contact.html): if (meteor.isclient) { // code runs on client template.contact.events({ "click .btn": function(event) { var = document.getelementbyid('from').value; var name = document.getelementbyid('name').value; var text = document.getelementbyid('message').value; meteor.call('sendemail', 'lolotutu@gmail.com', from, name, text); } }); template.contact.helpers({ test: "working" }); everything work fine, have no control on template used send mail. using mandrill here , know how tell sendemail method serve custom template sent people. maybe session.s

r - Input must be grobs Erorr when using do.call() -

i trying create 4 parallel coordinate plots big figure. below toy data make reproducible has no particular meaning other mimicking real data of meaning. library(ggally) library(gridextra) library(ggplot2) cnum=4 x = data.frame(a=2*runif(100)-1,b=2*runif(100)-1,c=2*runif(100)-1,d=2*runif(100)-1,e=2*runif(100)-1) plot_i = vector("list", length=cnum) (i in 1:4){ x = x + plot_i[[i]] = ggparcoord(x, columns=1:5, alphalines=0.5) do.call("grid.arrange", c(plot_i, ncol=1)) } here, seems error occurs on first iteration of do.call part. error: error in arrangegrob(..., as.table = as.table, clip = clip, main = main, : input must grobs! i see well-searched error, although solution seems dependent on context. instance, here, user misused ncol ( error grid.arrange:input must grobs ) not seem situation. thank you...

javascript - Ng-repeat isn't reading from the scope? -

i work angular & ng-repeat @ work, why perplexed why won't render. it's silly i'm overlooking, i've spent enough time on it merits asking else hint. the relevant bits: js .controller('listctrl', function($scope, dataapi){ dataapi.getindex().then(function(res) { console.log('server response', res); $scope.notes = res; }); jade h1 hello list div(ng-controller='listctrl') div(ng-repeat='note in notes') div {{ note.dist_path }} the console log of data loaded (array of objects) server response [object, object, object, object] no errors in console. inspect scope, , see expect. object of arrays. the problem dataapi method getindex using external library (q) resolve request, rather leaving angular's $http , $q . needed call $scope.$apply() after setting scope variable alert angular of change. or use angular's built in $q or work promise returned $http .

publish - Safari Extension available via a web server -

i working on safari extension , want publish extension on website. using following code user able download .safarixtz file , install it:- <%string filename = "<safariextz file path>" ; response.setcontenttype("application/octet-stream safariextz"); string disheader = "attachment;filename=test-safari.safariextz"; response.setheader("content-disposition", disheader); // transfer file byte-by-byte response object file filetodownload = new file(filename); response.setcontentlength((int) filetodownload.length()); fileinputstream fileinputstream = new fileinputstream(filetodownload); int = 0; while ((i = fileinputstream.read()) != -1) { out.write(i); } fileinputstream.close();%> but resulting file can not installed on safari browser , throwing error:- safari can't install extension error occurred while installing extension i want installation start moment user click on install link in apple gallery. thanks

C# Upload file with no extension -

i have got following code, need upload multiple files don't have extension/type assigned them. following code below works, not on these files it's trying make file example called: ftp.server/file here code: using system; using system.collections.generic; using system.linq; using system.text; using system.io; using system.net; using system.threading.tasks; namespace consoleapplication1 { class program { static void main(string[] args) { string sourcefilepath = @"path"; // e.g. “d:/test.docx” string ftpurl = @"ftp"; // e.g. ftp://serverip/foldername/foldername string ftpusername = @"user"; // e.g. username string ftppassword = @"pass"; // e.g. password string[] filepaths = directory.getfiles(sourcefilepath); // object used communicate server. foreach (string filename in filepaths) { ftpwebrequest

java code to print alternate prime numbers in reverse order -

the following java code print 'n' prime no.s want modify such can print alternate prime numbers in reverse order. import java.util.scanner; class primenumberdemo { public static void main(string args[]) { int n; int status = 1; int num = 3; //for capturing value of n scanner scanner = new scanner(system.in); system.out.println("enter value of n:"); //the entered value stored in var n n = scanner.nextint(); if (n >= 1) { system.out.println("first "+n+" prime numbers are:"); //2 known prime number system.out.println(2); } ( int = 2 ; <=n ; ) { ( int j = 2 ; j <= math.sqrt(num) ; j++ ) { if ( num%j == 0 ) { status = 0; break; } } if ( status != 0 ) { system.out.println(num); i++; }

python - Efficient time series data extract -

i have problem in python not sure how solve efficient. have large set of time series data read in generator. of now, when call yield, each data given me 1 one. fine when each time series have same index, each start on same date , end on same date. problem when have set of time series data not have same start date, same end date. what best implementation whereby when query, return values specific date. way not have worry start date. point in time. i use pandas , have no clue how implement efficiently. code use import csv file file: def _open_convert_csv_files(self): comb_index = none s in self.symbol_list: print s # load csv file no header information, indexed on date self.symbol_data[s] = pd.io.parsers.read_csv( os.path.join(self.csv_dir, '%s.csv' % s), header=0, index_col=0, parse_dates=true, names=['date','open',

c++ - Why can templates only be implemented in the header file? -

quote the c++ standard library: tutorial , handbook : the portable way of using templates @ moment implement them in header files using inline functions. why this? (clarification: header files not only portable solution. convenient portable solution.) it not necessary put implementation in header file, see alternative solution @ end of answer. anyway, reason code failing that, when instantiating template, compiler creates new class given template argument. example: template<typename t> struct foo { t bar; void dosomething(t param) {/* stuff using t */} }; // somewhere in .cpp foo<int> f; when reading line, compiler create new class (let's call fooint ), equivalent following: struct fooint { int bar; void dosomething(int param) {/* stuff using int */} } consequently, compiler needs have access implementation of methods, instantiate them template argument (in case int ). if these implementations not in header, wouldn

jQuery / Javascript boolean -

i have piece of code working user can choose download "slice" of pie chart or whole thing. when click on slice, send variable called source tells me slice came from. right working on "download all" button. source all . this loop looks if user selects slice : // loop on our data $.each(seed.dataset,function(key, value){ if(this[col] == slice){ table += '<tr>'; table += '<td>'+this.escalationid+'</td>'; table += '<td>'+this.escreasonid+'</td>'; table += '<td>'+this.reasontext+'</td>'; table += '<td>'+this.esccreatedby+'</td>'; table += '<td>'+this.esccreatorfirst+'</td>'; table += '<td>'+this.esccreatorlast+'</td>'; table += '</tr>'; } }); the if statement within loop controls data including in table variabl

asp.net mvc 4 - Including logo when sending email via postal -

in mvc4 application, using postal package sending emails. i trying include logo via <img> tag, it's not working. how can include company logo? controller action : public actionresult index() { dynamic email = new email("example"); email.to = "xxxxx@xxxxxx"; email.funnylink = "haiii"; email.send(); return view(); } view : to: @viewbag.to from: lolcats@website.com subject: important message <div style="background-color:aqua;"> hello, wanted important web links right? check out this: @viewbag.funnylink <br /> <img src="~/images/logo.png" /> </div> you need use full absolute image urls this- <img src="@request.url.getleftpart(uripartial.authority)/images/logo.png" /> or if you're having html based files should send domain name other data you're passing view this- <img src=&quo

cannot resolve symbol OnClickListener while making a button to navigate in Android Studio -

i'm trying make simple button switches between 2 activites i'm having several problems. my code entire mainactivity follows: package com.example.project.arithmeticalarm; import android.content.intent; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.widget.button; import android.view.view; import android.view.view.onclicklistener; public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on

makefile - unrecognized command line option '-std=c++11' using mitlm -

after using make command following error occurs. followed page mac error: undefined symbols architecture x86_64 , not solve that. - cc1plus: error: unrecognized command line option '-std=c++11' -cc1plus: error: unrecognized command line option '-std=c++11' -cc1plus: error: unrecognized command line option '-stdlib=libc++' -make[1]: *** [src/util/commandoptions.lo] error 1 -make[1]: leaving directory `/home/saddam/softwareforsphinx/mit-language-modeling-toolkit'`enter code here` make: *** [all-recursive] error 1``

javascript - Meteor + Bootstrap - Alert closed.bs.alert does not trigger -

i'm using meteor , bootstrap, nemo64:bootstrap package. in custom.bootstrap.json have "alerts" , "alert" on. i'm trying capture closed.bs.alert event in template events. reason, won't capture. template.alert.events({ 'closed.bs.alert .alert': function () { console.log('closed'); // not trigger } }); oddly, close.bs.alert work: template.alert.events({ 'close.bs.alert .alert': function () { console.log('closed'); // triggers } }); also, if add event via jquery, can capture closed.bs.alert : $('.alert').on('closed.bs.alert', function () { console.log('closed'); // triggers }); so, know have events formatted correctly , know closed.bs.alert event triggering... reason can't catch template.alert.events. any ideas? i dove in bootstrap code , found triggered event: alert.js, line 50 first, technique got work: templates.alert.onre

scala - Spark shell error : ERROR SparkDeploySchedulerBackend: Asked to remove non-existent executor 11 -

whenever start spark-shell on mapr sandbox keep on getting error error sparkdeployschedulerbackend: asked remove non-existent executor 11 please me solve error. use hostname command find host-name , use command bin/spark-shell --master spark://your-host-name:7077

python - 'numpy.int64' object has no attribute 'pop' -

error 'numpy.int64' object has no attribute 'pop' code fragment for index, row in dataframe_output.iterrows(): print(index) molecule = index.pop() how fix this?

php - installing composer on a shared host -

i trying install composer on shared host first time. when run curl -ss https://getcomposer.org/installer | php getting composer installed user it: php composer.phar when run php composer.phar getting warring error: warning: composer should invoked via cli version of php, not cgi-fcgi sapi any ideas on how fix ? , why getting error ? :( when run php -v back php 5.4.39 (cgi-fcgi) (built: mar 25 2015 14:20:20) copyright (c) 1997-2014 php group zend engine v2.4.0, copyright (c) 1998-2014 zend technologies zend guard loader v3.3, copyright (c) 1998-2013, zend technologies do need run using cli version if how ? any nice thank you. i resolved explicitly calling version of php asked for. keep in mind on shared server environment there multiple versions of php running , though may have set default in cpanel config, bash commands resolve (lower) version. first, created bin directory , moved composer.phar it. then, added alias .bash_profile , worked

javascript - how to decode nested json in php -

i having json string like: [ { "message": "test+sms", "sender": "test", "billcredit": "0.00", "messagestatus": "dnd", "sendondate": "2015-04-22 15:22:00", "provider": "aaaa" }, { "message": "test+sms", "sender": "test", "billcredit": "0.00", "messagestatus": "dnd", "sendondate": "2015-04-22 15:22:00", "provider": "aaa" }, { "message": "test+sms", "sender": "test", "billcredit": "1.00", "messagestatus": "delivrd", "sendondate": "2015-04-22 15:22:00", "provider": "aaaa" }, { "message": "test+sms", "sender": "test&qu

PHP Availability"[]\ Query with mySQL -

this first php application i've ever made; started learning php week, don't kill me, ok? ;) i'm trying use script find djs in our database available. reason, when manually enter region like: 'regions' \'tn_tricities\' it returns results, when enter like: $region = 'tn_tricities' ... `regions` \'$region\' it doesn't return results. idea how fix this? or if i'm totally going in wrong direction , not best way check availability, please let me know! the full code: $region = $_get['region']; $date = $_get['date']; require "connect.php"; echo $region; $sql = 'select `vendorname`, `vendorbio`, `vendortype`, `regions` `vendors` `regions` \'$region\' , `datesbooked` not \'$date\' , `datesunavailable` not \'$date\' '; try one, $region = $_get['region']; $date = $_get['date']; require "connect.php"; echo $region; $sql =

asp.net - how to add footer row dynamically for every 10 records in gridview using c#.net -

i trying break gridview rows fro every 10 records in gridview.it working fine 1 more thing need. 10 records need add footer row , have calculate sum of 10 rows in grid view . this code breaking grid view... protected void gvpartywisereport_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { tempcounter = tempcounter + 1; if (tempcounter== 10) { e.row.attributes.add("style", "page-break-after: always;"); } } } please body me in way. in advance. in opinion - easiest way manipulate back-end data-set or data-source grid bound rather creating , inserting footer row in rowdatabound event. iterate on data-set before binding data , add summary row every ten records. add property "ispagesummary" in data item flags whether summary record , not real data item. inside rowdatabound event, grab summary record separately using "ispages

java - Unable to understand the issue "call By Reference" -

this question has answer here: is java “pass-by-reference” or “pass-by-value”? 74 answers in java, object reference used call reference , variables used call value. here’s example: class foo{ int x; int y; } public class callbyref { public static void main(string[] args) { foo foo = new foo(); foo.x=5; foo.y=10; system.out.println(foo.x+", "+foo.y); getfoo(foo); system.out.println(foo.x+", "+foo.y); } static void getfoo(foo f){ f.x=2; f=new foo(); f.x=10; } } output: 5, 10 2, 10 why happend? x should 10 modified value f.x=10 is correct f=new foo() create new object in heap , not point prevoise reference? in method getfoo , variable f local variable. when call getfoo(foo) main , variable indeed refe

xml - Trouble in Layout design Android -

i have created android application in have problem in layout design. please see layout in link- https://lh6.googleusercontent.com/wjrlolp6pvokskrbdfh6vmmdqftsgt10ezhd-a1h_glblyojjvrf8byjspxmw752sgttlzih7ihwtqo=w1342-h479 my code: <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" > <imageview android:id="@+id/product_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/product" /> <textview android:id="@+id/price" android:layout_width="wrap_content" android:layout_height="wrap_content"

oracle - What if the value of order field is the same for all the records -

this question has answer here: why oracle return specific sequence if 'orderby' values identical? 4 answers all, let's sql looks below. select a, b ,c table1 order c if rows in table1 have same field value in field c. want know if result has same order each time executed sql. let's data in table1 looks below. a b c ------------------------------------------- 1 x1 2014-4-1 .... 100 x100 2014-4-1 .... 1000 x1000 2014-4-1 .... how oracle determine rows sequence same order value? added will random sequence each time? one simple answer no . there no guarantee order by on equal values return same sorted result every time. might seem stable, however, there many reasons when change. for example, sorting on equal values migh

node.js - How to edit jade image field from within Node/Express? -

i want display image on webpage on basis of user enters in form. have form defined in abc.jade, , in abc.js store form, , generate image's url , store in variable map_img on basis of form. how set image's source in jade point map_img url? abc.js: sales.save(); markers = [{ 'location': sales.location }] var gm = require('googlemaps'); var map_img = gm.staticmap(sales.location, 16, '500x400', false, false, markers); in general, best way manipulate fields in html/jade document node/express? im not sure if question right... there severals ways send data. described here: http://jade-lang.com/reference/ i use #{img_map} or in case have pure html better use !{img_map_html_desc}. also, alternative variant, create #temp div, send data there. on front end js(on window.onload) can data , store variable. don't forget clear #temp div after dont need anymore. once i've used side front-end js module , couldnt find better sollution, thi

C# conditional regex -

i new conditional regex , not sure how achieve below input string - "test \n string \n\r" output string - "test r string \n\r" would replace \n 'r' , leave is, if \n\r thanks, arthi you can use negative lookbehind: regex.replace(string, @"(?s)(?<!\r)\n", "r"); this replace \n when not preceded \r

sql - How to get more values from Access c# -

i want select sentence database, don't know how write code. search number reading lines textbox. (int = 0; < lines.getupperbound(0); i++) { oledbcommand command = new oledbcommand(); command.connection = connection; string query1 = "select top 1 * solozinnentabel faciliteitnummer = " + lines[i] + " , paragraaf '" + alineakinderennaam + "%' order rnd(id)"; command.commandtext = query1; oledbdatareader reader1 = command.executereader(); while (reader1.read()) { richaccotext.text = richaccotext.text + reader1["zin"].tostring(); richfacilitytext.lines = richfacilitytext.lines.where(line => line != lines[i]).toarray(); } } this code works can search 1 line , search them in textbox. want this:

ios - NSTimeZone timeZoneWithName abbreviation shows different Abbreviations on different devices -

i want display "edt" on label. used below line , found working on iphone6, 6+ , iphone4 (ios 7.1). testing on iphone5s(ios 8.2), iphone5(ios 7.1) noticed showing "gmt-4" nsstring *labelstring = [nsstring stringwithformat:@"%@",[[nstimezone timezonewithname:@"america/new_york"] abbreviation]] is device time zone related issue or can point out making mistake please. in advance. this because of timezone set on devices. different devices had different timezones set , made change in [[nstimezone timezonewithname:@"america/new_york"] abbreviation]]

ios - autolayout aspect ratio imageview in tableviewcell -

Image
i have custom tableviewcell imageview inside it. layout such: i want use autolayout calculate height of cell in method cgsize size = [cell.contentview systemlayoutsizefittingsize:uilayoutfittingcompressedsize]; so set constraints this basically these constraints pin each element edge of superview or view above/below. the problem there 1 more constraint want add imageview's aspect ratio. want set imageview's height half of width. if directly set aspect ratio constraint 2:1 unable simultaneously satisfy constraints error. tried change priority high , still no luck. can achieve using autolayout? the reason why constraints work , automatic height correctly calculated ui elements have own intrinsic size (the size make fit content). therefore, imageview has size fit image put inside. can't both use intrinsic size , specify own (even if want change 1 of dimensions). a solution see have static height constraint on uiimageview , plus aspect ration

gruntjs - Grunt specify order of injected files in index.html -

i using angular-fullstack yeoman generator 1 of projects , if run grunt build index.html overwritten injected dependencies grunt-injector finds. problem want specify loading of of modules in order or want ignore specific folder. how can that? javascript files loaded in wrong order , every time run grunt build error. you can use arrays specify order, instance // inject application script files index.html scriptsvendor: { options: { transform: function(filepath) { filepath = filepath.replace('/app/', ''); return '<script src="' + filepath + '"></script>'; }, starttag: '<!-- injector:js -->', endtag: '<!-- endinjector -->' }, files: { 'app/index.html': [ [ 'app/lib/js/jquery.js', 'app/lib/js/bootstrap.js', 'app/lib/js/angular.js' ],

facebook - Trying to get an access token using restFB. but not directing -

hello i'm playing spring boot , learning web services. started playing facebook graph api , using restfb. access token , hard code every time. dont want hard code credentials(access tokens), want able token when sign in account without hard coding access tokens every time try retrieve photos face , use in application. has worked restfb show me example of how automatically access tokens without hard coding it. thanks. uri "localhost:8080/myapp." @controller @requestmapping("/") public class homecontroller { @value("#{facebookappid['app_key']}") private static string app_key; @value("#{facebookappsecret['secret']}") private static string app_secret; private facebookclient.accesstoken getfacebookusertoken(string code, string url) throws ioexception { webrequestor web = new defaultwebrequestor(); webrequestor.response accesstokens = web.executeget("https://graph.facebook.com/oauth/access_token?client_i

PHP YouTube Live Streaming API insufficientPermissions Error -

i trying access listlivebroadcasts through "youtube live streaming api" (youtube data api v3). have auth 2.0 access , token every time. same logic accessing google+ calendar events successfully, have enabled youtube api also. when trying list : $youtube->livebroadcasts->listlivebroadcasts( 'id,contentdetails', array( 'mine' => 'true', )); it gives error : [domain] => global [reason] => insufficientpermissions [message] => insufficient permission i have tried everything, set scope $scopes auth/youtube; tried including : force-ssl readonly same code working @ https://developers.google.com/youtube/v3/live/docs/livebroadcasts/list with google's example api key. you shouldn't using google's sample api key. create new application in developer console , use application's api key.

asp.net - VerifyRenderingInServerForm : no suitable method found to override C# error -

i writing code export excel gridview. using updatepanel, whole page doesnot loads. so, wrote code : aspx.cs code protected void export_click(object sender, eventargs e) { gridview gv = (gridview)tbmmastercontentpalceholder.findcontrol("mygridview"); response.clear(); response.addheader("content-disposition", "attachment;filename=suppliers.xls"); response.charset = ""; response.contenttype = "application/vnd.xls"; system.io.stringwriter stringwrite = new system.io.stringwriter(); system.web.ui.htmltextwriter htmlwrite = new htmltextwriter(stringwrite); gv.rendercontrol(htmlwrite); response.write(stringwrite.tostring()); response.end(); } public override void verifyrenderinginserverform(control control) //to prevent export excel error { } asp code <asp:button id="btnexport" runat="server" text=" exp

php - Reverse string without strrev -

some time ago during job interview got task reverse string in php without using strrev . my first solution this: $s = 'abcdefg'; $temp = ''; ($i = 0, $length = mb_strlen($s); $i < $length; $i++) { $temp .= $s{$length - $i - 1}; } var_dump($temp); // outputs string(7) "gfedcba" then asked me if without doubling memory usage (not using $temp variable or variable copy reversed string to) , failed. kept bugging me , since tried solve multiple times failed. my latest try looks this: $s = 'abcdefg'; ($i = 0, $length = mb_strlen($s); $i < $length; $i++) { $s = $s{$i * 2} . $s; } var_dump($s); // outputs string(14) "gfedcbaabcdefg" it's not solution chop off "abcdefg" after loop because still double amount of memory used. need remove last character in every iteration of loop. i tried use mb_substr this: $s = 'abcdefg'; ($i = 0, $length = mb_strlen($s); $i < $length; $i++) { $s = $s{$i

javascript - How to have a specific file name when download -

this question has answer here: save file javascript file name [duplicate] 3 answers i've made function create csv file using json. i've found tips have button in order download file, i'm having issues have file name "*****.csv". need have extension ".csv" couldn't find topics dealing that. here code : function json2csv() { var myjson = "http://******/get_json_test.php?callback=?"; $('.filter').each(function(i, obj){ var input = $(obj).find("input")[0]; myjson += '&'+input.name+'=' + input.value; }); $('.display').each(function(i,obj){ myjson += '&'+$(obj).attr('table')+'|'+$(obj).attr('titre')+''; }); $.getjson(myjson, function(data){ var line = ''; var str = ''; if

c# - Is it possible to change default value for value types variables? -

this question has answer here: is possible change default value of primitive data type? 6 answers i'm curious know, possible change default value of e.g. int in c# , can have value -1 instead of 0. public class foo { public int i; } ... foo = new foo(); console.write(foo.i); so code must return -1 without explicit initializing public class foo { public int = -1; } can sure, don't print somewhere like #define true false but default value of int p.s. interest purposes only. no, basically. assuming don't initialize fields, memory space zeroed. shouldn't expose fields directly anyway . one trick have seen around (used capnp serializer, works against raw memory, not objects) use xor. example: if default -1, can xor value in , out: public class foo { private int i; public int { { return ^ -1; }

kerberos - Kerberize a python application -

i writing python application performs several queries. have used class here http://python-notes.curiousefficiency.org/en/latest/python_kerberos.html if have lot of urls , need authenticate every url each time. result makes program slow. question there way make session kerberos application? if not possible, there way read kerberos credential machine running program can authorized?

android - Change Color of AppCompatButton programatically -

support library 22.1 introduced new appcompatbutton should tint aware , new drawablecompat class set tint of drawable. i thought should easy create colored buttons , change button color programatically. i create button in code, background drawable of , try tint new drawablecompat class , set button. appcompatbutton btn = new appcompatbutton(context); drawable tintdr = drawablecompat.wrap(btn.getbackground()); drawablecompat.settint(tintdr, color.blue); btn.setbackground(tintdr); the result on android 5.x button blue ripple effect gets lost , clicking button looks quite strange. on android < 5.0 button grey. how can tint button programatically on android versions?

php - Checking for a specific user -

i have following code makes sure user logged in. want change code check specific user id. can me this? function protect_page() { if (logged_in() === false) { header('location: protected.php'); exit(); } } you can modify function logged_in , pass specific user id function: function logged_in($id) { //this function checks if user logged in , has specific id return (isset($_session['user_id']) && $_session['user_id'] === $id) ? true : false; } you have change protect_page function fit new logged_in function: function protect_page() { if (logged_in(7) === false){ header('location: protected.php'); exit(); } }

Multiplying Strings in Python -

given string , non-negative int n, return larger string n copies of original string. string_times('hi', 2) → 'hihi' string_times('hi', 3) → 'hihihi' string_times('hi', 1) → 'hi' def string_times(string, times): return string*times any sequence in python (of string example) can replicated multiplying sequence integer. although careful around numpy arrays , perform multiplication on every item in array.

c# - Load images with date criteria from Instagram -

i have code loads images instagram. public string giveinstagramimage() { string strtagname = "snowy"; string straccesstoken = "<<redacted>>"; string nextpageurl = null; string imageurl = null; { webrequest webrequest = null; if (webrequest == null && string.isnullorempty(nextpageurl)) webrequest = httpwebrequest.create(string.format("https://api.instagram.com/v1/tags/{0}/media/recent?access_token={1}", strtagname, straccesstoken)); else webrequest = httpwebrequest.create(nextpageurl); var responsestream = webrequest.getresponse().getresponsestream(); encoding encode = system.text.encoding.default; using (streamreader reader = new streamreader(responsestream, encode)) { jtoken token = jobject.parse(reader.readtoend()); var pagination

C++ static data members initialization -

1) true static data members of classes initialized before main() called? 2) true "static initialization order fiasco" can happen if static data member of class initialization code uses global static variable of other translation unit? where can read more it? couldn't find answer in 2003 standard of c++. thanks lot. 1) true static data members of classes initialized before main() called? yes initialized before program starts executing. 2) true "static initialization order fiasco" can happen if static data member of class initialization code uses global static variable of other translation unit? yes, along happens every other thing initialized before main() execution.

node.js - Auth/Session not working on one page in Sails with Passport -

Image
i have used passport manage authentication in sails. working bar 1 odd issue. if check user in order modify nav bar <ul class="nav navbar-nav navbar-right"> {{#if user}} <li>{{ user.username }}</li> <li><a href="/logout">logout</a></li> user! {{else}} <li><a href="/login">login</a></li> {{/if}} </ul> the log in , go / there nothing there. when go /login or /logout, both of use same template , share code above, both conditions being met. any ideas? ok, issue policies in sails applied controllers, not views. sails docs the solution create pages controller, route method home page view , apply following policy it. passes passport doesn't restrict access. pagecontroller.js module.exports = { home: function (req, res) { res.view(); }

android - Can't get selected text from webview -

i trying selected text webview below code returning null.please let me problem in below code. in code index.html html file inside sdcard/dheeraj/index.html folder. import android.app.activity; import android.content.res.assetmanager; import android.os.bundle; import android.os.environment; import android.content.clipboardmanager; import android.util.log; import android.view.actionmode; import android.view.keyevent; import android.view.menu; import android.view.menuitem; import android.webkit.websettings; import android.webkit.webview; import android.widget.toast; public class addtonoteswithwebviewactivity extends activity { assetmanager assetmanager; webview webview; string line, line1 = "", finalstr = ""; int = 0; private actionmode mactionmode = null; private clipboardmanager clipboard;

html - One button for more functions = recording in JavaScript -

i have source code record audio in browser. record.js calls scripts provides recording audio , save server. index.html <button type="submit" onclick="togglerecording()" data-run="0"></button> record.js //starts click on button function togglerecording(button) { var run = parseint(button.getattribute('data-run')); if(run === 1) { recorder && recorder.stop(); recorder && recorder.exportwav(function(blob) { uploadaudiofromblob(blob); }); __log('recording stopped'); button.setattribute('data-run', 0); } else { recorder && recorder.clear(); recorder && recorder.record(); __log('speak...'); button.setattribute('data-run', 1); } } function __log(e, data) { showinfo("\n" + e + &qu