Posts

Showing posts from June, 2010

bash - need help modifying a script to check service status -

i have script gets called remotely check status of service , echo whatever tell to. external process calls script determines service gets checked. instead of echoing custom message need echo out actual output of command. here script now: #!/bin/bash s1="active" info=$(systemctl status $1 | awk 'nr==3' | awk '{print $2}') if [ $info == $s1 ] echo $1 "is running!" exit 0 else echo $1 "is not running!" exit 2 fi as can see, pretty basic , scripting not cup of tea works. need make more complex. in script instead of echoing out "$1 running" or "$1 not running" need change 2 echo result command giving me 3rd line only. need echo this: active: active (running) since fri 2015-10-30 14:58:47 cdt; 1h 7min ago which actual result of command in script excluding awk '{print $2}' and if result comes "active running" or "active exited", etc.. needs exit 0. if result comes ot

node.js - What is the best approach in nodejs to switch between the local filesystem and Amazon S3 filesystem? -

i'm looking best way switch between using local filesystem , amazon s3 filesystem. i think ideally wrapper both filesystems can code against. configuration change tell wrapper filesystem use. useful me because developer can use local filesystem, our hosted environments can use amazon s3 changing configuration option. are there existing wrappers this? should write own wrapper? there approach not aware of better? i idea build wrapper can use either local file system or s3. i'm not aware of existing provide you, interested hear if find anything. an alternative use sort of s3 file system mount, application can use standard file system i/o data might written s3 if system has location configured s3 mount. don't recommend approach because i've never heard of s3 mounting solution didn't have issues. another alternative design application use s3, , use sort of s3 compatible local object storage in development environment. there several answers this quest

python - Hex characters in arguments to Popen -

i trying pass raw byte array process: import subprocess cmd = ["./input"] cmd += "\x00" subprocess.popen(cmd) however, gives error: typeerror: execv() arg 2 must contain strings how solve this? this problem occurs me when include null terminator (\x00). every other value, works. try this: for in range(256): cmd = ["echo",chr(a)] try: c = subprocess.popen(cmd) except typeerror: print(a) this gave me 1 value: 0. @ guess, python gets confused when have double null terminators.

node.js - node server is starting automatically and can't be killed -

environment windows 10 pro path setting: c:\program files (x86)\nodejs\ (v0.10.13) c:\program files\nodejs (v6.2.2) node version global: v6.2.2 npm version : 3.9.5 description i installed node.js, , right after installation got problem because nodejs starting background process taking port 8080 must not taken. running command: >netstat -ano | find "8080" tcp 0.0.0.0:8080 0.0.0.0:0 listening 4428 running command: >taskkill /im "node.exe" /t /f success: process pid 6140 (child process of pid 4428) has been terminated. success: process pid 2916 (child process of pid 2776) has been terminated. success: process pid 10888 (child process of pid 2776) has been terminated. success: process pid 4428 (child process of pid 2556) has been terminated. success: process pid 2776 (child process of pid 2560) has been terminated. >netstat -ano | find "8080" but after time server started again: >netst

javascript - setTimeout for client using command -

so i'm trying create "cooldown" system discord bot, i've tried using database method, here doesn't work me. i'm using discord.js package. here code: if (msg.content.startswith("!point")) { var usr = msg.content.split(" ").slice(1).join(" "); if (!usr) { bot.sendmessage(msg, "```error: 1\n reason: please state name.```"); return; } if (usr == msg.author.username) { bot.sendmessage(msg, "```error: 3\n reason: you're unable point yourself.```"); return; } if (!db["users"][usr]) { db["users"][usr] = 0; } console.log(usr + " has " + db["users"][usr]); db["users"][usr] += 1; console.log(usr + " has " + db["users"][usr]); fs.writefilesync('database.json', json.stringify(db)); bot.sendmessage(msg, usr + " has received 1 point"); } unless it's important cooldown

sql - How to keep the value from previous records -

my original table 't1' looks this: id date order_ind var2 var3 1 1/1/2015 1 ..... ..... 1 1/5/2015 1 ..... ..... 1 1/5/2015 2 ..... ..... 2 1/10/2015 1 ..... ..... 2 1/20/2015 1 ..... ..... 2 1/20/2015 2 ..... ..... 2 1/20/2015 3 ..... ..... the final table want create adding additional variable 'new_var' based on criteria. may notice, there records same date, , criteria work on first record (order_ind=1). rest of records same date, such order_ind=2, or 3, new_var value should same order_ind=1 record. id date order_ind var1 var2 new_var 1 1/1/2015 1 ..... ..... 1 1 1/5/2015 1 ..... ..... 0 1 1/5/2015 2 ..... ..... 0 2 1/10/2015 1 ..... ..... 0 2 1/20/2015 1 ..... ..... 1

delphi - Remove tcategorypanel border -

Image
how can remove border tcategorypanel , tcategorypanelgroup in xe3? tried , didn't work: type tcategorypanel = class (vcl.extctrls.tcategorypanel) protected procedure createparams ( var params: tcreateparams); override ; end ; procedure tcategorypanel.createparams ( var params: tcreateparams); begin inherited ; params.style:= params.style , not ws_border; end ; for tcategorypanel need set protected property bevelouter bvnone . for tcategorypanelgroup can indeed remove border in createparams . so: params.style := params.style , (not ws_border); it looks this:

python - How to pass variables between different view functions in Django -

some variables (class object) needs shared among different view functions. each view function changes object's properties. object user-specific, say, user needs log in web page, access different webpage. not want different users share/change object variable. can think of is: using global declare variable in different view functions. however, in running in django runserver multi-threaded, when multiple users access it, global variables changed/shared users? or variable specific each user? using session, however, variable object, not json serializable. store in database, however, object , not allowed store in database. cannot pickle either. what correct way of sharing variables among different view functions while allowing multiple users access server concurrently? thanks, this problem met. please explain little bit, please not down vote without comment, thank you you object user-specific. session-specific? if user open new tab in browser , access page in

java - How to autowire services outside of the constructor? -

is possible add @autowired class, , add constructor class not use these autowired classes? example: public class myjob { @autowired private myservice1 serv1; @autowired private myservice2 serv2; public myjob(string filename) { this.filename = filename; } } here want take myservice1 , myservice2 granted, , initialize class @bean using constructor: @bean public getmyjob1() { return new myjob("test1"); } @bean public getmyjob2() { return new myjob("test2"); } is possible? i think best way make factory myjob's instances: public class myjobfactory { private myservice1 serv1; private myservice2 serv2; @autowired public myjobfactory(myservice1 serv1, myservice2 serv2) { this.serv1 = serv1; this.serv2 = serv2; } public myjob myjob(string filename) { return new myjob(filename, serv1, serv2); } }

Different kinds of load-balacing policies -

i'm doing internship have dynamically scale application according workload. right now, use basic policy : if average cpu of nodes above 60%, add new node, if goes under 20% remove node. wondering if there other types of scaling policies i'm not aware of. thanks. i have worked on different aspects on how load-balancing achieved. can refer blog things mentioned more appropriately. link : www.loadbalancerweb.wordpress.com

ios - Swift: how to censor/filter text entered for swear words, etc? -

i want see whether there established way this, or how 1 go this. i have text field acts form in ios app user can post something. can't have users posting swear words/inappropriate crap, want filter out , display error if string enter contains 1 of these words. how other apps in swift this? search through string see if contains word (obviously not within other words, standing alone) or there method? how can accurately filter out swear words user post in swift? construct list of words consider swear words, , check user entered string whether of these words contained within string. swift 3: import foundation func containsswearword(text: string, swearwords: [string]) -> bool { return swearwords .reduce(false) { $0 || text.contains($1.lowercased()) } } // example usage let listofswearwords = ["darn", "crap", "newb"] /* list lower case */ let userenteredtext1 = "this darn didelo thread no no." let usere

java - Having a static "sub-site" in Wicket (i.e.: mounting a directory in Wicket) -

i'm developing web application using wicket . while of website dynamically generated through wicket, need have portion of site normal "static" html website. small "subsite" inside main website not managed wicket @ all, that, instead, collection of static content (html pages, css, images). can done? idea "mount" subpath point sub-site, don't know if possible, mountresource() method wants resource input. edit: need solution allow me modify static html files directly on filesystem, reason trying "mount directory" via wicket. cannot put pages in webapp folder, since way end inside app's war file , every modification static pages need full deploy every time. any ideas? well, implementet myself in end, using dynamic resource. i'm not expert of wicket, may "bad" solution reason, seems work. posting code here other people can use if want: what did create resource: public class directoryresolverresource

osx - Need help getting gdb to run on OS/X El Capitan (code signing does not work) -

i trying gdb (installed via homebrew) run on os/x el capitan. have gone through multiple posts online code signing, creating certificate, etc., still not work. (see example: how "codesigned" gdb on osx? ) my code signed evidenced by: codesign -vvd /usr/local/bin/gdb executable=/usr/local/cellar/gdb/7.11/bin/gdb identifier=org.gnu.gdb format=mach-o thin (x86_64) codedirectory v=20100 size=44540 flags=0x0(none) hashes=1388+2 location=embedded signature size=1772 authority=gdb-cert signed time=jul 4, 2016, 7:37:55 info.plist entries=4 teamidentifier=not set sealed resources=none internal requirements count=1 size=88 and codesign -vvd /usr/local/cellar/gdb/7.11/bin/gdb executable=/usr/local/cellar/gdb/7.11/bin/gdb identifier=org.gnu.gdb format=mach-o thin (x86_64) codedirectory v=20100 size=44540 flags=0x0(none) hashes=1388+2 location=embedded signature size=1772 authority=gdb-cert signed time=jul 4, 2016, 7:37:55 info.plist entries=4 teamidentifier=not set sea

Mono Method 'SqlParameter.set_TypeName' not found. & fastcgi -

trying run site built under v4.5 profile. i’m building latest docker image: docker run --name=monobuild -it -v `pwd`/src:/var/src -v `pwd`/out/temp:/var/out -w /var/src/ -e mono_iomap=case mono:latest xbuild /var/src/api.admin.sln /p:configuration=local /p:outdir=/var/out/ i had same error when compiling forgot how got go away. now i’m getting when attempting run in docker image: https://github.com/seif/docker-mono-fastcgi-nginx i suspect it’s not loading v4.5 libs have no clue of how configure fastcgi this. the error screen gives : version information: 4.0.4 (stable 4.0.4.1/5ab4c0d tue aug 25 23:11:51 utc 2015); asp.net version: 4.0.30319.17020 i’ve had hell of time trying run in apache/nginx. super appreciated. the web.config has: <httpruntime targetframework="4.5" /> <compilation targetframework="4.5" />

Android NDK in Android studio >=1.4 -

Image
i not consider question duplicate of this , this questions since answered this link , not adaptable later versions of as. i can find information on how integrate android ndk eclipse , eclipse , adt considered deprecated google. when following instructions setup project experimental gradle plugin numerous errors in editor of type cannot resolve symbol new additions error posted below after build. the build.gradle in project. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle-experimental:0.2.0' } } allprojects { repositories { jcenter() } } task clean(type: delete) { delete rootproject.builddir } and build.gradle in app apply plugin: 'com.android.model.application' model{ android { compilesdkversion = 22 buildtoolsversion = "23.0.1" defaultconfig.with { applicationid = "se.einarsundgren.gstr

ios - WKWebView content jumping on load -

Image
i've created simple test app reproduce problem reliably , minimize moving parts. contains navigation controller , view controller add wkwebview to. tell wkwebview navigate www.google.ca . once page has loaded, content automatically jumps underneath header bar. reproducible consistently on various simulators/devices running ios 8/9/9.1. below code viewcontroller: // viewcontroller.swift import uikit import webkit class viewcontroller: uiviewcontroller { let webview = wkwebview() override func viewdidload() { super.viewdidload() view.addsubview(webview) let url = nsurl(string: "http://www.google.ca")! let request = nsurlrequest(url: url) webview.loadrequest(request) webview.frame = view.bounds } } put webview.frame = view.bounds before view.addsubview(webview)

c# - sqlite - database synchro/bakup - windows 10 mobile -

i'm making windows 10 apllication - sales manager. 3 tables. have local sqlite database. i'm looking easy way backup database or synchronize. because databae small think full synchro always, example: i'm clicking 'send database' , full data device send server. when click 'download' database downloaded. grateful advice way save database imho, can take advantage of onedrive's app folder backup sqlite database. the app folder dedicated, special folder app. app folder typically named after app, , found in apps folder in user's onedrive. if request onedrive.appfolder permission scope , user authorizes it, app gets read , write access folder. and c#, can use onedrive sdk csharp in application. example, can send database file following: private async task<item> uploaddbfile() { storagefile dbfile = await applicationdata.current.localfolder.getfileasync("db.sqlite"); var onedriveclient = await onedrivecli

javascript - When one calls addEventListener without a target element what element does it default to? -

addeventlistener("load", run); function run() { //code } the above code appears work when try in web browser. guess because if 1 uses addeventlistener without target element defaults window object? can confirm this? global functions attached global object, window . addeventlistener("load", run); is same as window.addeventlistener("load", run); just alert same window.alert

How can I show an animated full screen View over the rest of the UI and View Hierarchy in Android? -

i trying figure out how handle ui feature want make viewpager appear on everything, scroll through page items, , when press goes away. use full screen dialog this, want apply combination fade animation (fade in on appear , fade out on disappear) scale animation (scale nothing fullscreen on appear , scale down fullscreen nothing on disappear). dialogs seem lot less animation friendly based on dialog , animation interfaces compared views. again, don't know how make view sit on top of since that's dialogs for. seems hard tell lesser evil, potentially benefit more having full screen view on else. need do? edit: point brought @sound-conception should make clear, sadly due application context feature, making separate activity not option right now. you state in question viewpager full screen view. in case implement viewpager seperate activity , use activity transitions. check out google i/o developer video on activity transitions . there's lots of info on dev

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

i trying create customuser django project email username , add radio button truck , company. in registration process email-id registered per truck or company. mentioned radio button 'tag' , add manytomany field tag in emailuser model. when makemigrations, raising error : (fields.e300) field defines relation model 'abstractemailuser' either not installed, or abstract. i quite new django , not sure whether have created correct code wants. please me solving this. here code, models.py: import django django.contrib.auth.models import ( abstractbaseuser, baseusermanager, permissionsmixin) django.core.mail import send_mail django.db import models django.utils import timezone django.utils.translation import ugettext_lazy _ class emailusermanager(baseusermanager): """custom manager emailuser.""" def _create_user(self, email, password, is_staff, is_superuser, **extra_fields): """create , save emailus

database - Passing an SQLiteDatabase delete function a table name as a String in Android -

if run: void deletetablerecords() { sqlitedatabase db = this.getwritabledatabase(); db.delete(table_albums,null,null); db.close(); } i intended result. however, if run: void deletetablerecords(string tablename) { sqlitedatabase db = this.getwritabledatabase(); db.delete(tablename,null,null); db.close(); } with call of deletetablerecords("table_albums") crash , told that: android.database.sqlite.sqliteexception: no such table: table_albums what should passing table name if not string? table_albums name of variable. value else. i guess assigned value table_albums , example: private static final string table_albums = "somevalue"; in case need pass actual value, not name of variable: deletetablerecords("somevalue"); a better approach make public constant: public class dbhelper { public static final string table_albums = "somevalue"; // ... } so

javascript - asp.net mvc angularjs controller throwing error on registration -

i have simple view: @{ viewbag.title = "arbitrary title"; layout = "~/views/shared/_layout.cshtml"; } <div ng-controller="mycontroller myctrl"> <div id="grid" kendo-grid k-options="myctrl.options"></div> </div> with accompanied controller: (function () { "use strict"; /***debugger throws exception here***/ angular.module("myapp").controller("mycontroller", mycontroller); mycontroller.$inject = ['$scope']; function mycontroller($scope) { //for brevity } })(); the console throws exception: error: [ng:areq] argument 'mycontroller' not function, got undefined http://errors.angularjs.org/1.4.0/ng/... i'm new angular, have learned, looks i'm not registering controller correctly? other controllers in project i'm working on registered same way, i'm bit lost. the _layout.cshtml shared

dns - How to use custom domain in blogger, not subdomain? -

i have blog on blogger example.blogspot.com , domain example.com . tried use custom domain blogger , added blogger settings. blog hosted at: blog.example.com i want cname or point domain example.com blog.example.com or example.com blog. don't want domain redirect subdomain bad seo. have seen in google blogger support there option redirect domain blog's subdomain. doesn't appear on blogger settings? don't use blog.example.com . instead use www.example.com . option appear in blogger settings redirect example.com www.example.com . follow this add a-records example.com in hosting provider's dns section.

javascript - dependent dropdown error Undefined index: TRANCHE codeigniter -

i have drop-down dependent on choices of other 2 drop-downs have debugged java script has error on error logs says, undefined index: tranche here controller public function dependent_dropdown() { if(isset($_post['tranche']) || isset($_post['grade'])) { $data = $_post['tranche']; $data1 = $_post['grade']; $this->output ->set_content_type("application/json") ->set_output(json_encode($this->employeesalary_model->gettype($data, $data1))); } } and here javascript jquery(document).ready(function(){ $("#grade").change(function() { var tranche = {"tranche" : $('#tranche').val()}; var grade = {"grade" : $('#grade').val()}; console.log(tranche); console.log(grade); $.ajax({ type: "post", data: (tranche, grade), url: "<?php base_url()

c# - Visual studio crashes when type something in the Code Editor -

suddenly visual studio 2015 update 3 started crashing when try type code. working until friday. happened on weekend. have 5 projects ( 4 class libraries & 1 web project) in solution. vs gets crashed when try type in code editor of data project class library. using ef code first don't think issue related code. related else. i have looked activity.log , found it's due corrupt componentcache . cleared componentmodelcache still problem persists. any suggestion hightly appreciated. activity.log entry pasted below reference. sure many of must have experienced issue. <entry> <record>633</record> <time>2016/07/04 13:55:53.621</time> <type>error</type> <source>editor or editor extension</source> <description>microsoft.visualstudio.extensibilityhosting.invalidmefcacheexception: visual studio component cache out of date. please restart visual studio.&#x000d;&#x000a; @ microsoft.vi

ios - How to add multiple data in Parse in the same row at the same time -

i'm using swift code, , code able store data in parse, doesn't place in same row, if please give me feedback on this, i'm self thought , beginner of coding. thanks. let newtransobject:pfobject = pfobject(classname: "transaction") let pickuptimeobject:pfobject = pfobject(classname: "transaction") let cityobject:pfobject = pfobject(classname: "transaction") // set text key text of messagetextfield newtransobject["pickup_location"] = self.myaddress.text pickuptimeobject["pickup_time"] = self.mytime.text cityobject["pickup_city"] = myplacement.locality //save pfobject newtransobject.saveinbackground() pickuptimeobject.saveinbackground() cityobject.saveinbackground() self.myaddress.text = "\(myplacement.locality!) \(myplacement.administrativearea!) \(myplacement.postalcode!) \(myplacement.isocountrycode!)" self.myaddress.backgroundcolor = uicolor.whitecolor() [enter image description here][1

xaml - How to format WPF StaticResource extension markup string value -

the following code example contains usage of wpf staticresource string value: <system:string x:key="sensor">sensor</system:string> ... <textblock text="{staticresource sensor}" textalignment="center"/> what need insert + char before "sensor" string. (for example: + senser ) it important note usage of textalignment="center" necessary me replacing textblcok label uses horizontalcontentalignmet="center" not option, because text more 1 line. thanks. you can use stringformat property. <textblock text="{binding source={staticresource sensor}, stringformat={}+{0}}" textalignment="center"/>

ios - Choosing Photo's from Camera Roll on every device -

Image
i have app chooses image camera roll or takes photo using camera. problem when run app on ipad, if select image doesn't display full image later on. image select : (notice waterfall pretty entered.) image displayed : (the image displayed wrong) the problem on big devices ipads. i'm saving image using coredata , recovering it. how can display full i'm age? niall you need set uiimageview contentmode scaleaspectfit

java - Incompatible types: DetailOneFragment cannot be converted to Fragment -

Image
i have problem in code error incompatible types: detailonefragment cannot converted fragment in android incompatible types: detailtwofragment cannot converted fragment in android which wrong? this detailactivity.java import android.content.intnet; import android.os.bundle; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.tablayout; import android.support.v4.app.fragmentmanager; import android.support.v4.view.viewpager; import android.support.v7.app.appcompatactivity; import android.view.view; import android.widget.imageview; import android.widget.textview; import org.adnroidtown.albaplanet.r; import org.adnroidtown.albaplanet.review_view.review1activity; public class detailactivity extends appcompatactivity { viewpager pager; tablayout tablayout; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_

haskell - How to response with HTTP status in custom servant handler? -

i created custom servant handler type serviceset = tvar (m.map string [microservice]) type localhandler = readert serviceset io but failed find way response 404-not-found status code client in following function: getservice :: string -> localhandler microservice getservice sn = tvar <- ask ms <- liftio $ sl <- atomically $ sm <- readtvar tvar return $ case m.lookup sn sm of nothing -> [] sl -> sl let n = length sl <- randomrio (0, n - 1) return $ if n == 0 nothing else . head . drop $ sl case ms of nothing -> ??? -- throwerror err404 ms' -> return ms' how send 404 status code in ??? ? you need add exceptt stack of monad transforms. right now, readert , there no way encode notion of error being thrown. {-# language datakinds #-} {-# language typeoperators #-} module lib import control.monad.except import control.monad.reader import data.maybe import d

python - Storing reference to other rows in SQLAlchemy Many-to-Many association table -

i'm working on project in sqlalchemy. let's (to simplify problem) there 3 tables @ play-- blog_posts, users, , users_daily_posts. first 2 this: class blog_posts(db.model): __tablename__ = 'blog_posts' post_id = db.column(db.integer(), primary_key = true) date = db.column(db.integer()) creator_id = db.column(db.integer()) class users(db.model): __tablename__ = 'users' user_id = db.column(db.integer(), primary_key = true) likes = db.column(db.integer()) users_daily_posts = db.relationship('users_daily_posts', lazy='dynamic', backref=db.backref('user', lazy='dynamic')) for third table, expectation has primary keys user_id , date (say date integer), column likes, , column should keep track of blog posts on particular date. when post liked, propagates table , users table, blog_posts not store it. thought date should foreign key, turns out there uniqueness constraint on in original table, , won&#

sql server - Adding Full Text Catalog to VS2013 causes build errors in SQL database project -

i want use db project contain definition of full text catalog , indexes. i've added catalog sql server instance , created index create fulltext catalog [ftscatalog] accent_sensitivity = on default authorization [username_uat]; with index create fulltext index on [dbo].[tablename] ([columnname] language 1033) key index [pk_tablename] on [ftscatalog]; however, sql db project gives error on definition of ftscatalog error 2 sql71501: full-text catalog: [ftscatalog] has unresolved reference object [username_uat] using sql database schema compare tool synchronise user generates user file contains this: create user [username_uat] login [username_uat]; the error moves file, contains oddly looking circular reference. error on second occurrence of username_uat: error 2 sql71501: user: [username_uat] has unresolved reference login [username_uat] in schema compare options object types have users, full-text catalogs , full-text indexes checked. there no option sy

Meteor SignUps Forbidden on Accounts.createUser -

i'm getting error "signups forbidden" when try create user account. ideas why? my packages: useraccounts:materialize materialize:materialize accounts-password accounts-facebook service-configuration accounts-google accounts-twitter kadira:blaze-layout msavin:mongol kadira:flow-router kevohagan:sweetalert client code: template.register.events({ 'click #register-button': function(e, t) { e.preventdefault(); // retrieve input field values var email = $('#email').val(), firstname = $('#first-name').val(), lastname = $('#last-name').val(), password = $('#password').val(), passwordagain = $('#password-again').val(); // trim helper var triminput = function(val) { return val.replace(/^\s*|\s*$/g, ""); } var email = triminput(email); // if validation passes, supply appropriate fields

javascript acces an item of an array? -

i'm beginner javascript used pixi. i don't know how format array row , line. try snippet when want access specific value of array : alert(graphics[2][1].position.x) i have error : uncaught typeerror: cannot read property '1' of undefined(anonymous function) @ main.js:40 here complete snippet : var renderer = pixi.autodetectrenderer(800, 600,{backgroundcolor : 0x1099bb}); document.body.appendchild(renderer.view); var stage = new pixi.container(); var container = new pixi.container() stage.addchild(container); (var j = 0; j < 5; j++) { (var = 0; < 5; i++) { var graphics = new pixi.graphics(); graphics.beginfill(0xff3300); graphics.linestyle(4, 0xffd900, 1); graphics.drawrect(0,0,10,10); graphics.position.x= 40 * i; graphics.position.y=40 * j; container.addchild(graphics); }; }; alert(graphics[2][1].position.x)//here error container.x=100 container.y=100 container.scale.x=container.scale.y=.1; animate(); function animate() { requ

javascript - How to get the file type of a CSV in jQuery -

Image
this input tag using select file, <input id="imprtupldfileinpt" name="file" type="file"/> and how process file details jquery, var file = $("#imprtupldfileinpt")[0].files[0]; var f_name = file.name; var f_size = file.size; var f_type = file.type; var filemimetypearr = ["text/comma-separated-values", "text/csv", "application/csv", "application/vnd.ms-excel"]; var filetypepos = $.inarray(f_type, filemimetypearr); i checking whether selected file csv or not value of filetypepos . if value greater or equal 0, conform csv file. facing problem in getting file type. if csv selected, file name , size obtained correctly. not getting file type. the following screenshot shows file details of csv file, i have added possible mime types in filemimetypearr checking whether file csv file or not. problem getting file type. this problem not occur if csv file saved in machine has ms excel installed

c# - Xamarin Listview within Stacklayout displays incorrectly on iOS -

i have following xaml <stacklayout orientation="vertical" verticaloptions="endandexpand" horizontaloptions="fillandexpand" margin="0,0,0,0"> <label text="menu" /> <listview x:name="lvmenu" itemselected="lvmenu_itemselected"> <listview.itemtemplate> <datatemplate> <imagecell imagesource="{binding imagesource}" text="{binding titletext}" /> </datatemplate> </listview.itemtemplate> </listview> </stacklayout> the following c# populates it private void populatemenu() { var menu = new list<settingitem>() { new settingitem() { imagesource="icon.png", titletext="show jobs", targetpagetype = typeof(joblistpage) }, new settingitem() { imagesource="opportunities.png&

code cleanup - Cleaning Up User Defined Matrix -

i'm doing project in class involves creating user defined matrix , displaying both matrix , transpose. created source file works, think cleaned bit. have far: int nrow; int ncol; int n = 0; int m = 0; printf ("please enter number of rows.\n"); scanf ("%d", &nrow); printf ("please enter number of columns.\n"); scanf ("%d", &ncol); printf ("please enter desired matrix values.\n"); int matrix[nrow][ncol]; int mrow = nrow; int mcol = ncol; while (ncol > 0) { while (nrow > 0) { scanf ("%d", &matrix[n][m]); n++; nrow--; } ncol--; n = 0; m++; nrow = mrow; } ncol = mcol; nrow = mrow; m = 0; n = 0; printf ("original matrix\n"); while (ncol > 0) { while (nrow > 0) { printf ("%3d", matrix[n][m]); n++; nrow--; } ncol--; n = 0; m++; nrow = mrow; printf ("\n\n"); } print

ftp - Connecting to vps via sftp using Filezilla -

Image
edit start : background before question: i used connect vps fine filezilla now, did do-release-upgrade on server , can't connect filezilla. didn't change parameter in filezilla on laptop, guess problem coming server, if think filezilla issue , i'd rather check filezilla forum, let me know. edit end i try connect server using sftp . in command line, sftp -p 22 username@xx.xxx.xx.xxx runs fine. filezilla, response: fzsftp started command: open "username@xx.xxx.xx.xxx" 22 error: connection timed out error: not connect server what missing? command: open "username@xx.xxx.xx.xxx" 22 this should only command: open xx.xxx.xx.xxx 22 username send in later stages , have different field in filezilla configuration:

javascript - Creating Circles(div) and appending it to div#canvas -

i trying create new circles pen hovers on window. having issues cannot add circles page. hovers around. how able modify code add circles hovers. <!doctype html> <html> <head> <title> javascript environment: project </title> <meta charset="utf-8"> <style> html, body { width: 100%; height: 100%; margin: 0px; padding: 0px; } #canvas { background-color: yellow; width: 100%; height: 100%; } .pen { position: absolute; background-color: lightblue; width: 10px; height: 10px; border-radius: 5px; } </style> <script> window.onload = function() { function circle(x, y) { this.x = x; this.y = y; } var canvas = do

c++ - Inserting new score into sorted array while updating separate array of names -

Image
score array of 10 scores in ascending order. scorename array of names associated with each score. need check if new score enough enter the high score table , if so, insert correct position , make sure scorename updated reflect changes. i having problems current code: //table for (int = 0; < leaderboardsize; i++) { cout << scorename[i] << "\t\t" << score[i] << endl; } system("pause"); //check see if made highscore if (dicetotal >= score[9]) { cout << "congrats, have made highscore table !\nenter name."; cin >> playername; (int = 9; < leaderboardsize; i--) { if (dicetotal <= score[i]) { scorename[i = + 1] = scorename[i]; score[i = + 1] = score[i]; scorename[i] = playername; score[i

java - Get the query plan using jdbc PreparedStatement on sql server -

using statment, resultset.getobject returns query plan xml connection conn = getconnection(); string query = " set showplan_xml on "; statement st = conn.createstatement(); boolean execute=st.execute(query); log.info("execute status {} " , execute); query = " select atmprofiles.termid columnid, atmprofiles.termid columnname atmprofiles (nolock) " + " authprocessname = 'atmst' " + "order atmprofiles.termid "; resultset rs = st.executequery(query); while(rs.next()) { object object = rs.getobject(1); log.info("query plan {} ", object); } but if execute same through preparedstatement, returns actual result insteadof queryplan connection conn = getconnection(); string query = " set showplan_xml on "; preparedstatement ps = conn.preparestatement(query);

copy files to remote machine's /etc/systemd/ directory using ansible -

i new ansible. may saying wrong. i created vm using kvm, both remote , local running on ubuntu 16.0.4 now configured ansible creating key ssh-keygen -t rsa -b 4096 -c "d...@192.168.111.113" created key , copied remote machine ssh-copy-id d...@192.168.111.113 tested ssh working, working fine. i added remote machine's address in /etc/ansible/hosts under [ddas] group. now can ping remote machine using ansible. wrote playbook copy file. working fine copy files /home/das1/ only. mean, can copy files location not need root permission. i want copy these files /etc/systemd/ directory instead of /home/das1/. changed dest in playbook gives permission related errors. any highly appreciated. thank das by default playbook tasks execute under context of user use connect remote system. ansible allows change user use run playbook or individual tasks. can create new user , give privileges directory mention or can use built-in root user. to run entire playboo