Posts

Showing posts from August, 2015

r - How to make part of rmarkdown document without section numbering? -

Image
i have rmarkdown document (.rmd) want knit pdf document. number_sections has been put 'yes' , toc 'true'. how can add appendix sections appear in table of contents don't have section number? here example .rmd code. how can let appendix , appendix b numberless sections , let them appear in table of contents @ same time? --- title: "test" author: "test test" geometry: margin=1in output: pdf_document: keep_tex: yes latex_engine: xelatex number_sections: yes toc: yes toc_depth: 3 header-includes: - \usepackage[dutch]{babel} - \usepackage{fancyhdr} - \pagestyle{fancy} - \fancyfoot[le,ro]{this fancy foot} - \usepackage{dcolumn} - \usepackage{here} - \usepackage{longtable} - \usepackage{caption} - \captionsetup{skip=2pt,labelsep=space,justification=justified,singlelinecheck=off} subtitle: test test test fontsize: 12pt --- # start # second ```{r results="asis",eval=true,echo=false,message=false, error=false, warn...

c# - How do I create a class with SQL connection and query functions and calling it to my windows form buttons? -

i want create class has sql connection , functions (like insert, select, delete queries) , want call forms (buttons , etc.) i don't know if it's possible or not or maybe there ways on doing so... i've done research , come code on class sql connection , i'm not sure if it's correct. thank in advance. i'm beginner , want learn more on c#. any type of response appreciated. thank you sorry bad english using system.data.sqlclient; class sqlconnclass { public static sqlconnection getconnection() { string str = "data source=localhost;initial catalog=kwem;integrated security=true;"; sqlconnection conn = new sqlconnection(str); conn.open(); return conn; } you close! may want take `conn.open()' out of method can open query. (remember close or put in using statement!) public static void updatedb(string valtoupdate) { sqlconnection conn = getconnection(); using (conn) { ...

xml - geotools : Could not find element declaration for -

i don't find solution of issue. try create kml file using geotools. i 'm stuck : <dependency> <groupid>org.geotools.xsd</groupid> <artifactid>xsd</artifactid> <version>${geotools.version}</version> </dependency> <dependency> <groupid>org.geotools.xsd</groupid> <artifactid>gt-xsd-kml</artifactid> <version>${geotools.version}</version> </dependency> <dependency> <groupid>org.geotools.xsd</groupid> <artifactid>gt-xsd-core</artifactid> <version>${geotools.version}</version> </dependency> and java source code have common example : final encoder lencoder = new encoder(new kmlconfiguration()); final fileoutputstream lfileoutputstream = new fileoutputstream(outputfile); lencoder.setind...

ios - Show swrevealviewcontroller over main view controller -

the default behavior(shadow) of swrevealviewcontroller makes appear main view controller on top of menu. there way reverse behavior menu appears on top of main view controller? swrevealviewcontroller doesn't have behaviour. can try library has looking for: https://github.com/jonkykong/sidemenu

Java Binary Tree Main Method -

i've got class node class node{ int val; node parent; node left; node right; public node (int val){ this.val = val; } } and have few methods: public class tree{ public node root = null; void insertnodesorted(node x, node tree) { if (x.val < tree.val) { if (tree.left == null) { tree.left = x; } else insertnodesorted(x, tree.left); } else { if (tree.right == null) { tree.right = x; } else insertnodesorted(x, tree.right); } } // end insertnodesorted void deletenodesorted(node x) { if (root == null) return; else root = deletenodesorted(x, root); } node deletenodesorted(node x, node tree) { if (x.val < tree.val) tree.left = deletenodesorted(x, tree.left); else if (x.val > tree.val) tree.right = deletenodesorted(x, tree.right); else tree = replacenodesorted(...

If I have an application registered with Azure AD, how do i leverage the Schools REST API? -

if have application registered azure ad, how best leverage schools rest api? i think there few things can't reconcile within docs, bear me. specifically, there permission level allows me request data rest endpoint? @ moment i'm requesting basic permissions (user.read) seems according school data sync district has register , share sis information. leads me believe user cannot grant such permission, , instead application has granted permission 'district'. if district finds app in azure marketplace grant permission or can have situation using app found in azure marketplace haven't granted sds permission? also, can 'id' https://graph.microsoft.com/v1.0/me used query schools rest api? how query student/teacher information signed in user? reading docs seems have traverse tree of schools, school, students, specific student. thanks!

JavaScript closure inside loops – simple practical example -

var funcs = []; (var = 0; < 3; i++) { // let's create 3 functions funcs[i] = function() { // , store them in funcs console.log("my value: " + i); // each should log value. }; } (var j = 0; j < 3; j++) { funcs[j](); // , let's run each 1 see } it outputs this: my value: 3 value: 3 value: 3 whereas i'd output: my value: 0 value: 1 value: 2 what's solution basic problem? well, problem variable i , within each of anonymous functions, bound same variable outside of function. what want bind variable within each function separate, unchanging value outside of function: var funcs = []; function createfunc(i) { return function() { console.log("my value: " + i); }; } (var = 0; < 3; i++) { funcs[i] = createfunc(i); } (var j = 0; j < 3; j++) { funcs[j](); // , let's run each 1 see } ...

android - Gradle build error - bug? -

i'm getting strange error when making signed app: :app:compilereleaseaidl failed failure: build failed exception. * went wrong: null value in entry: sourceoutputdir=null happened after update studio, other projects fine i've made clean / rebuild / delete gradle dir project / lowered gradle version / rollback git what else should try?

parsing - PHP Parse/Syntax Errors; and How to solve them? -

Image
everyone runs syntax errors. experienced programmers make typos. newcomers it's part of learning process. however, it's easy interpret error messages such as: php parse error: syntax error, unexpected '{' in index.php on line 20 the unexpected symbol isn't real culprit. line number gives rough idea start looking. always @ code context . syntax mistake hides in mentioned or in previous code lines . compare code against syntax examples manual. while not every case matches other. yet there general steps solve syntax mistakes . references summarized common pitfalls: unexpected t_string unexpected t_variable unexpected '$varname' (t_variable) unexpected t_constant_encapsed_string unexpected t_encapsed_and_whitespace unexpected $end unexpected t_function … unexpected { unexpected } unexpected ( unexpected ) unexpected [ unexpected ] unexpected t_if unexpected t_foreach unexpected t_for unexpected t_while unexpected t_do ...

ios - Swift segue running even though if statment is not true -

Image
i trying stop segue running if there no text in text field @ibaction func action(_ sender: any) { if( email.text != ""){ emailaddress = email.text! performsegue(withidentifier: "segue", sender: self) } else { print("enter email") } } the "enter email" prints out in output still performs segue. add segue between view controller not button view controller. see image after call method on button condition performsegue(withidentifier: "segue", sender: self)

Docker two tier application issue: failed to connect to mongo container -

i have simple nodejs application consisting of frontend , mongo database. want deploy via docker. in docker-compose file have following: version: '2' services: express-container: build: . ports: - "3000:3000" depends_on: - mongo-container mongo-container: image: mongo:3.0 when run docker-compose up, have following error: creating todoangularv2_mongo-container_1 ... creating todoangularv2_mongo-container_1 ... done creating todoangularv2_express-container_1 ... creating todoangularv2_express-container_1 ... done attaching todoangularv2_mongo-container_1, todoangularv2_express-container_1 mongo-container_1 | 2017-07-25t15:26:09.863+0000 control [initandlisten] mongodb starting : pid=1 port=27017 dbpath=/data/db 64-bit host=25f03f51322b mongo-container_1 | 2017-07-25t15:26:09.864+0000 control [initandlisten] db version v3.0.15 mongo-container_1 | 2017-07-25t15:26:09.864+0000 control [initandlisten] git version: b8ff50...

python - PhantomJS does not click on a button -

i have been trying solve entire week , last shot @ (asking stackoverflow). i use phantomjs selenium go login page of youtube , fill in credentials , log in. i login page , manages fill in email, no matter try, won't click on "next" button. from selenium import webdriver selenium.webdriver.common.keys import keys selenium.webdriver.common.desired_capabilities import desiredcapabilities selenium.webdriver.common.action_chains import actionchains import time selenium.common.exceptions import nosuchelementexception selenium.webdriver.support.ui import webdriverwait dcap = dict(desiredcapabilities.phantomjs) dcap["-phantomjs.page.settings.useragent-"] = ( "-mozilla-5.0 (windows nt 6.3; wow64) applewebkit-537.36 (khtml, gecko) chrome-34.0.1847.137 safari-537.36-" ) driver = webdriver.phantomjs(desired_capabilities=dcap) driver.set_window_size(1920,1080) driver.get("https://youtube.com") driver.find_element_by_class_name("y...

django - Invalid template library specified. ImportError raised when trying to load 'bootstrap3.templatetags.bootstrap3': cannot import name 'flatatt' -

i don't know happened of sudden getting error: invalid template library specified. importerror raised when trying load 'bootstrap3.templatetags.bootstrap3': cannot import name 'flatatt' any ideas? look file gives error and change line having flatatt in import given line from django.forms.utils import flatatt

angularjs - Angular 1.6 with typescript 2.4, gulp to webpack transition -

i think having typing issue. have angular 1.6 project being built using gulp , company wants switch webpack 3. think close getting project build having typing issue backed.d.ts file full of our types , api calls not being recognized think in webpack or compiling .ts files, hard tell which. here webpack.config.js module.exports = { entry: { 'vendor': './source/vendor.ts', 'main': './source/index.ts' }, target: 'node', output: { filename: '[name].[chunkhash].js', path: path.join(__dirname, '/webpack-build'), chunkfilename: '[name].[chunkhash].js' }, plugins: [ new webpack.optimize.commonschunkplugin({ name: 'vendor', minchunks: infinity, }), new webpackmd5hash(), new inlinemanifestwebpackplugin({ name: 'webpackmanifest' }), new ...

angular - Angular4 session handling -

i have sailsjs backend api's , want use angular4 frontend. wondering, how can handle sessions on angular? tried reading documentation , unable come anything. specifically need able handle login, log out, csrf protection, etc. possible use angular4 in sails because sails has of built in? as want use sails angular4 may need add sails.io.js in index.html <script src="/assets/sails.io/sails.io.js"></script> ,keeping sails.io.js in assets/sails.io/ folder import sailsmodule , register sails module in in app.module.ts .also add imports:[sailsmodule.forroot()] you may need inject sailsservice in constructor , ngoninit() call connect() method of sailsservice. can use request(options):observable method of sailsservice request(check http://sailsjs.com/documentation/reference/web-sockets/socket-client/io-socket-request , check http://sailsjs.com/documentation/concepts/sessions ) of req.session can session value , property.

Regex for 0 or more of a set where at least one of a subset is mandatory -

i'm using regex in notepad++ (basically pcre syntax) find arbitrary-length runs of set of characters. however, run must contain @ least 1 of subset of characters. for example, use set [abcdefg] string can contain 0 or more of a, b, c, or d, must contain @ least e, f, or g. currently i'm using [abcd]*[efg][abcd]* i.e. specifying optional ones before and after mandatory ones. there more concise way specify this? (i'm using sets of diacritics etc. pain modify , use them little possible... string used doesn't render below. use \x{0000} syntax verbose) [ּֽׁׂׅ֑ׄ]*[ ִ ֶ ַ ֻ][ּֽׁׂׅ֑ׄ]* shorter , more correct [a-g]*[efg][a-g]* plus, bookend whitespace boundary: (?<!\s)[a-g]*[efg][a-g]*(?!\s) update hebrew char's the equivalent literal regex [ִֶַֻּֽׁׂ֑ׅׄ]*[ִֶַֻ][ִֶַֻּֽׁׂ֑ׅׄ]* but doesn't render well. the better choice convert codepoint notation [\x{591}\x{5b4}\x{5b6}-\x{5b7}\x{5bb}-\x{5bd}\x{5c1}-\x{5c2}\x{5c4}-\x{5c5}]*[...

Elasticsearch - How to index the same field with different analyzers -

i interested in indexing same text field different analyzers, both stemmed allow inexact matching , shingles proximity matching. blogpost https://www.elastic.co/blog/multi-field-search-just-got-better understand possible, not sure correct way it. should index field twice different fields, each analyzer, or there way specify 2 analyzers same field? message: { properties: { text: { type: 'string', index: 'analyzed', analyzer: 'custom_text_analyzer', fields: { standard: { type: 'string', index: 'analyzed', analyzer: 'standard' } } } } here's 1 way it, can add fields onto property , give whatever properties want when index on server. in case, when want reference field query on text.standard instead of text .

ajax - disable textbox till datatables get populated in javascript -

i getting data datatable through ajax call , having trouble in disabling text-box till datatable populated(either 0 results or more results.) datatable: tableisasschedulesdetailview = $('#tableisasschedules').datatable({ "bprocessing": true, "deferrender": true, "bserverside": false, "sservermethod": "post", ajax: "/services/json/schedule.aspx?t=is&df=" + date + "&pfjson=" + encodeuri(json.stringify(filters)), "aocolumns": [ { "sname": "clientid", "bvisible": false, "stitle": "", "mdata": "clientid", "sclass": "cells", "swidth": "0" }, { "sname": "displayname", "stitle": "client", "mdata": "displayname...

c# - Unity3D - Move UI object to center of screen while maintaining its parenting -

Image
i have ui image parented recttransform container, parented ui panel, parented canvas. i want able move ui image center of screen (ie. canvas) while leaving parenting hierarchy. goal animate ui image center now. can please let me know code like? to answer original question, can place uicell @ center of screen using: private recttransform rect; void start() { rect = getcomponent<recttransform>(); rect.position = camera.main.screentoworldpoint(new vector3(screen.width / 2, screen.height / 2, 10)); } there several ways move cell desired destination. 1 method use vector2.lerp . however, due nature of rectangular transform parental hierarchy, things little complicated positioning - below example of how could accomplish movement. float t; void update() { t += time.deltatime; rect.localposition = vector2.lerp(rect.localposition, new vector2(0, 0), t/3f); }

awk, print all columns and add new column with substr -

i have table usi,name,2d-3d ro0001,patate,2d ro0002,haricot,3d ro0003,banane,2d ro0004,pomme,2d ro0005,poire,2d and want usi,name,2d-3d ro0001,patate,2d,ro_2d_patate ro0002,haricot,3d,ro_3d_haricot ro0003,banane,2d,ro_2d_banane ro0004,pomme,2d,ro_2d_pomme ro0005,poire,2d,ro_2d_poire i manage obtain construction "ro_2d_patate" awk awk -f "," '{print substr($1,1,2)"_"substr($3,1,2)"_"$2}' test4.txt but want print column $0 before second table. i tried still novice !!!! any idea on there? awk -f, '{print $0 (nr>1 ? fs substr($1,1,2)"_"$3"_"$2 : "")}' test4.txt

angular - Dynamically Load Angular2 Modules -

i have created angular2 application, bundling using webapack. destination file size got increased more 15mb including depending modules. now want load dependency modules based on demand. i have multiple main menu's, each menu contains module related components. asynchronously load dependency module based on user menu selection. you can using dynamic module loading , jit compiler. here general approach: constructor(private injector: injector, private compiler: compiler) loadmodule(modulename) { import(pathtomodule).then((module)=>{ const moduleclass = module.modulename; const modulefactory = this.compiler.compilemodulesync(moduleclass); const moduleref = modulefactory.create(this.injector); const componentfactoryresolver = moduleref.componentfactoryresolver; // can use resolver components const f = componentfactoryresolver.resolvecomponentfactory(mycomponent); }) } read more dynamic components int here...

Scala regex find/replace with additional formatting -

i'm trying replace parts of string contains should dates, possibly in impermissible format. specifically, of dates in form "mm/dd/yyyy" , need in form "yyyy-mm-dd". 1 caveat original dates may not exactly in mm/dd/yyyy format; "5/6/2015". example, if val x = "where date >= '05/06/2017'" then x.replaceall("'([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})'", "'$3-$1-$2'") performs desired replacement (returns "2017-05-06"), for val y = "where date >= '5/6/2017'" this not return desired replacement (returns "2017-5-6" -- me, invalid representation). joda time wrapper nscala-time , i've tried capturing dates , reformatting them: import com.github.nscala_time.time.imports._ import org.joda.time.datetime val f = datetimeformat.forpattern("yyyy-mm-dd") y.replaceall("'([0-9]{1,2}/[0-9]{1,2}/[0-9]{4})'", "'...

Camel csv creating issue -

i need create csv file having thing following structure using camel. school1_id,school1_name class1_id,class1_name,division1 student1_id,studennt1_firstname,student1_lastname student2_id,studennt2_firstname,student2_lastname class2_id,class2_name,division2 student1_id,studennt1_firstname,student1_lastname student2_id,studennt2_firstname,student2_lastname school2_id,school2_name class1_id,class1_name,division1 student1_id,studennt1_firstname,student1_lastname student2_id,studennt2_firstname,student2_lastname class2_id,class2_name,division2 student1_id,studennt1_firstname,student1_lastname student2_id,studennt2_firstname,student2_lastname seems bindy not supporting such hierarchical structure , in beanio reference says, "repeating segment may not contain repeating descendants variable occurrences". there other approach or api can implement create such csv in apache camel? using camel 2.17.0 i think best bet normalize custom processor. an altern...

How to read a particular row from excel in Java? -

i trying code program allows me retrieve details of person stored in excel file. have decided use emails way of identifying each person these unique. program not appear work, can me? import java.io.bufferedreader; import java.io.filenotfoundexception; import java.io.filereader; import java.io.ioexception; public class reader { public static void main(string[] args) { string csvfile = "clients.csv"; bufferedreader br = null; string line = ""; string cvssplitby = ","; try { br = new bufferedreader(new filereader(csvfile)); while ((line = br.readline()) != null) { if(((br.readline().split(cvssplitby))[2]).equals("email@gmail.com")){ string[] data = line.split(cvssplitby); system.out.println("first name: "+data[0]+" last name: "+data[1]+" activity level: "+data[7]); } ...

node.js - condition expression on put item in dynamodb -

in dynamodb using putitem want run test if item1 , item2 matches existing record, want nothing, if dont, want putitem. my table field1 field2 field3 item1 item2 item3 item1b item2b item3b var item = {field1: myfield1, field2: myfield2, field3: myfield3} so if conditionexpression: myfield1 != item1 , myfield2 != item2 i want dynamo.putitem....... i had thought done without query i tried using conditionexpression: "attribute_not_exists(field1) , attribute_not_exists(field2)" but didn't see results want

c# - Integer for Id rather than GUID when using ASP.NET Identity w/ a custom data store -

i aware when using asp.net identity w/ entity framework following tell identity user class using int instead of guid id public class user : identityuser<int> however, since not using entityframework class declaration this: public class user : iidentity { public virtual guid id { get; set; } = guid.newguid(); public virtual string username { get; set; } public virtual string email { get; set; } public virtual bool emailconfirmed { get; set; } public virtual string passwordhash { get; set; } public string normalizedusername { get; internal set; } public string authenticationtype { get; set; } public bool isauthenticated { get; set; } public string name { get; set; } } can change guid int without running issues or have implement identityuser still? identityuser part of identity.entityframework package no longer installed in application.

ios - How to add programmatic constraints to a UITableView? -

Image
i have class set follows: class settingscontroller: uitableviewcontroller { i able add constraints uitableview there equal spacing either side of table (it full width table, little ugly on ipad). i have read can't add constraints uitableviewcontroller , , instead must add uiviewcontroller class, add uitableview that, , should able add constraints tableview. i've amended class , defined uitableview on next line. here first 2 lines now: class settingscontroller: uiviewcontroller { var tableview = uitableview() further down, have code attach tableview uiview : override func viewdidload() { super.viewdidload() self.view.addsubview(tableview) } the app builds when trying access view, screen blank, i've not been able attempt constraints part yet (the screen display data correctly if revert i've described). many of existing functions within class reference tableview passing in data/setting number of rows etc, seems i've not done right...

python - Rolling correlation coefficients for two xarray DataArrays -

i trying calculate rolling correlation between 2 xarray dataarrays. suppose dataset is: <xarray.dataset> dimensions: (date: 2621, x: 100) coordinates: * date (date) datetime64[ns] 2007-01-03 2007-01-04 ... * x (x) int64 1 2 3 4 5 6 ... data variables: (date) float64 -0.001011 0.001227 -0.006087 0.002535 ... b (date, x) float64 -0.001007 -0.0001312 -0.02594 ... i compute rolling coefficients between , b dimensions of each coefficient (date, x). note date dimension present because rolling applied along date axis. i able put , ugly way full of loops wondering if there way somehow applying reduce function on rolling dataset object. can't see way there may entirely different approach missing. this problem can generalized applying arbitrary function takes 2 series of numbers inputs (in case correlation function.

can you skip a row in Pentaho Kettle's User Defined Java Class -

inside of processrow(), can skip row , not send next step , pull next row? know filter rows step after udjc option, wondering if done inside udjc. if you're implementing logic in user defined java class element using processrow() function, , don't want pass rows further based on criteria - can skip call of putrow() function such rows.

c++11 - Safe await on function in another process -

tl;dr how safely await on function execution (takes str , int arguments , doesn't require other context) in separate process? long story i have aiohtto.web web api uses boost.python wrapper c++ extension, run under gunicorn (and plan deploy on heroku), tested locust . about extension: have 1 function non-blocking operation - takes 1 string (and 1 integer timeout management), calculations , returns new string. , every input string, 1 possible output (except timeout, in case, c++ exception must raised , translated boost.python python-compatible one). in short, handler specific url executes code below: res = await loop.run_in_executor(executor, func, *args) where executor processpoolexecutor instance, , func -function c++ extension module. (in real project, code in coroutine method of class, , func - it's classmethod executes c++ function , returns result) error catching when new request arrives, extract it's post data request.post() , stor...

json - GET and parameterless GET causing AmbiguousActionException? -

i'm trying have 2 web api methods in controller. 1 when called myviewmodel object in header, , 1 without. mycontroller.cs: [produces("application/json")] [route("api/[controller]")] public class mycontroller : controller { [httpget] public ienumerable<usermodel> get() { // ... } [httpget] public ienumerable<usermodel> get(myviewmodel viewmodel) { // ... } } but browsing route address in chrome without passing myviewmodel gives me error: ambiguousactionexception: multiple actions matched. following actions matched route data , had constraints satisfied: mycontroller.get (myproject) mycontroller.get (myproject) if comment out parameterless method , put break point in parameterized function , browse api url, looks rather viewmodel being null expected, appears new myviewmodel object made parameterless constructor. seems may relevant problem. i'm running on microso...

mongodb - Conditionally Aggregate Against Choice of Pairs : Home or Away -

i'm looking best way aggregate soccer matches aggregate table display qualification table. have data looks this: /* 1 */ { "_id" : objectid("5976b6e1f42aa4d69585f4fb"), "home" : objectid("596fe03ad496e047d6314bf7"), "away" : objectid("596fe03ad496e047d6314be8"), "homegoals" : 4, "awaygoals" : 1, "tournament" : objectid("59726e597ec27162718ff90b"), "stage" : objectid("59726e597ec27162718ff9b3"), "date" : isodate("2017-01-28t08:00:00.000z"), "notes" : "", "__v" : 0 } /* 2 */ { "_id" : objectid("5976b6e1f42aa4d69585f4fd"), "home" : objectid("596fe03ad496e047d6314be9"), "away" : objectid("596fe03ad496e047d6314c0d"), "homegoals" : 0, "awaygoals" : 0, "tournament...