Skip to content

Instantly share code, notes, and snippets.

View ayee's full-sized avatar

Anthony Yee ayee

View GitHub Profile

Adding SFTP-only user to Ubuntu Server

To add a SFTP-only user, you'll need to make sure your SSH config settings are correct, add a new user/group and set permissions for your new user. For step-by-step directions, see below. Omit sudo if you're logged in as root.

Directions

  1. Edit /etc/ssh/sshd_config and make sure to add the following at the end of the file:

     Match group filetransfer
    

ChrootDirectory %h

I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):

Detailed Instructions

For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.

Install Jenkins Plugins

@ayee
ayee / Sample Redshift code
Created March 17, 2015 17:43
Sample redshift code to load from JSON file using jsonpaths
### begin Redshift code ###
// get rid of the old stuff
drop table crashyplane;
// create a new table
create table crashyplane (
event varchar(255) not null,
"time" int,
distinct_id varchar(255) distkey sortkey not null,
@ayee
ayee / gist:b02f2066d9b3c750acb3
Created May 26, 2015 21:23
Query to pull a dataset of first-hit visits (visit_number=1) with only variables that have been shown with significant influence
select paidlengthofstay, sitecatalyst_narrow.* from customer_sample_null_plos_fix join reservation using (accountorderitemid) join sitecatalyst_narrow on reservation.reservationitemid = sitecatalyst_narrow.purchase_id_int and sitecatalyst_narrow.visit_number = 1 and purchase_id_int is not NULL
0. SSH to server
1. Edit /opt/bitnami/apps/jenkins/jenkins_home/config.xml
2. set userSecurity to false: <userSecurity>false</userSecurity>
3. delete
<authorizationStrategy> and <securityRealm>
4. /etc/init.d/bitnami restart
@ayee
ayee / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ayee
ayee / pyspark-split-dataframe-column-literal.py
Created December 21, 2015 23:03
Split Spark dataframe columns with literal
from pyspark.sql.functions import split
df = sc.parallelize([[1, 'Foo:10'], [2, 'Bar:11'], [3,'Car:12']]).toDF(['Event', 'eventtype'])
df = df.withColumn('Thing', split(df.eventtype, ':')[0])
df = df.withColumn('Ranking', split(df.eventtype, ':')[1])
df.collect()
# [Row(Event=1, eventtype=u'Foo:10', Thing=u'Foo', Ranking=u'10'),
# Row(Event=2, eventtype=u'Bar:11', Thing=u'Bar', Ranking=u'11'),
# Row(Event=3, eventtype=u'Car:12', Thing=u'Car', Ranking=u'12')]
@ayee
ayee / gist:494bd2efcce0772c908a28869612814e
Created September 3, 2016 06:26 — forked from filipbec/gist:5998034874b119fab0e4
Scannr - Keys for obtaining US Driver's license data
@ayee
ayee / card_perspective_correct.cpp
Last active October 11, 2016 18:24
Sample code to automatically correct perspective of a card image using OpenCV
Mat src=imread("card.jpg");
Mat thr;
cvtColor(src,thr,CV_BGR2GRAY);
threshold( thr, thr, 70, 255,CV_THRESH_BINARY );
vector< vector <Point> > contours; // Vector for storing contour
vector< Vec4i > hierarchy;
int largest_contour_index=0;
int largest_area=0;
@ayee
ayee / python-tesseract-install-macox.md
Last active December 2, 2016 04:11
How to install python-tesseract wrapper for SimpleCV