Skip to content

Instantly share code, notes, and snippets.

View duncangh's full-sized avatar
💭
👨‍💻

Graham Duncan duncangh

💭
👨‍💻
View GitHub Profile
import pandas as pd
import matplotlib
matplotlib.use('Agg')
import prettyplotlib as ppl
import brewer2mpl
from matplotlib.colors import Normalize
from ggplot import *
from datetime import datetime, timedelta, time
from hdfs import InsecureClient
from email.MIMEMultipart import MIMEMultipart
@duncangh
duncangh / Crontab.sh
Created June 23, 2018 00:36 — forked from Paulmicha/Crontab.sh
Command-line / Shell / Bash Scripting - Snippets, Notes & Whatnot
#!/bin/bash
# -*- coding: UTF8 -*-
##
# Command-line / Shell / Bash - snippets : Cron-related snippets
# Tested on Debian 6 ("Squeeze")
#
# Sources :
# https://drupal.org/node/23714
# http://www.linuxquestions.org/questions/linux-general-1/crontab-every-10-minutes-117651/
@duncangh
duncangh / .bash_aliases
Created June 23, 2018 00:37 — forked from chrisbloom7/.bash_aliases
A portion of my alias entries and some other useful snippets for Bash
#!/bin/sh
# GENERAL COMMANDS
alias l='ls -AHhlp'
alias c='clear'
alias cx='chmod +x'
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
alias reload='source ~/.bash_profile'
alias release='xattr -d com.apple.quarantine'
alias flushdns='sudo discoveryutil udnsflushcaches'
@duncangh
duncangh / README.md
Last active June 23, 2018 07:51 — forked from bruth/README.md
Postgres push notification

Postgres push triggers

Watch a table for changes and push a notification with a payload describing the change.

Example

In the Postgres shell:

-- Create the functions
@duncangh
duncangh / listen_sqla.py
Created June 23, 2018 23:23 — forked from dtheodor/listen_sqla.py
Listen for pg_notify with SQL Alchemy + Psycopg2
import select
import datetime
import psycopg2
import psycopg2.extensions
from sqlalchemy import create_engine, text
engine = create_engine("postgresql+psycopg2://vagrant@/postgres")
@duncangh
duncangh / detect-face-landmarks.swift
Created July 18, 2018 22:19 — forked from kravik/detect-face-landmarks.swift
iOS 11 Vision. Face detection
import Vision
//1
let sourceImage = UIImage(named: "jony.jpg")
var resultImage = sourceImage
//2
let detectFaceRequest = VNDetectFaceLandmarksRequest { (request, error) in
//4
if let results = request.results as? [VNFaceObservation] {
//5
for faceObservation in results {
import hashlib as hasher
import datetime as date
# Define what a GrahamCoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
################################################################################################
# name: convert_daily_to_monthly.py
# desc: takes inout as daily prices and convert into monthly data
# date: 2018-06-15
# Author: conquistadorjd
################################################################################################
import pandas as pd
import numpy as np
print('*** Program Started ***')

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor
@duncangh
duncangh / app.py
Created September 30, 2018 05:40 — forked from Sniedes722/app.py
Upload A File to an S3 Bucket with Flask
import os
import boto3
from flask import Flask, render_template, request, url_for, redirect
app = Flask(__name__)
AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
S3_BUCKET = os.environ['S3_BUCKET']