Skip to content

Instantly share code, notes, and snippets.

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

Graham Duncan duncangh

💭
👨‍💻
View GitHub Profile

source: request.py

Requests

If you're doing REST-based web service stuff ... you should ignore request.POST.

— Malcom Tredinnick, [Django developers group][cite]

REST framework's Request class extends the standard HttpRequest, adding support for REST framework's flexible request parsing and request authentication.

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
# Get the name of the exception which occurred as well as the context.
try:
someFunction()
except Exception as ex:
template = "An exception of type {0} occurred. Arguments:\n{1!r}"
message = template.format(type(ex).__name__, ex.args)
print(message)
################################################################################################
# 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 ***')