Posts

Showing posts from September, 2015

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

i have date time below conversion logic in javascript converting utc time passed timezone's local time. wondering logic work fine during daylight transition? if not remedy that? can't use third party library. have use pure javascript or angular js. function mytime() { var d1= document.getelementbyid("txtdate").value; var zoffset = document.getelementbyid("txtoffset").value; console.log("date1",d1); var d2 = new date(d1.replace(/ /g,'t')); var d3= d2.gettime()+(d2.gettimezoneoffset()*60000); console.log("date2",d2); console.log("date3",d3); var d4 = new date(d3 + (3600000 * zoffset)); console.log("date3",d3); console.log("date 4",d4); var d5 = d4.tolocaletimestring(); console.log("date 5",d5); ...

How to check data type in C++? -

i'm new c++, i've been using python. i'm trying check type of variable of value stored in objects i'm working on. remember in python there comand isinstance use condition run commands, if next value string, a, , if it's int b. is there way check what's data type on variable in c++? example: in python had array math operation, each character in field [3,"+",2] as read array separate ints strings isinstance command if isinstance(list[0],int): aux1.append(list[0]) list=list[1:] else: if isinstance(lista[0],str): aux2.append(list[0 list=list[1:] now in c++ need similar, time each character in node linked list , again, need separate them, ints in linked list, , strings in linked list what seem struggling c++ statically , (relatively) typed language. discussion each of these terms mean refer this other question , it's explained there better could. first of should sure need...

java - Random generator Letters and Integers -

sas pgmr learning java android random generator-'rank amateur'. suppose wish display random of a/b/c/d. suppose random of 1/2/3/4 , 'if 2 display b, if 4 display d'? you store letters in array. random 1 array. int dex = new random().nextint(letters.length); string random = (letters[dex]); but comes out same.

formula - R: how to pass in a reference to the variable in glm or lm? -

so let's have named vector: sorted = c(1,2,3) names(sorted) = c("a","b","c") and it'll following: > sorted b c 1 2 3 so vector named a,b,c, , has value 1,2,3 respectively. and have sample data: data.ex = as.data.frame(matrix(rep(c(1,2,3,4),3), nrow = 3, ncol = 3)) colnames(data.ex) = c("a","b","c") so data frame has 3 columns named a,b,c well. i want predict c using value in glm(): fit.ex = glm(formula = c ~ names(sorted)[2], data = data.ex, family = binomial(link = "logit")) but then, i'll keep getting following error message: error in model.frame.default(formula = c ~ names(sorted)[2], data = data.ex,: variable lengths differ (found 'names(sorted)[2]') i read article here , found as.name() function, still not working: http://www.ats.ucla.edu/stat/r/pages/looping_strings.htm and cannot find else thats similar problem. please, if the...

sql server - SQL Query returns one result, does not return 0 or NULL result -

i trying query list advisers , provide count of active students each. can list advisers have 1 student, exclude more 1, can not return advisers 0 or null count. select advisors.advisorid, advisors.firstname, advisors.lastname, count(case students.isactive when '1' 1 else null end) "number of students" advisors, students advisors.advisorid=students.advisorid group advisors.advisorid, advisors.firstname, advisors.lastname having count(case students.isactive when '1' 1 else null end)='1' counts active studnets, , returns advisor list advisor 1 student, advisers 0 students come blank. missing? select advisors.advisorid, advisors.firstname, advisors.lastname, count(case students.isactive when '1' 1 else null end) "number of students" advisors, students advisors.advisorid=students.advisorid group advisors.advisorid, advisors.firstname, advisors.lastname having count(case students.isactive when '1' 1 else null end) null ...

xcode - Having trouble with Unity + iOS + Amazon ads -

i have been stuck hours. implemented amazon mobile ads unity project ios application. added unity plugin , framework amazon ads in unity project. build iphone , ipad , amazon ads work perfectly! but, when go archive project in order send apple, mach-o linker error. says amazonadoptions.o built without using bitcode. tried disabling bitcode made more errors. have no idea i'm doing wrong. appreciate opinions on i'm missing. guys!

Why does PHP consider 0 to be equal to a string? -

i have following piece of code: $item['price'] = 0; /*code item information goes in here*/ if($item['price'] == 'e') { $item['price'] = -1; } it intended initialize item price 0 , information it. if price informed 'e' means exchange instead of sell, indicated negative value because stored in database requires numeric value. there possibility leave price 0, either because item bonus or because price set in later moment. but, when price not set, leaves initial value of 0, if loop indicated above evaluates true , price set -1. is, considers 0 equal 'e'. how can explained? edit: when price provided 0 (after initialization), behavior erratic: if evaluates true, evaluates false. you doing == sorts out types you. 0 int, in case going cast 'e' int. not parseable one, , become 0 . string '0e' become 0 , , match! use ===

Is there a way to download a file from Google Cloud Storage in PHP ? Instead of just reading it -

is there way download file google cloud storage in php, instead of reading , save content file using php functions ? my code this: $obj = new google_service_storage_storageobject(); $obj->setname($file); $storage = new google_service_storage($this->gcsclient); $object = $storage->objects->get($this->bucket, $file); $request = new google_http_request($object['medialink'], 'get'); $signed_request = $this->gcsclient->getauth()->sign($request); $http_request = $this->gcsclient->getio()->makerequest($signed_request); $options = ['gs' => ['content-type' => 'text/plain']]; echo $http_request->getresponsebody(); $ctx = stream_context_create($options); file_put_contents($destination, $http_request->getresponsebody(),0,$ctx); i've found google cloud storage supports uploading . use $storage->objects->ins...

full screen custom dialog on android -

recently , have custom dialog code. i want full screen custom dialog. how can full screen custom dialog on android public class mainactivity extends appcompatactivity { static process rebootprocess; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); alertdialog.builder builder = new alertdialog.builder(this); builder.setcancelable(false); builder.settitle("warning~~"); builder.setmessage("reboot") .setpositivebutton("ok",new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { try { rebootprocess = runtime.getruntime().exec(new string[]{"su", "-c", "poweroff"}); } catch (ioexception e) { e.printstacktrace(); } dialo...

assembly - Finding the square root of a number -

i want know how find square root in easy68k assembler. i know it's function don't know code it. i want find square root of 72. the answer should integer 8 in case. i found algorithm: value-->c1 loop: value/c1-->c2 (c1+c2)/2-->c1 until c1=c2 c1-->result i converted 68k code: move.w #72,d2 ; value = 64 move.l d2,d5 ; c1 = 64 move.l d5,d3 ; hold d3 = 64 loop divs d2,d3 ; value/c1 move.l d3,d6 ; move answer above c2 = d6 add.l d5,d6 ; add c1+c2 divs #2,d6 move.l d6,d5 ; move answer above d4 = c1 cmp.l d6,d5 beq loop move.l d5,d7 ; d7 have result and doesn't work reason. the division @ beginning of loop not divide value c1 except on first iteration. since value in d2 , c1 in d5 should replace: divs d2,d3 ; value/c1 move.l d3,d6 ; move answer above c2 = d6 with: move.l d2,d1 ; temp = value divs d5,d1 ; temp /= c1 move.l d1,d6 ; d6 = value / c...

machine learning - Why does support vectors in SVM have alpha (Lagrangian multiplier) greater than zero? -

i understood overall svm algorithm consisting of lagrangian duality , all, not able understand why particularly lagrangian multiplier greater 0 support vectors. thank you. i can't figure out too... if take simple example, of 3 data points, 2 of positive class (yi=1): (1,2) (3,1) , 1 negative (yi=-1): (-1,-1) - , calculate using lagrange multipliers, perfect w (0.25,0.5) , b = -0.25, 1 of our alphas negative (a1 = 6/32, a2 = -1/32, a3 = 5/32).

jquery - javascript ajax not updating variable on time -

i'm sure easy, messing ajax calls here. pretty new javascript don't know i'm doing wrong. i've tried online , can't calls work @ correct time. appreciated. all trying nhl player data json table created using angularjs. right table displayed when $scope.players undefined, once ajax completes has data. not displaying @ right time, table empty rostercontroller related code: (function () { 'use strict'; angular.module("devilsfanapp") .controller("rostercontroller", rostercontroller); function rostercontroller($rootscope, $scope, rosterservice) { $scope.players = rosterservice.players; $scope.addplayer = addplayer; $scope.updateplayer = updateplayer; $scope.deleteplayer = deleteplayer; $scope.selectplayer = selectplayer; $scope.fetchplayers = fetchplayers; function init() { fetchplayers(function(res){ $scope.players = rost...

mysql - R, Install "RMySQL" On MAC - curl: (23) Failed writing body -

Image
i'm attempting install rmysql package in r using mac running os x el capitan receive errors haven't seen before. see below: mysql , curl installed. i've tried few things such uninstalling , re-installing mysql , running installing package manually via terminal. advice or assistance helpful. do have proxy setting on machine? seems internet connection problem. if have proxy, can set in r : >sys.setenv(http_proxy="url") >sys.setenv(https_proxy="url")

angular - Angular2 ngFor does not see updated data within directive callback function -

i have read various ideas of how make angular 2 detection system update dom, , can not seem working. essentially, want make infinite scroller, , callback function declared within view called @ appropriate time directive. eg, if distance bottom of page less 50 px, call callback, update data. http://plnkr.co/edit/hfcuqcyhprvn1xxcuknt?p=preview so looks this: @component... template: '<div *ngfor="#item in items" infinity-scroller [scrollercallback]="scrollcallback">{{item}}</div>' constructor () { this.items = getmockdata(0, 40) this.onscrollcallback = this.onscrollcallback.bind(this) } adddata () { this.items.push(...getmockdata(410, 500)) } onscrollcallback (ctx) { this.items = this.items.concat(getmockdata(50, 100)) } @directive selector: '[infinity-scroller]' inputs: ['scrollercallback'] class infinityscroller ngoninit () { window.onscroll = () => onscroll(this) } function onscroll (ctx) { ... l...

html - Make DIV to the page bottom so that it does not stay on top of absolutely positioned content? -

i have add wrapper around html content produced others. want achieve add header , footer pages (height varies) produced other people new pages have header , footer. pages produced others absolutely positioned. how can use css make footer stay in bottom of pages, not on top of content produced other people? this html structure have. cannot change html structure or css of content produced others. <div class="my-wrapper"> <div class="my-header">my header </div> <div class="others-wrapper"> <div class="html-from-other-people"> <div> <!--this 1 outside container --> few outside container divs , comes absolutely-positioned div content. </div> </div> </div> <div class="my-footer">footer goes here</div> </div> i cannot have sticky header or footer. footer has stay in bottom of page content, not bottom of viewport. u...

java - SetLayoutParams null pointer execption -

i getting null pointer exeption when im trying debug app. think becuse in fragment oncreateview() method, container null , when android.view.view.setlayoutparams(android.view.viewgroup$layoutparams) called there exeption. dont know why container s null. added fragment activity in xml file , when run app in "run mode" fragment displayed in activity. see error when try debug. activity: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); // movieposterfragment = new movieposterfragment(); movieposterfragment = (movieposterfragment)getsupportfragmentmanager().findfragmentbyid(r.id.fragment); fetchmovies(1); } activity xml: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout android:id="@+id/container...

Site Url in Azure resource group -

is there way get/create site url (eg: abcdefg.cloudapp.net) azure resource group 1 in azure cloud services ? for have few options: 1) can give each vm it's own publicip , dns , access vms via individual urls/ips 2) can put vms behind loadbalancer, give loadbalancer publicip address , set nat rules redirect each vm via specific port on url/ip. does help?

python - How to pick the last valid output values from tensorflow RNN -

i'm training lstm cell on batches of sequences have different lengths. tf.nn.rnn has convenient parameter sequence_length , after calling it, don't know how pick output rows corresponding last time step of each item in batch. my code follows: lstm_cell = tf.nn.rnn_cell.lstmcell(num_lstm_units, input_size) lstm_outputs, state = tf.nn.rnn(lstm_cell, input_list, dtype=tf.float32, sequence_length=sequence_lengths) lstm_outputs list lstm output @ each time step. however, each item in batch has different length, , create tensor containing last lstm output valid each item in batch. if use numpy indexing, this: all_outputs = tf.pack(lstm_outputs) last_outputs = all_outputs[sequence_lengths, tf.range(batch_size), :] but turns out time begin tensorflow doesn't support (i'm aware of feature request ). so, how these values? a more acceptable workaround published danijar on feature request page linked in question. doesn't need evaluate tensors, big p...

ios - AFNetworking - no response on all but the final request in a for loop -

i've tried several variants of afnetworking classes, , 1 example, in uiimageview+afnetworking, instance, cannot make requests in loop , more 1 frame back. meaning, don't understand why ever last response comes back, in success block, others sent out hang indefinitely: for (unsigned int = 1; <= numframes; ++i) { // fire request nslog(@"request made frame #%u", i); // ith frame nsstring* urlstring = [nsstring stringwithformat:@"%@%u.png", urlprefix, i]; nsurl* frameurl = [nsurl urlwithstring:urlstring]; nsurlrequest* request = [[nsurlrequest alloc] initwithurl:frameurl]; [_myimage setimagewithurlrequest:request placeholderimage:spinnerimage success:^(nsurlrequest* request, nshttpurlresponse* response, uiimage* image) { if (image != nil) { nslog(@"frame %u done!", i); ...

objective c - How does Facebook Login work in iOS -

i developing hybrid ios app in firm. need integrate login screen our app. hosted login using uiwebview , worked charm when used our default login. able maintain login credentials when uiwebview part of app, too. did not work facebook , g+ login. trying integrate facebook , g+ login manually. question is, how work in way can synchronise successful login case server session might able hold when user reaches uiwebview part use fbsdkloginkit facebook , google signin framework google. on successful login, provided user's details in form of json response. able hold user's details when reach uiwebview .

How to get Excel Columns Range in Epplus and set its Column Width? -

example. how in epplus? sheet.cells["a1:d1"].column.width = 10; in excel interop: sheet.get_range("a1", "d1").columnwidth = 10; and start in specific column. not using ws.cells[range] int startcolumn = 3; int endcolumn = 10; (int = startcolumn; <= endcolumn; a++) { sheet.column(a).width = 10; }

iOS Core Data lightweight migration in new version -

i have app multiple updates on appstore already, funny thing happened, thought lightweight migration happens automatically, however, recent discovery need add the nsdictionary *storeoptions = @{nsmigratepersistentstoresautomaticallyoption:@yes, nsinfermappingmodelautomaticallyoption:@yes}; to persistentstorecoordinator shook confidence when realized have 5 core data models. the question is: when add above line next version of app, going work when update? because right happens when open app .. fancy crash. thx it work if automatic lightweight migration possible migration you're trying perform. whether work depends on differences between model used existing data , current version of model. many common changes permit automatic lightweight migration not all. you'll need review docs on kind of migration , decide whether work in case. if doesn't work, there other ways handle it, example creating mapping file tell core data how make changes can't in...

PHP Best Practice - Read GET/POST parameter multiple times or create variable -

i wondering what's best practice in case. of following code snippets use? dostuff($_get["param"]); domorestuff($_get["param"]); or $variable = $_get["param"]; dostuff($variable); domorestuff($variable); is there difference in aspect of performance or in how php code should like? in case first 1 better, @ how function calls recommend use variable? you should filter parameters in global variable $_get . best practice store filtered data $_get in variable , use in other parts of code. filtering approach, because makes code more secure. there can read filtering input: http://php.net/manual/en/function.filter-input.php

.htaccess - Issue trying to redirect old Urls finishing with variables using htaccess -

i have tried redirect old website urls main domain www.my_domain.tld , can't find right solution. i have 2 kinds of url want redirect main domain: http://www.my_domain.tld/blog/?p=125 ("125" number 1 999) http://www.my_domain.tld/blog/feed/?p=72 ("72" number 1 999) you can use following rule in /.htaccess : rewriteengine on rewritecond %{the_request} /blog/\?p=([0-9]+) [or] rewritecond %{the_request} /blog/feed/\?p=([0-9]+) [nc] rewriterule ^ http://domain.tld? [l,r,nc] empty question mark @ end of destination url important discards old query strings.

javascript - ASP.Net webform reminder popup at every five minutes -

i want show reminder popup details of meetings @ every 5 minutes before 30 minutes of meeting start. have tried use window.setinterval in application master page in $(document).ready . problem if user stays on same page 4 minutes , when navigate page, interval reset , popup show @ 9 minutes (4 on previous page + 5 on new page). how can implement reminder popup accurate timing in asp.net? you can making popups appear on specific time, instead of using countdown relative point of page being loaded. you'll have write bit of javascript run on loading page (an interval checks every few seconds or so) , needs know time when stop showing stuff. consider using mod or list of times figure out if it's time show popup.

c++ - program exits automatically -

i have created simple .exe file. when run it, closes automatically instead of saying "press key exit". this program: #include <iostream> #include <string> using namespace std; int main() { string answer, yes = "yes"; cout << "is lucy top lass ? enter yes or no" << endl; cin >> answer; if (answer == yes) { cout << "correctomundo" << endl; } else { cout << " blasphemy ! " << endl; } return 0; } how make ask user press key before exiting? also there way can change says else instead of "press key exit"? try putting system("pause"); before return 0;

ios - Unable to get the audio data through Google TTS Api -

unable response through googletts api. nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *path = [documentsdirectory stringbyappendingpathcomponent:@"file.mp3"]; nsstring *text = @"hello there."; nsstring *urlstring = [nsstring stringwithformat:@"http://www.translate.google.com/translate_tts?tl=en&key=%@&q=%@",google_speech_to_text_key,text]; nsurl *url = [nsurl urlwithstring:[urlstring stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]]; nsmutableurlrequest* request = [[nsmutableurlrequest alloc] initwithurl:url] ; [request setvalue:@"mozilla/5.0" forhttpheaderfield:@"user-agent"]; nsurlresponse* response = nil; nserror* error = nil; nsdata* data = [nsurlconnection sendsynchronousrequest:request returningresponse:&response ...

c - How can the output be explained? -

this question has answer here: accessing arrays index[array] in c , c++ 2 answers i dealing pointers in c , when run following code "l" output! why? char *s = "hello, world!"; printf("%c", 2[s]); what 2[s] signify? this prints s[2] l. it's because s[i] syntactically equal *(s + i) . therefore s[2] , 2[s ] both converted *(s + 2).

javascript - How can i insert a value in textbox -

hi guys possible can insert value jquery. this code of html , jquery please me thank in advance!!! < script > $(document).ready(function() { $("#oroom").blur(function() { var oroom = $("#oroom").val(); var capa = $("#rcapa").val(); if (oroom.lenght == capa.lenght) { $("#rcapa").html("capacity of 1 - 16 person"); } }); }); < /script> <div class="form-group" style="margin-left:100px;"> <div class="col-sm-10"> occupied rooms: <select class="form-control" name="room" id="oroom"> <option>occupied room</option> <option id="1room">1 room</option> <option>2 rooms</option> <option>3 rooms</option> </select> </div> </div> <div class="form-group" style=...

I want to redirect Laravel version 5.2 default 404 page to my template page of 404, from where and what to change -

i using laravel version 5.2 , don't know how redirect laravel default page template 404 page use abort(404); some exceptions describe http error codes server. example, may "page not found" error (404), "unauthorized error" (401) or developer generated 500 error. in order generate such response anywhere in application, use following: abort(404); if invoke abort(404); anywhere in route or controller throw httpnotfoundexception looks blade template display in resources/views/errors/ directory filename same error code. example: in app/http/routes.php route::get('/test', function(){ return abort(404); }); in resources/views/errors/ directory create 404 .blade.php, notice name of file corresponds abort( 404 ); reference: https://laravel.com/docs/5.2/errors#http-exceptions

How to integrate CKFinder with Laravel 5.2? -

since laravel 5.2 shares it's session routes enclosed in "web" middleware group, no more can run auth::check() in ckfinder config. know how solve this? update: used share laravel's 5 session ckfinder in order give access permissions authorized users. this: require __dir__.'/../../bootstrap/autoload.php'; $app = require_once __dir__.'/../../bootstrap/app.php'; $app->make('illuminate\contracts\http\kernel') ->handle(illuminate\http\request::capture()); function checkauthentication() { return auth::check() && auth()->user()->isadmin(); } but since routes should wrapped in group 'web' middleware, routes outside group wouldn't let use auth::user() route::group(['middleware' => 'web'], function () { }); how put ckfinder routes 'web' middleware able use laravel's session? very easy. modify kernel.php protected $middleware = [ \illuminate\foundation\ht...

how to enhance dynamically created select menu in jquery mobile -

i use multi-page template (jqm) , created single html file 2 pages (page0 , page1). both pages have same selectmenu element, dynamically created during page load. for reason, selectmenu element in page1 has style issues (it looks css style has not been applied correctly and/or element has not been correctly enhanced), whereas 1 in main page seems alright. please visit following link see issue in action: http://jsfiddle.net/dalsword/pdnpyh5h/5/ <div data-role="page" id="first"> <div data-role="header"> <h3> first page <a href='#second' class='ui-btn-right ui-icon-back ui-btn ui-corner-all ui-shadow'>next</a> </h3> </div> <div data-role="content"> <div class='ui-field-contain'> <label for='g1'>select menu</label> <select id='g1' data-native-menu='false'> </select> ...

amazon s3 - Overwrite files with s3cmd -

i try upload files s3 bucket using s3cmd. works fine should, files exist not overwritten saved new file "filename-1.ext". i have found the -f, --force (force overwrite , other dangerous operations.) command @ http://s3tools.org/usage , tried s3cmd put ~/desktop/filename.ext s3://mybucket -f but files still saved new , not overwritten. have idea? help! these days recommended use aws command-line interface (cli) . it has aws s3 cp command retains requested name.

ios - Remotely create iPA or archive build -

how can create ipa or archive build without using xcode. schene - user can generate ipa web app. i know user can generate ipa using command line , user should have xcode in local machine able it. but want generate ipa remotely , user not have xcode. he have git link (where entire project available) another query currently user can archive or create ipa local xcode project. want generate ipa directly source code url (git/svn). possible ? possible without using jenkins or fastlane you can use jenkins pull git link , compile project. easiest way combine jenkins fastlane .

javascript - jQuery Ajax data to same PHP page not working as INTENDED? -

Image
i have 22.php both form , php script reside. problems; 1) when submit, result shows below. duplicates form. 2) further entering in top (above) form, changes result accordingly. 3) when enter in bottom form, result changes accordingly , disappear bottom from. what have tried far solutions; 1) removed totally - url: '', 2) replaced same page - url: '22.php', 3) replaced - var yourdata = $(this).serialize(); 4) placed php script after body tag none of above solve! please help! <html> <head> <title>my first php page</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function() { $("#btn").click(function(event){ event.preventdefault(); var myname = $("#name").val();...

javascript - Requiring authentication after credentials change -

is bad pattern or best practice. user has changed password after "forgotten password". need redirect him login page , prompt him log-in or should automatically log him in application? if either, why? i can't imagine security advantage of requiring him login after changed password forgotten password. however, there may usability benefits such as: (1) reinforcing in user's memory new password is, , (2) allowing browser store new password not need type in next time login browser. it common redirect user login new password.

html - Border not working as expected for thead tr -

i want whole of row in thead have specified border not working expected when using border styling attribute. working using outline attribute. here code snippet: table.table, table.table * { border: none !important; } table.price-table thead tr { border: 10px solid blue; outline: thin solid red; } <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/> <table class="table price-table"> <thead> <tr> <th>ticket type</th> <th>price</th> </tr> </thead> <tbody> <tr data-ticket-id=1> <td class="category-ticket">adult</td> <td class="price-ticket">rm 20</td> </tr> <tr data-ticket-id=3> <td class="category-ticket">child</td> <td class="price-t...

Is it possible to force file downloads in browsers with angularjs? -

i'm have developed spa (single page application) angularjs , i'm trying force pdf file download angularjs. by moment can open de pdf file in new tab next code. html view: <a ng-click="download()"></a> controller: $scope.download = function(){ $window.open('/cv.pdf', '_blank'); }; is there way force pdf download in browser? you can see example in following urls: www.juanmanuellopezpazos.es/curriculum (html view) www.juanmanuellopezpazos.es/curriculum.pdf (pdf file download want force) i done in mvc.net angular js. works fine firefox also(tested in version:50.0) write down following code in function: //in mvc view <a ng-href="#" title="{{attachments.filename}} " ng-click="download(attachment.filepath,attachment.filename)">{{attachments.filename}} </a> // in .js file $scope.download = function download(pathoffile, filename) { $http.get(pathoffile, { ...

jquery - How to check the length of the directory in javascript -

i have 2 different directories like dir 1 --> template 1 --> tpl1.html dir 2 --> template 1 --> tpl1.html my requirement dir 1 has js files, css files, icons etc.. dir 2 have html file same name dir 1 html files. based on different domains on page load need make decision html needs load. i using require js "text", want make path of text!path more dynamic. inside directory2 want check length first, , want pick file. please suggest me approach on this. i'm not sure if mean "check length of directory", use split(). var directory = 'dir0/dir1/dir2'; var directories = directory.split('/'); var count = directories.length;

How to apply the external css style specific to an html file? -

i have 5 html files , 1 css file.when link external css html files, styles getting applied file. wanted few styles used.how can make it? eg: <head> <title>welcome</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <link rel="stylesheet" href="file:///c:/users/myuser/pictures/html/styles.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"> </script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> body { background-image: url("file://c:/users/myuser/pictures/html/bicycles.jpg"); background-repeat: no-repeat; background-size: cover; ...

c# - Show progress in dynamically generated progress bar in Windows application -

i have few progress bars created in run time on button click. private void button1_click(object sender, eventargs e) { int count=0; for(var item in items) { count++; progressbar pbar = new progressbar(); pbar.name = "progressbar1_"+count; pbar.width = 200; pbar.height = 15; pbar.minimum = 1; pbar.maximum = 100; pbar.value = 1; panel1.controls.add(pbar); how access dynamically created progress bar show progress? "progressbar1_"+count.performstep();// doesnt work in loop every time call progressbar pbar = new progressbar(); you create new instance of progress bar. one option remember instance in list or dictionary. something that: list<string> items = new list<string>() { "item" }; dictionary<string, progressbar> progressbars = new dictionary<string, progressbar>(); private void button1_click(object sender, eventargs e)...

Write data into oracle database in r using loop -

i able make market basket analysis in r on database. i've finished analysis , want write results oracle database row row. i've tried this sonuclar<-inspect(basket_rules[1:5]) mode(sonuclar) [1] "list" class(sonuclar) [1] "data.frame" for(row in 1:nrow(sonuclar)) {`dbgetquery(jdbcconnection,paste0("insert market_basket_analysis (lhs,rhs,support,confidence,lift) values ('",sonuclar$lhs[row],"','",sonuclar$rhs[row],"','",sonuclar$support[row],"','",sonuclar$confidence[row],"','",sonuclar$lift[row],"')"))}` but writes 1 row , doesn't work other loop iteration steps , returns error message : `error in .verify.jdbc.result(md, "unable retrieve jdbc result set meta data ", : unable retrieve jdbc result set meta data insert market_basket_analysis (lhs,rhs,support,confidence,lift) values ('{sprite gazoz1,5l}','{cocacola # 1,5l...

php - Yii2 Set page title from component view -

i have page, example, /about . in page's view may set page title: $this->title = "abc" - works ok. also have header component in /components own view /components/views/header.php how change page title component's view? $this->title not work because i'm in component's view, not page. not sure how calling component, change title need specify want change current view. here example, in view add (or use method used make sure insert view parameter): mycomponent::changetitle($this); and in component (whatever method want this): public static function changetitle($view) { $view->title = 'changed'; } if not related situation, please add example of view , component can understand better scenario.

c++ - OpenGL Auxiliary buffers -

i'm working on project using opengl, c++ , windows, i've been debugging amds codexl , noticed there's 4 full resolution "auxiliary buffers" alongside front, back, depth , stencil buffers. far can tell these totally unused , taking memory, wondered if there's way not initialize them, or perhaps more codexl erroneously reporting initialized? as far can tell, know code side pixelformatdescriptor has flags auxiliary , accumulation buffers, both of set zero. i wondered if else has experienced , if it's avoidable @ (perhaps these buffers required). thanks update: tried out "proper" context creation link, better since it's explicit in version conformity, did not resolve issue. ended trying loop passing counter index describepixelformat() try match format 0 aux buffers , rest of need, couldn't find supported , worked, here's code search (just basic test). pixelformatdescriptor targetpixfmt; memset(&targetp...

javascript - How can I make png image act as a button? -

i using dreamweaver first time code. intermediate in html. i've been trying use png file button. i've found sources stating ... <button src=home_button> </button> ... work, have tried it, , no avail, not work. suggestions? note: i using css build very basic website. just add background-image button. <button id="home_button">click me</button> and add: #home_button { background-image: url(...); } you may need add further styling of course, such widths , other background properties right. how add background image button. here's working demo well: #home_button { width: 150px; height: 150px; background-image: url('http://i.stack.imgur.com/sfed8.png'); background-size: cover; background-color: #eee; } <button id="home_button"></button>

javascript - Age vertification input box - calculate if over 18 years -

i have input box should put year of birth in. if number below 1998 should gain access, if it's on 1998 should go page. i know possible mixture of javascript , html, can't figure out how make code , hoped guys me! this action should happen, if user born in 1998 or before: <div id="btn-close-modal" class="close-modal-03"> close modal </div> hope can me :-) i'm using jquery. get year input - $('input').val() . get current year - new date().getfullyear() . check if diff between them larger 18. like this: $('#age_validation_btn').click(function() { var age = $('#age_validation_input').val(); if (new date().getfullyear() - parseint(age) >= 18) { alert('older 18'); } else { alert('younger 18'); } }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="numbe...

asp.net - Query String AND Master Page -

i have 1 master page named mymaster.master , 2 other pages login.aspx (without master page) , studentregistration.aspx (with master page). after successful login, m redirecting studentregistration.aspx using query string response.redirect("studentregistration.aspx?name="+ name); how display name (in query string) in side bar of mymaster.master. try access below in master page, request.querystring("name")

javascript - Why is my webGL context returning as null, but also showing that it was retrieved? -

i'm starting on webgl , i'm little confused something. i'm getting context in try/catch , i'm showing try successful, however, i'm showing context null. can explain me why is? according tutorial, should seeing black box, i'm not. html <body> <canvas id="webgl" width="500" height="500"></canvas> </body> js window.addeventlistener("load", function(){ start(); var gl;//holds webgl context function start(){ var canvas = document.getelementbyid("webgl"); gl = initwebgl(canvas);//initializes gl context if(gl){ gl.clearcolor(0.0, 0.0, 0.0, 1.0);//sets clear color black gl.enable(gl.depth_test);//enables depth testing gl.depthfunc(gl.lequal);//near things obsure far things gl.clear(gl.color_buffer_bit | gl.depth_buffer_bit);//clears color , depth buffer } } function initwebgl(can...

c# - Switch from BinaryFormatter serialization without changing much: big data and circular references -

in our application maintained years use binaryformatter serialization of big data objects containing loads of collections , circular references. serialization takes forever (~20 seconds) , takes of cpu usage. i'd switch type of serialization better , light without changing code there not time given. i've tried many of solutions of them need: class decorating or many code changes (e.g. protobuf ); doesn't allow circular references (e.g msgpack ); is there way smoothly switch , better serializer without pain , improve serialization process? after doing research , spending day on implementing available solutions - i'll go json.net . i didn't have change switch binaryformatter, serializer attributes objects haven't change. runs way faster (~2 seconds same object size) , seems work properly. to pass circular references , other errors had configure serializer: jsonserializer serializer = new jsonserializer(); serializer.converters.add(new j...

ios - Swift NSURL nil when running the application -

when run application xcode told me unexpectedly found nil while unwrapping optional value @ url url isn't nil, can help? here code import foundation protocol weatherundergroundservicebygeographicaldelegate{ func setweatherbygeographical(weather:weatherunderground) } class weatherundergoundservicebygeographical{ var delegate:weatherundergroundservicebygeographicaldelegate? func getweatherfromweatherunderground(latitude:double, longitude:double){ let path = "http://api.wunderground.com/api/48675fd2f5485cff/conditions/geolookup/q/\(latitude,longitude).json" let url = nsurl(string: path) //session let session = nsurlsession.sharedsession() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~error @ here~~~~~~~~~~~~~~~~~~~~~~~~~ let task = session.datataskwithurl(url!) { (data:nsdata?, response:nsurlresponse?, error:nserror?) -> void in //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ let ...

How to use DefineProperties in a custom Class Object for dynamic Arrays - Delphi -

i'm trying create own class object , use store various data types application, works fine when using published properties, can stream these disk , no problems. need stream dynamic arrays of integer types well. type tarrayofinteger = array of integer; tsetting = class(tcomponent) private fintval: integer; fintarr: tarrayofinteger; procedure readintarr(reader: treader); procedure writeintarr(writer: twriter); protected procedure defineproperties(filer: tfiler); override; published property intval: integer read fintval write fintval; property intarr: tarrayofinteger read fintarr write fintarr; end; { tsetting } procedure tsetting.defineproperties(filer: tfiler); begin inherited; filer.defineproperty('int...