Skip to content

Instantly share code, notes, and snippets.

View claytantor's full-sized avatar
💭
Doing and Being

Clay Graham claytantor

💭
Doing and Being
View GitHub Profile
@claytantor
claytantor / settings.ini
Last active August 29, 2015 14:12
How to create environment based settings configs
[secrets]
DJANGO_SECRET_KEY: ill%92_5+gaw!7p5la0h+-=-pb2)l&%11(d@a8+#mff5z$r3^
@claytantor
claytantor / views.py
Last active August 29, 2015 14:12
Backflips related to using Mailchimp OAuth2 Implementation
# AUTH
# ******************************************************************************************
# Step 1: Your application begins the authorization process by redirecting the user to the authorize_uri
#
# - this is a GET request
# - response_type=code, your client_id, and the *urlencoded* redirect_uri are included
# ******************************************************************************************
#
# authorize_uri = https://login.mailchimp.com/oauth2/authorize?response_type=code&client_id=635959587059&redirect_uri=http%3A%2F%2F192.168.1.8%2Foauth%2Fcomplete.php
@claytantor
claytantor / csr_text.txt
Last active August 29, 2015 14:12
Generate CSR and Key Files
$ openssl req -nodes -newkey rsa:2048 -keyout mysite_com.key -out mysite_com.csr
Generating a 2048 bit RSA private key
.........................+++
.................................................................+++
writing new private key to 'mysite_com.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
@claytantor
claytantor / gist:47e87d30e8f60d274bbb
Created January 10, 2015 23:04
twilio date conversion
datetime.strptime("Sun, 04 Jan 2015 00:06:51 +0000"[:-6],"%a, %d %b %Y %H:%M:%S")
@claytantor
claytantor / sudoer.sh
Created January 16, 2015 05:11
sudoer for ssh user
mysuer ALL=(ALL) NOPASSWD:ALL
@claytantor
claytantor / install_276.sh
Last active August 29, 2015 14:14
installing python 2.7.6.for django
cd ~/src
sudo yum groupinstall "Development tools"
sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
sudo yum install httpd-devel
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
sudo make && sudo make altinstall
python
@claytantor
claytantor / HelloLog4j.java
Last active May 19, 2016 12:52
Configurations for log4j
package com.claytantor.log4j.playground;
import org.apache.log4j.Logger;
/**
* Created by cgra12 on 8/24/15.
*/
public class HelloLog4j {
static Logger log = Logger.getLogger(HelloLog4j.class.getName());
@claytantor
claytantor / shade-init.sh
Created November 2, 2015 01:00
A shade/shadow jar that has jetty runnable init.d service.
#!/usr/bin/env bash
#
# Startup script for a spring boot project
#
# chkconfig: - 84 16
# description: project
# Source function library.
[ -f "/etc/rc.d/init.d/functions" ] && . /etc/rc.d/init.d/functions
[ -z "$JAVA_HOME" -a -x /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
@claytantor
claytantor / aws_ls_csv.bash
Created November 9, 2015 04:54
How to list aws dir as CSV
#!/bin/bash
aws s3 ls s3://dronze.2b67/data/wiki --region=us-west-2 --recursive | python -c '
import sys
for line in sys.stdin:
r = line.strip("\n").split(None, 10)
fn = r.pop()
print ",".join(r) + "," + fn.replace("\"", "\"\"")
'>wiki_docs.csv
@claytantor
claytantor / guava_table1.java
Created November 14, 2015 13:46
Creating a guava table using column names
Table<Integer, String, Object> table = HashBasedTable.create();
String[] columnNamesArray = (String[])columnNames.toArray(new String[columnNames.size()]);
List<List>[] rows = (List<List>[])data.toArray(new List[data.size()]);
for(int i = 0; i < rows.length; i++){
Object[] objectArray = rows[i].toArray();
for (int j = 0; j < objectArray.length; j++) {
if(j==0){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdf.parse(objectArray[j].toString());