Skip to content

Instantly share code, notes, and snippets.

View OdinsHat's full-sized avatar
💭
Open to job offers

Doug OdinsHat

💭
Open to job offers
View GitHub Profile
'use strict';
var map;
var infoWindow;
var markers = [];
var contents = [];
function addMarker(location, i)
{
var image = 'bs-gold-32-rounded.png';
var latLong = new google.maps.LatLng(parseFloat(location.lat), parseFloat(location.lng));
@OdinsHat
OdinsHat / joke.py
Created March 26, 2014 13:22
Random Reddit joke from top 20 at r/jokes
import praw
from random import choice
def joke():
"""Prints a joke from a random selection of the
top 20 reddit jokes in r/jokes
"""
r = praw.Reddit(user_agent="Reddit Joke Grabber")
subs = r.get_subreddit("jokes").get_hot(limit=20)
jokes = list(subs)
.blink_me {
-webkit-animation-name: blinker;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-moz-animation-name: blinker;
-moz-animation-duration: 1s;
-moz-animation-timing-function: linear;
-moz-animation-iteration-count: infinite;
@OdinsHat
OdinsHat / Create CSR (BASH)
Last active August 29, 2015 14:00
Create CSR for new SSL certificate (reminder instructions included)
#!/bin/sh
openssl req -new -newkey rsa:2048 -nodes -out www.example.co.uk.csr -keyout www.example.co.uk.key
@OdinsHat
OdinsHat / yii_migration_add_fields_to_table_example.php
Last active August 29, 2015 14:01
YII Migration example for copying fields from a related table by first creating them then copying the data over (thereby de-normalising it).
<?php
/**
* This is an obfuscated Yii Migration example taken from a commercial project I'm working on.
*
* I thought I may find the creation of fields in one table and
* copying over of the data from the related table (thereby de-normalising it)
* of some use in future. It was required in a few tables due to the unusual
* nature of the related data.
*
* @see http://www.yiiframework.com/doc/guide/1.1/en/database.migration
@OdinsHat
OdinsHat / gist:7eae263cb04079a338e4
Last active August 29, 2015 14:01
Bypass clang: error: unknown argument: '-mno-fused-madd'

Bypass clang: error: unknown argument: '-mno-fused-madd'

When installing Python packages on OSX Mavericks there will be a Clang error akin to this: clang: error: unknown argument: '-mno-fused-madd' To bypass this you need to tell Clang to ignore unknown flags So far this problem has occured with xattr and PIL/pilow but this command fixed both

Installing PIL/pillow on OSX Mavericks 10.9

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow

Installing xattr on OSX Mavericks 10.9

@OdinsHat
OdinsHat / getstockfile.py
Created May 18, 2014 08:12
Quick & dirty script used for downloading latest stock sheet from Google Apps Email and saving to server for further processing
#!/usr/bin/env python
""" Quick & dirty script used for downloading latest stock sheet from
Google Apps Email and saving to server for further processing"""
import email
import imaplib
import os
save_dir = '.'
@OdinsHat
OdinsHat / memoization.js
Created May 18, 2014 08:50
Javascript Memoization Example from Javascript the Good Parts
var memoizer = function (memo, formula) {
var recur = function (n) {
var result = memo[n];
if (typeof result !== 'number') {
result = formula(recur, n);
memo[n] = result;
}
return result;
};
return recur;
@OdinsHat
OdinsHat / gendepotcodes.py
Last active August 29, 2015 14:01
Scripts for generating unique numbers for garage depots for use in text campaigns. One script for creating XLS file and another for separate CSV files
#!/usr/bin/env python
"""
Generates URN/codes and saves them to separate CSV files - 1 for each depot.
URN Format: (\d{3})([A-Z])(\d{3})
Group 1: Random capital letter A-Z (technically unecessary)
Group 2: Depot number 01-67
Group 3: Sequence number 001-250 (never repeats)
"""