Posts

Showing posts from March, 2015

node.js - My express app is not start,how can I do with it? -

Image
i created express application express test , npm install the package in test directory,but when use npm start ,my project can not run in browser.just that: this situation kept long time , don't know how deal it. my package.json is: { "name": "test", "version": "0.0.0", "private": true, "scripts": { "start": "node ./bin/www" }, "dependencies": { "body-parser": "~1.17.1", "cookie-parser": "~1.4.3", "debug": "~2.6.3", "express": "~4.15.2", "jade": "~1.11.0", "morgan": "~1.8.1", "serve-favicon": "~2.4.2" } } can me ?

android - parsing response from HttpUrl in NetworkUtils to onpostExecute -

hey i'm trying complete asynctask udacities popularmovies app, i'm new android , trying figure out 1. how set data recieved doinbackground onpostexecute , populate recycler view 2. in networkutils.buildurl, how set default view option(popular/rating default. heres code networkutils private static final string log_tag = networkutils.class.getsimplename(); public static final string sort_by_popular = "most_popular"; public static final string sort_by_rating = "top_rated"; private static final string api_key = "api_key"; private static final string base_url_popular = "https://api.themoviedb.org/3/movie/popular"; private static final string base_url_top_rated = "https://api.themoviedb.org/3/movie/top_rated"; final string sort_by = "sort_by"; string sortby = params[0]; public static url buildurl(string sortmode) { url url = null; try { if (sortmode.equals(sort_by_popular)) { ...

javascript - $q deferred not firing continuations in Jasmine -

Image
i creating unit tests work promises want resolve manually , finding promise continuations seem never hit. open console in jasmine debug panel, put reference $q on window object...and d = $q.defer() d.promise.then(x => console.log(`done`, x)) d.resolve(5) nothing gets logged... what going on?! $q somehow working? not work every other deferred implementation in world works? reading ( insanely meager ) documentation wrong? how possible above promise resolved not have continuation fire?! angularjs 1.5.8 logs "done 5" in example angular.module("app",[]) .run(function($q) { var d = $q.defer(); d.promise.then(x => console.log(`done`, x)); d.resolve(5); }); <script src="//unpkg.com/angular/angular.js"></script> <body ng-app="app"> <h1>promise example</h1> </body> integration browser event loop angularjs modifies normal javascript flow providin...

c - Confusing MACRO and enum definition -

i browsing route netlink source code. i wanted figure out value of rtnlgrp_neigh source: http://lxr.free-electrons.com/source/include/linux/rtnetlink.h?v=2.6.35#l550 541 /* rtnetlink multicast groups */ 542 enum rtnetlink_groups { 543 rtnlgrp_none, 544 #define rtnlgrp_none rtnlgrp_none 545 rtnlgrp_link, 546 #define rtnlgrp_link rtnlgrp_link 547 rtnlgrp_notify, 548 #define rtnlgrp_notify rtnlgrp_notify 549 rtnlgrp_neigh, 550 #define rtnlgrp_neigh rtnlgrp_neigh 551 rtnlgrp_tc, 552 #define rtnlgrp_tc rtnlgrp_tc 553 rtnlgrp_ipv4_ifaddr, 554 #define rtnlgrp_ipv4_ifaddr rtnlgrp_ipv4_ifaddr ... ... ... ... #define rtnlgrp_phonet_ifaddr rtnlgrp_phonet_ifaddr 585 rtnlgrp_phonet_route, 586 #define rtnlgrp_phonet_route rtnlgrp_phonet_route 587 __rtnlgrp_max 588 }; 589 #define rtnlgrp_max (__rtnlgrp_max - 1) what enum #define doing. value of rt...

laravel - Why is it a bad idea to refresh JUST token on every request? -

so i'm building react app laravel api, , jwt token expiring every hour (as it's meant to). now, i've read few different approaches refreshing token on here, of sound convoluted (storing expiry in state, doing second request whenever api returns 401 etc), seems think it's horrible idea refresh token on every request. why that? i'm not familiar react, in terms of jwt, main reason can think of have include new token in every response. forces endpoints act authorization endpoints, whatever main purpose is. think it's better keep authorization endpoint seperate other api endpoints, , make requests when it's necessary refresh.

IMEI number gone while flashing -

i have lenovo vibe x3a40 mobile. flashed , imei numbers gone , don't have backup. i have tried android diagnostics mode write new imei port not shown on device manager. please i'm on 3 days no luck. ps newbie step step approach lot.

python - How to sort a list of tuples such that the key is the sum of the value in the tuples? -

b= sorted(calls,key=lambda x:x[0]-x[1] ) in case subtraction equal list should sorted on basis of 2nd element sorted(calls, key=lambda x: sum(x)) i don't believe there way specify secondary sort parameter requested, you'll have sort collection twice. sort first value of second element, sort again sum. elements have same sum retain ordering first sort. edit: there is way specify multiple sort keys! lambda function can return tuple of values. first item in tuple primary sort key, second item secondary key, , on: sorted(calls, key=lambda x: (sum(x), x[1])) thanks @tzot's answer this question !

Generic Map Parameter java -

i having lot of methods of type: public static list<eduusers> getdetails(class c, map<string, integer> params) { list<eduusers> details = null; session session = hibernateutil.getsessionfactory().opensession(); transaction tx = null; try { tx = session.begintransaction(); criteria cr = session.createcriteria(c); (map.entry<string, integer> entry : params.entryset()) { cr.add(restrictions.eq(entry.getkey(), entry.getvalue())); } details = cr.list(); tx.commit(); } catch (exception asd) { log.debug(asd.getmessage()); if (tx != null) { tx.commit(); } } { session.close(); } return details; } i trying have generic method them , have written far: public static <t> list<t> getdetails(class<t> c, class<t> b) { l...

swift - Trouble with SKAudioNode -

in app when screen touched want play file "pewpew.mp3". not working. i've looked @ several of these posts none of working. code: let shootnoise = skaudionode(filenamed: "pewpew.mp3") shootnoise.autoplaylooped = false addchild(shootnoise) shootnoise.run(skaction.play()) hero.run(playnoise) that inside of override func(touchesended) any ideas? feel i'm over-thinking this.

Specifying the minimum python version required for a module in pip -

is there way specify minimum python version required installing module in pip? i trying publish package pypi. python setup.py sdist upload -r pypi is command using. in setup.py there no way specify minimum python version (in case python 3.5) needed run module. you can specify version of python required project using: python_requires='>=3.5' the above code must specified in setup.py ,also versions 9.0.0 , higher of pip recognize python_requires metadata. additionally in setup.py specify dependences: setup( install_requires=['dependent functions,classes,etc'], )

Build columns while running a query in yii2 -

create columns while running query in yii2 in controller : query : $query=reports::find()->select(['report type','title','imagefile','id','body'])->where(['like', 'title',''.$test.'' ])->orderby('id desc'); i build column type not work. for see result of alias should add in reports model public var same name value class reports extends \yii\db\activerecord { public $type; ..... then can access value $mymodels->type

Javascript- Splitting an array I'm looping through without changing the loop array -

var arraylength = splitdata.length; for(var i=0; i<arraylength; i++){ if(splitdata[i]== '----------------\r\n#notes:\r\n'){ console.log("notes section found..."); notesection = true; } else if(i==1){ var temparray = splitdata[i]; var titledata = temparray; titlebox = titledata.split("\r\n"); for(var i=0; i<titlebox.length; i++){ var bpmbox = titlebox[i]; if(bpmbox.indexof("bpms") >= 0){ var bpmboxsplit = bpmbox.split("="); bpm = parseint(bpmboxsplit[1]); console.log("bpm found: " + bpm); } } } so have array , loop iterates through array, searching particular string: '----------------\r\n#notes:\r\n' but reason, else if statement has code in that's altering arraylength, , causing loop skip straight on string need. var titledata = splitdata[i]; titlebox = titledata.split("\r\n"); this bit of code messing thi...

forms - Subform issue ms access vba -

i writing because faced time consuming issue have not yet solved. connected ms access query , form data exchange. put in simple way. have following form: form i have table cars , inside columns in order shown in q_cars query. have subform updated using particular comboboxes (currently 2 assigned) updating query using vba code (requery option). works if pick values both comboboxes only. can me find way put query criteria criterion empty combobox run query available data? tried use e.g. following structure inside criteria in query form: iif( formularze![form]![t_id] <>""; «wyr» formularze![form]![t_id] ;>0) or other attempts isempty, isnull function without success. know how solve issue? in version due language "," replaced ";" inside if structure. remaining code: private sub btn_clear_click() me.t_brand.value = "" me.t_id.value = "" me.t_color = "" me.t_seats = "" q_cars_subform.requery end sub pr...

api - Why do my browsers redirect me with this URL, but Python doesn't? -

when use urllib, urllib2, or requests on python 2.7, neither 1 ends @ same url when copy , paste starting url chrome or firefox mac. edit: suspect because 1 has signed in vk.com redirected. if case, how add sign-in script? thanks! starting url: https://oauth.vk.com/authorize?client_id=private&redirect_uri=https://oauth.vk.com/blank.html&scope=friends&response_type=token&v=5.68 actual final (redirected) url: https://oauth.vk.com/blank.html#access_token=private_token&expires_in=86400&user_id=private private, private_token = censored information the following 1 of several attempts @ this: import requests appid = 'private' display_option = 'popup' # or 'window' or 'mobile' or 'popup' redirect_url = 'https://oauth.vk.com/blank.html' scope = 'friends' # https://vk.com/dev/permissions response_type = 'token' # documentation vague on this. don't know # other options there are, ...

xml - XSLT pass regex-group() value to variable and formatting it -

i have not find clear example on how this. want pass 2 regex-group result variable inside analyse-string 1 should tranformed hexadecimal decimal. example take regex-group(2)=2 , regex-group(4)=30, regex-group(4) should formated 0.30 both value passed variable lets $rg2 $rg4 calculating "($rg4*(100 div 60))+$rg2" "(0.30*(100 div 60))+2"=2.5 . if rg4=0.38 final result 2.6333333333333333 <xsl:analyze-string select="sbtime/@stmerid" regex="([hm]{{1}})([0-9]{{1,2}})([ew]{{1}})([0-9]{{0,2}})"> <xsl:matching-substring> <xsl:choose> <xsl:when test="regex-group(1) = 'm'"> <xsl:choose> <xsl:when test="regex-group(3) = 'e'"> <xsl:text>-</xsl:text> </xsl:when> <xsl:otherwise> ...

How to display json data in two columns with table in each column using angularjs -

i have data in json dynamic , want display data in table 2 columns , each column contains table. this json: var data = {"a": "1", "b": "2", "c":3, "d": "4", "e": "5"} my html code. <table> <tr> <td> <table> <tr> <td>a</td> <td>1</td> </tr> </table> </td> <td> <table> <tr> <td>b</td> <td>2</td> </tr> </table> </td> </tr> <tr> <td> <table> <tr> <td>c</td> <td>3</td> </tr> </table> </td> <td> <table> <tr> ...

ios - why Reloading collection view in another class will cause Fatal Error in Swift 3? -

i have collection view in app in 1 class - have camera function in class want when take picture function execute in collection view class , want reload data in collection view cause fatal error here camera class codes func imagepickercontroller(_ picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : any]) { let selectedimage = info[uiimagepickercontrolleroriginalimage] as! uiimage uiimagewritetosavedphotosalbum(selectedimage,self,nil,nil) oneviewcontroller().reloading() print("save image ") dispatchqueue.main.asyncafter(deadline: .now() + .seconds(3), execute: { self.dismiss(animated: true, completion: nil) }) and here oneview controller reloading function public func reloading() { print("oky") viewdidload() viewwillappear(true) let allphotosoptions : phfetchoptions = phfetchoptions.init() allphotosoptions.sortdescriptors =...

sublimetext3 - No dots in the gutter with sublimelinter-html-tidy -

i have installed htmltidy in sublime text 3 following rules ; works... when html error occurs, don't see code marks neither dots in gutter. installed php lint , dots appear in gutter. when activate linter debug mode, see html errors in console. found no solution yet, in doc or here . have made new install scratch in vain.

ios - Determine if a cell in on screen and perform a function -

Image
i want find out if cell displaying onscreen in table view. i tried out willdisplay method it's of no use. tried if (tableview.indexpathsforvisiblerows?.contains(indexpath))! { print("showing now") } function works, doesn't print when cell on screen or scroll down. ex: if have 5 cells, app launches , cell on display, nothing printed. also, when scroll cells 1 5, nothing displayed. on contrary, if scroll cells 5 1, display it, defies purpose. i hope understood query , can me apt solution. cheers! willdisplay method of tabview should work you. give datasource , delegate properly. control+drag tableview yellow icon display correct options. add extension viewcontrollerclass , confirm table protocols-: extension viewcontroller : uitableviewdelegate,uitableviewdatasource{ func numberofsections(in tableview: uitableview) -> int { return 1 }// default 1 if not implemented func tableview(_ table...

php - correct way to deploy project in jenkins -

i have php project unit tests. want run unit tests , on success deploy codes production repository. using jenkins don't know how can push codes repository in jenkins can use git publisher merge branch can't push repository. i have added conditional step in build step this: image of conditional build think not correct way. another ask is way push repository or shall merge example production branch i have added conditional step in build step this: image of conditional build think not correct way. what you're doing fine. think you're worried not using built-in jenkins git integrations. if it's simple adding remote pointing @ local git repo, don't think jenkins integrations helping. is way push repository or shall merge example production branch it more conventional (and simpler, have found) merge production branch (often called master), lots of people have separate repo production.

android - FrameLayout width is not equal to its parent which is a Toolbar -

Image
i have framelayout inside toolbar problem set framelayout width match patent not going equal wherease toolbar full length code follows <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context="com.ecbclass.user_activity.home"> <android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" ...

haskell - How to avoid unsafePerformIO in the Handler Monad? -

i have problems wrapping head around avoiding unsafeperformio in yesod handler. code in handler living in handler monad, how can execute io operation? getprofiler :: handler html getprofiler = -- totmdbmovie's return-type io movie -- without unsafeperformio type of result io [movie] -- how io [movie] [movie]? -- ignore reccmovies - it's parameter. let result = unsafeperformio $ mapm totmdbmovie reccmovies defaultlayout $ settitle "profile" $(widgetfile "profile") thank help! if monad m working in of monadio class, can use liftio :: io -> m a perform io actions inside. as yesod, can perform io action in handler actions, persistent's rundb blocks.

parsing - How do you parse and process HTML/XML in PHP? -

how can 1 parse html/xml , extract information it? native xml extensions i prefer using 1 of native xml extensions since come bundled php, faster 3rd party libs , give me control need on markup. dom the dom extension allows operate on xml documents through dom api php 5. implementation of w3c's document object model core level 3, platform- , language-neutral interface allows programs , scripts dynamically access , update content, structure , style of documents. dom capable of parsing , modifying real world (broken) html , can xpath queries . based on libxml . it takes time productive dom, time worth imo. since dom language-agnostic interface, you'll find implementations in many languages, if need change programming language, chances know how use language's dom api then. a basic usage example can found in grabbing href attribute of element , general conceptual overview can found @ domdocument in php how use dom extension has been covered exte...

node.js - node js jwt how to pass token to other routes to check logged user information later -

i'm creating application learn self. @ moment need authenticate user using jsonwebtoken , know how create token authenticate user. need know how can retrieve logged users's information later using token created user when logged system. searched everywhere answer couldn't find answer apiroutes.post('/authenticate', function(req, res) { // find user user.findone({ name: req.body.name }, function(err, user) { if (err) throw err; if (!user) { res.json({ success: false, message: 'authentication failed. user not found.' }); } else if (user) { // check if password matches if (user.password != req.body.password) { res.json({ success: false, message: 'authentication failed. wrong password.' }); } else { // if user found , password right // create token var token = jwt.sign(user, app.get('supersecret')); // return information including token json res...

python - Django-registration: How to allow user delete their account? -

i have simple website users can register in order have access private content , receive newsletter. have used django-registration user registration , authentication, , used html templates here . the whole system working (login, logout, password recovery, etc.) realized user cannot delete account website. there plugin designed this, or how extend registration classes that? deleting, i'd prefer real suppression, not making user inactive. you can this: def delete_user(request, username): context = {} try: u = user.objects.get(username=username) u.delete() context['msg'] = 'the user deleted.' except user.doesnotexist: context['msg'] = 'user not exist.' except exception e: context['msg'] = e.message return render(request, 'template.html', context=context) and have url pattern like: url(r'^delete/(?p<username>[\w|\w.-]+)/$', views.d...

storage - Android - Store generated RSA private key -

i've create keypair this: try { keypairgenerator generator = keypairgenerator.getinstance("rsa"); generator.initialize(2048, new securerandom()); keypair pair = generator.generatekeypair(); return pair; } catch (exception e) { e.printstacktrace(); return null; } this works fine, (obviously) want save key. saw posts none of them helped me out. p.s. example nice! thanks.

javascript - Bootstrap Popover not working in Chrome Extension (Days debugging) -

no matter have tried, can't seem popover work in chrome extension. the extension intended go through school's registration page, pull info on professors through professor rating website, , show in popover. (and link pages works fine). here school page. hit subject = art less = 200 some results pop up, click extension icon, , bam script runs. my code: manifest: { "name": "rmp", "description": "work in progress", "manifest_version": 2, "version": "0.8", "icons": { "16": "icon16.png", "48": "icon48.png", "128": "icon128.png" }, "permissions": [ "activetab", "http://*/", "https://*/" ], "background": { "scripts": ["jquery-3.2.1.min.js","bootstrap.min.js","background.js"], "persis...

Google Script - Send active sheet as PDF to email listed in cell -

i'm trying use script below send first sheets in google sheets document email pdf. email send to, listed in cell a1. however, script send entire spreadsheet pdf , not first sheet. have been trying use of other scripts stackoverflow, 1 sends email. hope guys can me out. /* email google spreadsheet pdf */ function emailgooglespreadsheetaspdf() { // send pdf of spreadsheet email address var email = "amit@labnol.org"; // active spreadsheet url (link) var ss = spreadsheetapp.getactivespreadsheet(); // subject of email message var subject = "pdf generated spreadsheet " + ss.getname(); // email body can html var body = "install <a href='http://www.labnol.org/email-sheet'>email spreadsheet add-on</a> one-click conversion."; var blob = driveapp.getfilebyid(ss.getid()).getas("application/pdf"); blob.setname(ss.getname() + ".pdf"); // if allowed send emails, send email pdf ...

css - Auto show hover effect when scrolling on mobile using jQuery -

i want show hover effects on mobile when scrolling down, i've images have hover effects , want shown on mobile while scrolling .search-results-container .post_title{ border: 4px solid black; width: auto; transform: translate(0,0%); padding-top: 54%; background: rgba(255, 255, 255, 0.7); top: 15px; bottom: 25px; right: 30px; left: 30px; position: absolute; padding-left: 30px; visibility: hidden; opacity:0;} .search-results-container:hover .post_title{ visibility:visible; opacity:1; !important} <div class="search-results-container"> <div class="post_title"> <h3 class="entry_title"> <a href="#">josh woodward</a> </h3> </div> <div class="post_image search-results-image"> <a href="#"> <img src="#"> </a> </div> </div> ...

c# - Can we use multiple parameter when we pass the argument by reference -

i'm new programming. wanna ask whether can use key word "ref" when there multiple parameters? static int calc(ref int x, int y) { return x*y; } static void main(string[] args) { int num=2; int multi=calc(ref num, 4); console.writeline(multi); }

cakephp - cant redirect outside an iframe with cakephp3 -

i have application need redirect website ( example below). issue cakephp3 application embedded in wordpress iframe , reason below command executes inside iframe have webpage within webpage. how can redirect webpage outside iframe? //controller if .... return $this->redirect('http://www.xxxxxx/thank-you-application/'); what goes on in vegas, stays in vegas what goes on in iframe, stays in iframe i don't think want possible php (and php framework), maybe getting content of page want load inside iframe with: $http = new client(); $response = $http->get('http://example.com'); $content = $response->body(); and put $content in view in "top level page / mean not inside iframe" (like in financial website), i'm not sure of exact way. the easiest solution send in controller value ($redirect = true) view say: "hey! view, plz open link top level window! / mean outside iframe". write in view (or template): <...

java - Spring Data Mongo Null Query -

i have basic query in dao: query query = new query(criteria.where("userid").is(userid)); program userprogram = mongotemplate.findone(query, program.class); i have basic pojo gets , sets class document annotation...very basic. in example how coalesce , return default user object if there no user? there best practice (aka nullpointer exception checking in service?)

xaml - wpf trigger not effective on style set in code -

in resources.xaml set style datagrid cell <style targettype="datagridcell" > <style.triggers> <trigger property="datagridcell.isselected" value="true"> <setter property="background" value="cornflowerblue" /> <setter property="foreground" value="white" /> </trigger> </style.triggers> </style> in specific datagrid column set foreground manually sub new() fontweight = fontweights.bold foreground = brushes.blue end sub when cell selected, background dose change trigger, foreground dosen't i believe due fact set forground in code what can solve this? note: cannot set foregroud column in xaml writing foreground = brushes.blue set local value foreground dependency property. local value has higher priority setter value trigger. advise create named style datagridcell, derived base...

iOS AVPlayer flash a frame when seek a paused video -

avplayer paused @ 10.0 seconds, after while, call seektotime:cmtimemakewithseconds(15.0, 1000) tolerancebefore:kcmtimezero toleranceafter:kcmtimezero, screen first show frame @ 10.02 , show frame 15.0, should not show frame @ 10.02 first. should avoid flash? thanks in advance!

python - Parallel calls to CouchDB -

i'd stress test clouddb cluster python3 can't multithreading work properly. have used google , there many ways this, of them way complicated me and/or use case. what try save document couchdb on 3 nodes @ same time. how use simple way of multithreading possible this? import couchdb import random import time import _thread servers = { "pizerogrijs": "http://admin:admin@pizerogrijs.local:5984/", "pizerogeel": "http://admin:admin@pizerogeel.local:5984/", "pizeroroze": "http://admin:admin@pizeroroze.local:5984/" } databasename = 'testhijs' class bank(object): def __init__(self): self.dbs = {} s in servers: self.dbs[s] = couchdb.server(servers[s])[databasename] def showdbs(self): print(self.dbs) def randomwrite(self, data): randomdb = self.dbs[random.choice(list(self.dbs))] return(randomdb.save(data)) def directwrite(s...

how to judge client's network off-line or online use JavaScript? -

this question has answer here: detect internet connection offline? 13 answers if(window.navigator.online==true){ alert("connect success") }else{ alert("fail") } window.navigator.online return true whatever in off-line or online.any other methods solve problem? thanks. if understood issue correctly, answered here : detect internet connection offline? we can mark duplicate same question.

How facebook marketing work without cookies and using customer-id? -

i read here "typical digital retargeting technologies rely on cookies, they’re not accurate. if have multiple people sharing computer, or if audience moving between desktop, mobile or tablet devices, wasting budget on wrong audience.one great way reach real people custom audiences website. these identify people facebook ids have visited specific product pages or added products cart. " i didn't clear how facebook getting facebook ids because pixel fired code fired website common users? are assuming user logged facebook same browser? if yes, app users i.e. never able re-target our app users? how facebook tracking customer id pixels fired?

javascript - Youtube api -how to return nextpage token from fuction? -

using youtube api playlist items. there more 50 in list need build loop them. when button clicked i'm calling function return 50 @ time build loop items. having problems returning nextpagetoken function. couldn't figure out way return data got point i've plugged nextpagetoken html of div inside function but, once function finishes when try html value returns blank. the console.log('nextpagetoken: ' + data.nextpagetoken); command shows correct value. the console.log('after call: ' + next); command shows blank value. also, 'after call' command appears in console log before 'nextpagetoken' log. any received. here's javascript , html: $(document).ready(function() { var loop=0; var data; var next=''; $('#get').click(function(){ getvids(); next=$('#pagetoken').text(); console.log('after call: ' + next); }); function getvids(page){ $('#results').html...

c++ - Calling of delete after construction throwing an exception -

i'm reading effective c++ 3rd edition, item52 "write placement delete if write placement new". i want how make operator delete automatically called after construction throwing exception. #include <iostream> using namespace std; class { int i; public: static void* operator new(std::size_t size) throw(std::bad_alloc) { return malloc(size); } static void operator delete(void* p) throw() { cout << "delete" << endl; free(p); } a() { throw exception(); } }; int main() { a* = new a; } the above codes output: terminate called after throwing instance of 'std::exception' what(): std::exception [1] 28476 abort ./test_clion reference: operator delete, operator delete[] i should write new in try {} . know little exceptions now. #include <iostream> using namespace std; class { int i; public: static void* operator new(std::size_t size)...

arrays - Add text of UILabel from database by loop - Swift 3 -

Image
i'm creating uilabel for loop , wanna adding text in uilabel database, text in database string i'm converting string array characters , example i've 4 labels , 4 characters (a, b, c, d), i want add each characters in 1 label how can ?? i wanna create : and code : func createtarget(id: int) { listdata = dbhelpr.getdatabase(rowid: id) var targetheigt = cgfloat() let viewwidth = self.view.frame.size.width if viewwidth == 320 { targetheigt = 2.5 } else { targetheigt = 5 } data in listdata { // listdata (database) has variable (ans) let yaxis : cgfloat = (self.view.frame.height) * 60% let = data.ans.length // char count let width: int = int(view.frame.size.width) - 40 // frame width var targetwidth: int = (width - (i - 1) * 5) / if targetwidth > 50 { targetwidth = 50 } let totalwidth: int = (targetwidth * i) + ((i - 1) * 5) ...

Openlayers does not print layer from geoserver -

i try print geoserver layer on website. application , geoserver instance running on separate tomcats , use different ports. i have noticed in firefox' network inspector logs appropriate png images downloaded geoserver. noticed http requests such as: http://localhost:8081/geoserver/wms?service=wms&version=1.3.0&request=getmap&format=image/png&transparent=true&layers=graves:graves&tiled=true&styles=graves&cql_filter=not(id < 0)&width=256&height=256&crs=epsg:2001&bbox=4762.7,-7860.5599999999995,4905.6900000000005,-7717.57 and when use such link in browser gives me png of elements. application not print of elements. my code somehow that: var projection = new ol.proj.projection({ code: 'epsg:2001', extent: [4762.7, -8003.55, 4950.55, -7717.57], units: 'm' }); ol.proj.addprojection(projection); var mapcenter = [4880, -7930]; var mapzoom = 2; var view = new ol.view({ center: mapcenter, ...

Error - I cannot using phone register through Android studio&FireBase -

can give me code illustrates how make phone number registration through firebase? tried that, went wrong code, in beginning of it. screenshot of error attached post. please me figure out how can solve this(or give me example of code). enter image description here you have import gradle files correctly. also, check package name , gradle dependencies used in original project. connect firebase android project mentioned here check out docs sample on phone authentication through firebase. link docs

Rewriting urls for subcategories in wordpress -

i have problem rewriting urls in wordpress page. add_rewrite_rule( '([^/]+)/popular', 'index.php?category_name=$matches[1]&popular=yes', 'top' ); it works fine 1 category but have subcategories , doesn't work: add_rewrite_rule( '([^/]+)/popular', 'index.php?category_name=$matches[1]/$matches[2]&popular=yes', 'top' ); should change sth in line? regards

EOF while scanning triple-quoted string literal in python 3.5 window 7 -

i run code data_dir = r"c:\users\administrator\desktop\gorn" fld = open(os.path.join(data_dir, "ld2011_2014.txt"), "rb") data = [] cid = 250 line in fld: if line.startswith(""";"): continue cols = [float(re.sub(",", ".", x)) x in line.strip().split(";")[1:]] data.append(cols[cid]) fld.close() num_entries = 1000 plt.plot(range(num_entries), data[0:num_entries]) plt.ylabel("electricity consumption") plt.xlabel("time (1pt = 15 mins)") plt.show() np.save(os.path.join(data_dir, "ld_250.npy"), np.array(data)) and got error "eof while scanning triple-quoted string literal"

c# - WPF WebBrowserControl: removal of PDF is slow -

i'm using webbrowser control in wpf display pdf documents. displaying pdf assigning local uri works within few 100 milliseconds. webbrowser.source = new uri(path); but assigning null remove pdf ... webbrowser.source = null; ... takes second. same reassigning new uri without setting source null before. has idea, why assigning null webbrowser.source takes longer loading , displaying pdf document? example: <window x:class="wpfapp1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:wpfapp1" mc:ignorable="d" title="mainwindow" height="350" width="525"> <dockpan...

antivirus - how to block a access to any file or exe vb.net? -

i wondering if new how block , unblock file or executable being opened permanently , unblock file using code in vb.net in advance. you can use code, , can use environment.username name of user, , lock type of file , lock folder : dim fss filesystemsecurity = file.getaccesscontrol(application.startuppath & "\quarantine\" & newtextdoc.text) fss.addaccessrule(new filesystemaccessrule(environment.username, filesystemrights.fullcontrol, accesscontroltype.deny)) file.setaccesscontrol(application.startuppath & "\quarantine\" & newtextdoc.text, fss) and unlock file/folder remove accessrule : dim fss filesystemsecurity = file.getaccesscontrol(application.startuppath & "\quarantine\" & newtextdoc.text) fss.removeaccessrule(new filesystemaccessrule(environment.username, filesystemrights.fullcontrol, accesscontroltype.deny)) file.setaccesscontrol(application.startuppath & "\quarantine\" & newtextdoc.text,...

c# - How to call, Hang up, put on hold and unhold calls using Twilio? -

i have twilio number , understood in order 4 actions(call, hang up, put onhold , unhold calls) need create conference call, don't understand how add twilio number conference , how add number of mobile of client. example, if twilio number " +9728888888" , customer's want call mobile number "+9725555555" – want code examples of : 1. calling customer(from twilio number " +9728888888" mobile number "+9725555555") 2. hold call 3. unhold cold 4. hangout call. i'm using twilio nuget on web api project . can give me code examples , considering numbers gave(twilio , mobile) of 4 scenarios above? appreciate it. btw, saw code example on site: using twilio.twiml; class example { static void main() { var response = new voiceresponse(); var dial = new dial(); dial.conference("moderated-conference-room", startconferenceonenter: false); response.dial(dial); syst...