Posts

Showing posts from February, 2014

PHP Put Span Class into Brackets regex -

this have far: $phones = "samsung galaxy s8~lg g6~iphone 7 plus~ motorola z2"; $phones = str_replace("galaxy s", '<span class="galaxy">galaxy</span>', $phones); $value = preg_replace('/(\d+.*?)(~)/', '($1)$2', $phones . "~"); $value = "<li>". str_replace("~", ",</li><li>", substr($value,0,-1)) . "</li>"; echo $value; and result is: samsung galaxy (8), lg g(6), iphone (7 plus), motorola z(2) what i'm trying put span class inside brackets be: samsung ( galaxy 8 ), lg g(6), iphone (7 plus), motorola z(2) thanks pattern demo/explanation code: ( demo ) $phone='samsung galaxy s8~lg g6~iphone 7 plus~ motorola z2'; $match='/galaxy s(\d+)/'; $replace='( <span class="galaxy">galaxy</span> $1 )'; echo preg_replace($match,$replace,$phone); unrendered output: sam

Calculating the prorata of employee calls per Business Unit in SQL Server 2014 -

i establishing business rules determine number of active call center agents per 30 minutes intervals. we have 2 types of agents: billing & technical ops . we've let billing agents take technical calls, , vice-versa. i have written following code returns call count per agent, per interval , per call type: select hagent.[row_date], case when len([starttime]) = 1 '00:00' when len([starttime]) = 2 '00:30' when len([starttime]) = 3 (left([starttime],1) + ':' + right([starttime],2)) when len([starttime]) = 4 (left([starttime],2) + ':' + right([starttime],2)) end thetime, ([logid]) agents, count(hagent.acdcalls) call_count, case when splitmatrix.[business_unit] '%billing%' 'cdn billing' when splitmatrix.[business_unit] '%techops%' 'cdn tech ops' end bunit [kpi_data].[dbo].[dm_cms_hagent] hagent left join [gemdb].[dbo].[t_prd_

identityserver4 - Can someone explain HttpContext.Authentication.GetTokenAsync("access_token") -

i have implemented asp.net core mvc client using hybrid flow, , wondering httpcontext.authentication.gettokenasync("access_token") does. if need more background on question: the instructions accessing api asp.net core client app controller action follows: var accesstoken = await httpcontext.authentication.gettokenasync("access_token"); var client = new httpclient(); client.setbearertoken(accesstoken); var response = await client.getasync("http://localhost:5001/api/stuff"); there magic in httpcontext.authentication.gettokenasync("access_token") :-) i wondering function might doing. decrypting access token cookie in mvc app domain? ... id4 domain? i sorry have been unable find sufficient documentation on or finding cookie access token may in. have looked here: https://docs.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.authentication.authenticationtokenextensions does know does? link more thorough documentation totally a

git - Parsing file names using ruby Net::SSH -

working on automating task job. issue: have rather large stack of git repos hosted on private git server @ our main office. work @ remote location. goal: need clone many (50+) repos without authenticating , manually typing out filename ever time. this supposed quick , dirty version written in ruby (i'm learning ruby i'm trying use , needs it's for) can use template more fine tuned git operations in future. this have right now: #!/usr/bin/ruby require 'net/ssh' git_server_address = "x.x.x.x" git_server_login = "username" puts "enter password #{git_server_login}" git_server_passwd = gets.chomp $gitnames = [] def getgitnames(address, login, passwd) net::ssh.start(address, login, password: passwd) |ssh| ssh.exec!("cd /git") ssh.exec!("find . -type d -exec echo '{}' \\;") |file| $gitnames.push(file) end end end $gitnames = getgitnames(git_server_address, git_server_login,

Logging messages while entering and leaving a definition in python using a decorator for all definitions -

i not able print print("leaving definition : " + func._name_) in following code snippet from functools import wraps def notification(func): @wraps(func) def with_logging(*args, **kwargs): print("entering definition : " + func.__name__) print("arguments passed : {0} {1}".format(args,kwargs)) d = func(*args, **kwargs) print("leaving definition : " + func._name_) return d return d return with_logging @notification def addition_func(x): """""" return x result = addition_func(4) print(result)

java - Dynamically setting TextView with String.valueOf(intVar) truncates part of intVar -

i have textview starts @ '0' , updated on button press reflect current score total, public int points . textview update, 1 or more of characters in score truncated (for instance, "1580" might display "158" or "15"). when activity completed , sent scoreboard activity, however, points shown correct (the variable passed on intent same variable points ). here relevant java code: public int points = 0; textview currentscorecounter = (textview) findviewbyid(r.id.scorecounter); currentscorecounter.settext(string.valueof(points)); and here scorecounter in xml file: <textview android:id="@+id/scorecounter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:textsize="30dp" android:layout_centerhorizontal="true" android:layout_alignparenttop="true" /> i suspect may have width/height of textview, unsure. you use an

xml - MobileFirst 7.1 - Change android publicSigningKey at build time -

i have mobilefirst android application app authenticity enabled. have different publicsigningkey dev , prod. want know best way choose correct key @ build time based on environment i'm building for. if can reference key file or property, make work. have tried using dtd entity fails because ant builder can't find external file since looks in ant build-file root. not working due ant relative path issues <!doctype application [ <!entity publicsigningkey system "publicsigningkey.xml"> ]> <application xmlns="http://www.worklight.com/application-descriptor"...> <android ...> <security> &publicsigningkey; <packagename>...</packagename> </security> </android> </application>

Is it possible to hyperlink JavaScript array elements into an HTML table? -

this code have done far. want hyperlink websites when array outputted table in html, websites clickable , link respective webpages. reason, code in type="text/javascript" different code in language="javascript" , have no idea why. if provide code language="javascript" appreciated! html: <table id="table"> <tr id="tbody"> <th>mattress type</th> <th>link</th> </tr> </table> javascript: <script language="javascript"> var table = document.getelementbyid("table"); var body = document.createelement("tbody"); var beds = new array(3); beds[0] = ["spring mattress", "king size", "http://factorymattresstexas.com/specials/spring-air/"]; beds[1] = ["rest lumbar support", "queen size", "http://factorymattresstexas.com/specials/beautyrest-lumbar-support"]; beds[2] = ["beauty rest

selenium webdriver - WebDriverError: File not found -

i getting selenium webdriver error: webdrivererror: file not found: /users/foo/bar/nabisco/cdt-now/csv-data/it-de-yasper.csv the thing is, file totally exists on filesystem. selenium server running locally. not sure why cannot find file. know? if use firefox 55, recent bug causes exception occur if file present. see https://github.com/mozilla/geckodriver/issues/858 . until bug fixed, there workaround: setting firefox preference "dom.file.createinchild" "true". for instance: firefoxprofile profile = new firefoxprofile(); profile.setpreference("dom.file.createinchild", true); desiredcapabilities capabilities = desiredcapabilities.firefox(); capabilities.setcapability(firefoxdriver.profile, profile); webdriver driver = new firefoxdriver(capabilities);

reactjs - How to specify a port number in a create-react-app based project in production? -

i deploying website have few react projects built create-react-app. each project on own webpage: e.g.: mywebsite.com/project1, mywebsite.com/project. setting nginx reverse proxy on ubuntu server (which understand how configure), not sure how specify port numbers each of create-react-app projects each of them has unique port. can shed light on how this? thanks! ps - have seen threads such 1 - how specify port run create-react-app based project? , not see how solution can applied in production. the server start npm start command in create-react-app webpack dev server. meant use while development , shouldn't use in production environment. instead, can host cra app simple static file server can easily configure nginx without reverse proxy or changing port of dev server. need run npm run build command , deploy content of build folder appropriate folder of static file server. can read more in the documentation of cra . also, make sure specify homepage in packa

android - Glide v4 and Listview -

i have listview custom baseadapter , search toolbar filter list, every time tap on toolbar or put filter (read: every time list refreshed) there flickering due images reloading... how can avoid this? @override public view getview(final int position, view convertview, viewgroup parent) { viewholder holder; if (convertview == null) { convertview = inflater.inflate(r.layout.listview_row, parent, false); holder = new viewholder(); holder.flag = (imageview) convertview.findviewbyid(r.id.flag); holder.name = (textview) convertview.findviewbyid(r.id.name); holder.place = (textview) convertview.findviewbyid(r.id.place); convertview.settag(holder); } else holder = (viewholder) convertview.gettag(); holder.name.settext(customlist.get(position).name); holder.place.settext(customlist.get(position).city + ", " + customlist.get(position).region + ", " + customlist.get(po

javascript - Angular: trying to submit coordinates array -

i'm developing geolocation api, , i'm having hard time submitting 2 coordinates merged array. in mongoose schema, have this: geolocation: { type: { type: string, default:"point" }, coordinates: [number], }, in index.html, have input input ng-model='values[0]' type='text' input ng-model='values[1]' type='text' in controller, i'm trying function maincontroller($scope, $http) { $scope.formdata = {}; $scope.values=[]; $scope.createlocation = function() { $scope.formdata.geolocation.coordinates = new array(2); $scope.formdata.geolocation.coordinates.push({ 0: $scope.values[0], 1: $scope.values[1] }); $http.post('/api/places/:location', $scope.formdata) .success(function(data) { $scope.formdata = {}; // clear form our user ready enter $scope.locations = data;

elasticsearch - Elastic Search: Fulltext searching with wildcards and "boost" by order in query -

i'm trying solve fulltext search problem. i search " something or something or something ", first " something " should have higher score second , on.. does have advice, tip, anything? i've been trying solve problem 3 days already, read documentation , have literally no idea. :) thank in advance

swift - iOS navigationBar not changing color when I set new font -

Image
i'm working on simple church app. , i've started slide-out menu , can't seem change color of font of navigationbar when set new font. colors change when don't have line of code written font change. but, add line of code font change, color goes default. i've provided code below, , pictures go along them. i've tried putting function in appdelegate (i saw multiple forums saying trick), nothing seems working. when this, color changed. func customizenavbar() { navigationcontroller?.navigationbar.tintcolor = uicolor(colorliteralred: 255/255, green: 255/255, blue: 255/255, alpha: 1) navigationcontroller?.navigationbar.bartintcolor = uicolor(colorliteralred: 0/255, green: 0/255, blue: 0/255, alpha: 1) navigationcontroller?.navigationbar.titletextattributes = [nsforegroundcolorattributename: uicolor.white] } when add nsfontattributename line of code, font type changes, color goes black. func customizenavbar() { navigationcontrol

javascript - React does not recognize my function -

i developing application in reactjs, utilizing redux architecture. application using third-party api gets called when submit city search bar. in testing it, console error reads: uncaught typeerror: this.props.fetchweather not function i unclear why react tells me fetchweather not function when exists function here on src/actions/index.js: import axios 'axios'; const api_key = 'spj3q-9huq]-hq -9hq 0rgjeth9e'; const root_url = `http://api.openweathermap.org/data/2.5/forecast?appid=${api_key}`; export const fetch_weather = 'fetch_weather'; export function fetchweather(city) { const url = `${root_url}&q=${city},us`; const request = axios.get(url); return { type: fetch_weather, // optional property // promise passed in payload: request }; } this.props.fetchweather(this.state.term); need fetch weather data , line of code exists in container/search_bar.js: import react, {component} 'react'; import {connect} 'rea

vim plugin - What is NetrwBrowseX and what are the related vim mappings for? -

i map vim keys search , something. i've been doing decades, when now, takes on second each time use mapped key. i believe cause this, response ":map" in vim: n gx <plug>netrwbrowsex n <plug>netrwbrowsex * :call netrw#netrwbrowsex(expand("<cword>"),0)<cr> what these mappings for, , how can rid of them? the map i'm adding today is :map g nz. simply every time find searched term, it's centered in screen can compare contexts. try nunmap gx . from source code netrw.vim : " s:netrwbrowsex: (implements "x") executes special "viewer" script or program {{{2 " given filename; typically means given extension. " 0=local, 1=remote fun! netrw#netrwbrowsex(fname,remote)

python - Exit program without triggering exception handling -

i wasn't sure how title question, issue this; have program set guess number , handle exceptions. program loops until number guessed, when program exits, exception message shows @ same time. how can fix this? num = none while num != 31: try: num = int(input("what age of creator? \n")) if num < 31: print("higher! guess again! \n") elif num > 31: print("lower! guess again! \n") elif num == 31: print("good guess!") exit() except: print("numbers only! \n") this output: what age of creator? 31 guess! numbers only! process finished exit code 0 if want keep exception message, recommend break instead of exit , more natural exit program. try this: try: ... elif num == 31: print("good guess!") break except valueerror: print("numbers only! \n") also, should catch specific

node.js - npm command not working after installing nodejs in windows10? -

Image
i have installed nodejs nodejs website. when typed node -v it gives me version as 6.11.2 but when type npm -v doesnt gives me results. have done reinstalling nodejs several times. my installation path c:\program files\nodejs any help? https://github.com/nodejs/node/issues/2786 solved issue. have renamed .npmrc file , runs perfect.

javascript - How to rename multiple services in Angualr Js? -

Image
the code base , working build upon angularjs 1.4.6.i have migrated angular 1.5.11 , result angular-ui needs upgraded well. when upgrading angularui bootstrap version 0.14.3, breaking changes renaming of prefixes. earlier $modal & $modalinstance $uibmodal & $uibmodalinstance . the earlier syntax using service in controller : angular.module('main').controller('mainctrl',function($scope,$modal...) { $scope.open = function() { var modalinstance = $modal.open({ templateurl: 'modal.html', controller: 'modalctrl', size : 'md', resolver : { data: function() { return $scope.items; } } }) modalinstance.result.then(function() {}, function () {}); } }); angular.module('main').controller('modalctrl',function($scope,$modalinstance,data) { console.log(data); }); now $modal , $mod

jquery - Stopping modal popup after first visit -

i have modal popup (from topmodal) on website (i know they're annoying client insisted!) pops after 3 seconds of landing on page. is there way can have pops after first visit? ...so if user goes homepage won't popup again. if so, please explain how done please (i'm still learning)? ;( function( $, window, document, undefined ) { 'use strict'; var pluginname = 'topmodal', defaults = { topmodal: '.js-topmodal', topmodalbtn: '.js-topmodal-btn', topmodalbtnclose: '.js-topmodal-btn-close', topmodalcontainer: '.js-topmodal-container', topmodaloverlay: '.js-topmodal-overlay' }; function plugin ( element, options ) { this.element = element; this.settings = $.extend( {}, defaults, options ); this._defaults = defaults; this._name = pluginname; this.init(); } $.extend( plugin.prot

tensorflow - CNN-> LSTM network for videos -

i have x number of videos , each video has different number of frames, let's y(x). frames size same videos 224x224x3. passing each frame cnn , outputs feature vector of 1024. now, want pass lstm. lstm batch_size, time_steps , number_of_feature required. how should decide value ? have 2 configurations in mind not know how should proceed. should break 1024 32 x 32 define time_steps , number_of_features , batch_size number of frames should time_step should corresponding number of frames , number_of_feature should 1024 , batch_size (?) so depends on problem trying solve. action classification using videos? if trying predict action/event video have use num_of_frames time_steps , , batch_size number of videos want process together. per frame object classification ? in case can split features 32x32 time_steps ,

swift - Frame width is not the full screen width -

i'm adding gradient view , it's cutting off width on 1 side. my code adding gradient is let gradientlayer = cagradientlayer() gradientlayer.frame = fadeview.frame gradientlayer.colors = [uicolor.maincolor().cgcolor, uicolor.white.cgcolor] fadeview.layer.addsublayer(gradientlayer) the fadeview inside of vertical stackview , inside of view inside of scrollview , of have horizontal constraints on left , right of 0, not constraining margins. the frame width fadeview (and other views other main view) 320, might because of device i'm testing on. width of screen 375. what's causing cut off this? change gradientlayer.frame = fadeview.frame to gradientlayer.frame = fadeview.bounds

javascript - How to define a recursive object with a single expression? -

for example, given object: let foo = {foo:1}; let bar = {a:foo,b:foo}; we can define bar single expression writing as: let bar = (($0)=>({a:$0={foo:1},b:$0}))() however, given object: let o = {a:'perfect'}; o.circle = o; is possible recreate structure of o single expression? this won't work: (($0)=>($0={a:"perfect",circle:$0}))() because circle nested , $0 has been defined yet. unless want solve getter properties, assignment unavoidable. there kinds of ways that, within single expression: let o = (o = {a:'perfect'}).circle = o; but recommend focus on clarity , use iife instead: const o = (function(){ const x = {a:'perfect'}; x.circle = x; return x; }()); // more first solution without mutable `o` variable: const o = (x => x.circle = x)({a:'perfect'});

C# post request stuck in WaitingForActivation even with timeout -

i trying simple post request using httpclient (which far can tell current correct way handle post requests.) however, code stalling on timeouttask.result, tasks stuck on status=waitingforactivation. looking @ server side of things, can tell post request being sent , data being returned, , have called wget manually , verified text data correctly returned server post request. this happened when called task.result, tried add timeout task, must making mistake async because still hangs on timeouttask.result. class httppostexample { private static readonly httpclient client = new httpclient(); public void processsentence() { string uri = "http://localhost:9000/?properties={%22annotators%22%3a%22tokenize%2cssplit%2cpos%22%2c%22outputformat%22%3a%22json%22}"; string result = postsync(uri, "the quick brown fox jumped on lazy dog"); debug.writeline(result); } public static async task<

json - Express is sending an object with an object inside -

i have express server hooked mongoose db (my terminology might not correct, have started learning express). when access /admins (route?) receive object json object inside. am sending incorrectly? var userschema = new schema({ firstname: {type: string, trim: true}, lastname: {type: string, trim: true}, classyear: number, email: {type: string, unique: true, sparse: true, trim: true}, phone: {type: string, unique: true, sparse: true}, phoneprovider: {type: string, trim: true}, isadmin: {type: boolean, index: true}, issuperadmin: {type: boolean, index: true}, hash: string, companyname: {type: string, trim: true}, interests: [string], }, { toobject: { getters: true }, timestamps: { createdat: 'createddate', updatedat: 'updateddate' } } ); part of admins.js exports.createadmin = function(req, res, next) { if (typeof req.body.email !== 'string') return res.status(400).send('missing email'

python - TensorFlow 1.3 GPU version not working on Windows 7 -

i beginner machine learning, , trying set tensorflow python environment using anaconda. however, have been dealing common problem of "no module named "pywrap_tensorflow_internal"" >>> import tensorflow tf traceback (most recent call last): file "c:\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_ tensorflow_internal.py", line 18, in swig_import_helper return importlib.import_module(mname) file "c:\anaconda3\envs\tensorflow\lib\importlib\__init__.py", line 126, in im port_module return _bootstrap._gcd_import(name[level:], package, level) file "<frozen importlib._bootstrap>", line 985, in _gcd_import file "<frozen importlib._bootstrap>", line 968, in _find_and_load file "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked file "<frozen importlib._bootstrap>", line 666, in _load_unlocked file "<frozen

c# - Angular js Replace html string with Tokens -

i have value coming model relatively huge html string. has token needs replaced value angular. trying see how both of ends meet. my html <h2 class="sub-title"> @model.welcometext </h2> now welcome text relatively html string has token. "hi @@name , welcome our website. click <a href='#'> here </a> more details. <small> more details please visit blah blah </small> now need replace @@name model value in controller- $scope.name i tried <h2 class="sub-title" ng-init= $scope.welcometext('@model.welcometext') </h2> and in controller function welcometext(str) { return str.replace('@@name',$scope.name); } but breaks in html because of $scope.welcometext has invalid values inside ng-init any pointers on how achieve this? model.title sitecore cms. dont have value in js i ended doing this. not sure if ideal solution atleast works. //added div hidden class v

r - Long to wide on multiple columns by data.table -

i have question data.table 's melt , dcast multiple columns. browsed on stackoverflow many similar posts not want. explain below. first, data causes of problems , value amount. here part of data : id type problem1 value1 problem2 value2 problem3 value3 1 x 500 y 1000 z 400 2 x 600 z 700 3 b y 700 z 100 4 b w 200 v 200 5 c z 500 v 500 6 c x 1000 w 100 v 900 second, id unique. type contains three( a , b , , c ). there 5 problems. take id == 1 example. type a , contains 3 problems( x , y , , z ). problem x has value 500 , problem y has value 1000 , problem z has value 400 . take id == 5 example. type c , contains 2 problems( z , v ). problem z has value 500 , problem v has value

python - correctly overloading the __add__ of a namedtuple -

i'm trying overload __add__ method on namedtuple instances , i'm having bit of trouble. the parameters input namedtuples dynamically generated. 4 parameters same , in same order, rest can , in number. need able dynamically define namedtuple class factory. , after create several instances, i'd able add them new namedtuple instance, unique parameters together. having trouble overloading __add__ method. doesn't seem work. so example, if have 3 namedtuple instances e = row(a=1, b=2, c=3, d=4) m = row(a=1, b=2, c=3, d=4, param1='a', param2='b') t = row(a=1, b=2, c=3, d=4, param3='val', param4=10) i'd able add them e + m + t returns row(a=1, b=2, c=3, d=4, param1='a', param2='b', param3='val', param4=10) here current code class row(object): ''' creates new namedtuple object ''' __slots__ = () def __new__(cls, *args, **kwargs): ''' make new r

javascript - How to select :host with a class in css for web components? -

in new v1 web components specs, can use :host target custom element. attached class a custom element, , had css selector :host.a , styles not being applied. know how fix this? thanks as per documentation : for example, had component shadow tree following: <x-foo class="foo"> <"shadow tree"> <div class="foo">...</div> </> </x-foo> for stylesheet within shadow tree: ... ' :host(.foo) ' matches <x-foo> element. as op has commented, would, in case, translate to: :host(.a) { ... }

I am Using Google Cloud Platform Service to implement OCR Functionality -

Image
i making app functionality extract data or text image have set api key free trial saying please enable billing. when going step towards billing , accepting terms & conditions give me error "unexpected error occurred ". please check error screen shot below. please me resolve problem.

javascript - How to call /cart/update.js in debut theme of shopify -

Image
all shopify experts knowing default debut theme not having version of ajax api. i developing own website need use cart update ajax. i have tried below code giving me errors in console. jquery.post('/cart/update.js', {updates: {90231456621: 2}}); screenshot: answer: (so other people having similar problems can see issue solved) the id passing product id, id shopify expects of it's add/change/update endpoints variant id. changing legal variant id should solve problem. cheers!

c++ - What is the difference between Dynamic Array and Dynamically allocated array? -

according wikipedia page on dynamic array, they're not same thing. wiki page. how memory allocation in both array work, need keep in mind while using either of them , 1 prefer. p.s. : i'm new programming a dynamic array similar array it's size dynamic , grab more memory when full , add new element it. can created on stack or on heap. a dynamically allocated array array created on heap.

spring mvc - Quartz thread count and data source pool max size -

i have spring mvc 4.1.3 & hibernate 4 based web application deployed in jboss eap 6.3. use quartz schduler version 2.1.7 my quartz thread count set 50 , using jdbc based job store. <prop key="org.quartz.threadpool.threadcount">50</prop> <prop key="org.quartz.jobstore.class">org.quartz.impl.jdbcjobstore.jobstoretx</prop> and data source connection pool max size set 30 in jboss standalone.xml <pool> <min-pool-size>5</min-pool-size> <max-pool-size>30</max-pool-size> </pool> i want undetstand if there issue in db connectivity becasue have thread count higher connection pool max size? thanks in adavce.

SQL Server Table Calculations -

Image
given: +-----------+---------------+-------------+-------+ | name | item | year | value | +-----------+---------------+-------------+-------+ | company | sales | 2017 | 100 | | company | sales | 2016 | 100 | | company | sales | 2015 | 400 | | company | profit | 2017 | 50 | | company | profit | 2016 | 50 | | company | profit | 2015 | 200 | | company b | sales | 2017 | 200 | | company b | sales | 2016 | 100 | | company b | profit | 2017 | 20 | | company b | profit | 2016 | 20 | +-----------+---------------+-------------+-------+ how use sql transform to: +----------+---------------+--------+-----------+ | name | year | margins| 2 yr ave | +----------+---------------+--------+-----------+ | companya | 2015 | 50% | null | | companya | 2016 | 50% |

TinyMCE: iPad forceful maintain the focus in the textarea -

under ipad, in tinymce, while entering keywords , hide ipad keyboard. after that, add link or table, add first location of textarea(due no focus on textarea). ideally, should add last location cursor was? any work around on this?

java - Send whole content to mail in pdf after clicking a button in jsp -

i creating java server page. has button send email. after clicking button whole page content should sent pdf client attachment. not want store pdf on server. you can use itext generate pdf document without having physically create file. example: file out = new file("somewhere.pdf"); pdfdocument pdfdocument = new pdfdocument(new pdfwriter(new filewriter(out))); document layoutdocument = new document(pdfdocument); layoutdocument.add(new paragraph("hello world")); layoutdocument.close(); in particular example i've used filewriter, writer do. so bytearrayoutputstream baos = new bytearrayoutputstream(); writer w = new outputstreamwriter(baos); // itext logic here ... // add bytes email byte[] mimebytes = baos.tobytearray(); ... check out documentation itext @ http://developers.itextpdf.com/content/itext-7-jump-start-tutorial/examples

githooks - git pre-commit hook not running when running git commit -a -

i have local pre-commit hook executes, , stops commit expected when run git commit also, expected, can bypass hook when run git commit -n ... however, running git commit -am "my message" or indeed, git commit -a seems bypass hook , allow commit processed. any idea why may happening? edit : hook below. project_root=`git rev-parse --show-toplevel` changed=`git diff --stat -- $project_root/myproj/myfile.ext | wc -l` if [ $changed -gt 0 ]; echo "myfile.ext file has changed, sure want commit" echo "use -n parameter process commit." exit 1 fi so, user error.. the hook running in both instances, logic used detect change in file didn't work when -a command supplied. checking against remote repo did trick. changed=`git diff origin/master --stat -- $project_root/myproj/myfile.ext | wc -l` edit : @torek, more appropriate way check change is: changed=`git diff --cached --stat -- $project_root/myproj/myfile.ext | wc -

WordPress Contact Forms appear as sent from the customer -

i searching way how setup wordpress contact form email sent inbox appear if would've sent customer filled-in form; i.e. email address specified on form appear 'from-field' in message. make reply customers easier. thanks; –adam

javascript - Check weather internet is available or not -

this question has answer here: detect internet connection offline? 13 answers i need html code. need integrate javascript in upon loading checks whether internet available or not. if active should perform specific task, else should show "no internet". `<html> <head> </head> <body onload="myclickhandler(); starttime()"> <script language="javascript"> var t; document.onclick = myclickhandler; function myclickhandler() { cleartimeout(t); t = settimeout("location.href='index.html'", 60000); //for refreshing page in every 60 sec. } </script> <h1> test </h1> <script type="text/javascript"> var url = "https://www.google.co.in"; var img = new image(); img.src = url; i

r - How to calculate the volume under a surface defined by discrete data? -

i need determine volume beneath series of surfaces represented discrete data points. in data, each sample stored separate data frame within list of data frames. here (small) example data: df1 <- data.frame(x=c(2,2,2,3,3,3,4,4,4,5,5,5,6,6,6), y=c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3), z=c(0,2,0,4,6,7,3,2,1,2,7,8,9,4,2)) df2 <- data.frame(x=c(2,2,2,3,3,3,4,4,4,5,5,5,6,6,6), y=c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3), z=c(1,1,2,3,5,6,2,1,3,3,8,9,8,3,1)) df <- list(df1,df2) answers similar questions either in other languages (matlab, python), or answers not contain useable script address problem ( as here ). can think of 2 acceptable ways estimate volume beneath each surface: 1) write out discretized version of simpson's rule function in r applied across list of data frames (df); 2) calculate arbitrary relationship between x, y, , z , use multivariate numerical integration find volume under surface (with functi

angular - TypeScript:Undefined value when get value in table -

Image
how can value of table in typescript, ? mycomponent.ts : let jsonusers = []; getuser() { // when console ==> response on picture console.log(this.jsonusers ); // want value of code , label not worked console.log(jsonusers.length); // ==> 0 (var index = 0; index < this.jsonusers .length; index++) { var element = this.jsonusers [0]; console.log(element.code); } looks array has no elements on it, see in console's output object's keys. try this, , let know see let jsonusers = []; getuser() { const keys = object.keys(this.jsonusers); keys.foreach((k, i) => { const element = this.jsonusers[k]; console.log(element.code) }) } or option using for...in let jsonusers = []; getuser() { (let k in this.jsonusers) { const element = this.jsonusers[k]; console.log(element.code) } } note this.jsonusers different variable jsonusers , keep in mind

javascript - custom html content in data-ng-options -

here code. i'm loading options in select controller data-ng-options, want add icon these items. example want add <span class="fa fa-plus"></span> @ end of each option <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body> <div ng-app="myapp" ng-controller="myctrl"> <select ng-model="selectedname" ng-options="item item in names"> </select> </div> <script> var app = angular.module('myapp', []); app.controller('myctrl', function($scope) { $scope.names = ["emil", "tobias", "linus"]; }); </script> <p>in above list need icon @ end of eact option</p> </body> </html> you can use $sce of ngsanitize module this var app = angular.module('myapp&#

Php view execl and xls file on browser -

i display execl file within browser similar how pdf file viewed.is there way accomplish this. have used execl library , not fulfil requirements. here example used in excel not working header('content-type: application/pdf'); header('content-disposition: inline; filename="' . $filename . '"'); header('content-transfer-encoding: binary'); header('accept-ranges: bytes'); i used phpexcel library viewing execl file on browser not working

amazon web services - HTML link to S3 videos, images -

i have videos , images on s3, want use instead of saving locally. have uploaded each image, if want link image in tags, or view in browser get: public/images/facebook.png instead of actual image, here link used taken s3 bucket: link: https://s3.eu-west-2.amazonaws.com/liveandnow-development/public/images/facebook.png i see this: <error> <code>nosuchkey</code> <message>the specified key not exist. </message> <key>public/images/facebook.png</key> <requestid>...</requestid> <hostid>...</hostid> </error> this error indicates there no object @ public/images/facebook.png . in fact, there 2 objects in bucket. how know this? bucket security settings incorrectly allowing list objects. should fix promptly.

Generate file on git branch create -

every time new branch specific prefix (e.g. "release/...") created, need perform action. server-side update hook, client-side handling not sufficient considering requirement. the action need perform reading contents of file (lets call a.txt ) in git branch. file present, not have affected commit or similar. need generate new file ( b.txt ) based on contents of read file , add generated file ( a.txt ) newly created branch. so outcome this: git-root | +---release/1.5.6 | +---somedirectory +---a.txt // file need read +---b.txt // generated git-hook is possible , if yes, how can achieve this?

node.js - request command equivalent to cURL command not working -

curl command: curl -f "json_query=</users/somename/desktop/api/payload/upload_image_payload.json" -f "file=@/users/somename/desktop/api/payload/image.png" http://url/api/upload_outgoing_media.php node.js command: var options = { method: 'post', url: 'http://url/api/upload_outgoing_media.php', headers: { 'content-type': 'multipart/form-data; boundary=----webkitformboundary7ma4ywxktrzu0gw' }, formdata: { json_query: { value: 'fs.createreadstream("/users/somename/desktop/api/payload/upload_image_payload.json")', options: { filename: '/users/somename/desktop/api/payload/upload_image_payload.json', contenttype: null } } }, file:

c# - Xamarin Resource designer does not update properly -

i have visual studio solution containing xamarin android project. since migration vs17, resource designer xamarin started behaving strangely. if add new xml layout in resources/layout folder, resource designer notice after exclude, , re-include new file. however, if these steps reproduced second new file, resource designer notice second new file, first 1 erased. this makes refactoring impossible, , leads corrupted project. has workaround ? visual studio 2017 entreprise version : 15.3.0 xamarin version : 4.6.0.295 (306f67a) on android, files in resources folder should have build action set 'androidresource' in order resource designer notice them. so when add existing files, make sure build action set properly. same goes files in resource folder on ios. only, build actions called 'bundleresource'.

html - Css hover triggering on a completely random element -

i making nested html menu. , reason, hover keeps triggering way before hover on correct element. it's if div or element triggering before hand. i think has html structure , way calling hover in css. see snippets below - /*car assistant styles*/ .car-assist-container { position: relative; float: left; width: 210px; } .assist-label { display: block; font-size: 1em; float: left; padding: 7px; text-transform: uppercase; color: black; } .assist-label:hover > .assist-list { opacity: 1; height: auto; } .assist-list { width: 100px; background-color: #141825; height: 0; opacity: 0; -moz-transition: 0.4s ease; -webkit-transition: 0.4s ease; -o-transition: 0.4s ease; transition: 0.4s ease; display: block; } .assist-item{ color: white; display: block; width: 100%; padding: 8px; border-bottom: 1px solid #1d2435; font-family: 'montserrat', sans-seri