Skip to content

Instantly share code, notes, and snippets.

View irskep's full-sized avatar
💭
~emo song lyrics~

Steve Landey irskep

💭
~emo song lyrics~
View GitHub Profile
from mrjob.job import MRJob
class MRWordCountJob(MRJob):
def steps(self):
return [self.mr(
mapper=self.capture_values,
mapper_init=self.init_values,
mapper_final=self.emit_values,
ssh -o ServerAliveInterval=10 -o StrictHostKeyChecking=no -i ~/.ssh/EMR.pem hadoop@<value of Master Public DNS Name>
# Tab color aliases
alias tred='echo -en "\033]6;1;bg;red;brightness;255N^G\a" && echo -en "\033]6;1;bg;green;brightness;128N^G\a" && echo -en "\033]6;1;bg;blue;brightness;128N^G\a"'
alias torange='echo -en "\033]6;1;bg;red;brightness;255N^G\a" && echo -en "\033]6;1;bg;green;brightness;192N^G\a" && echo -en "\033]6;1;bg;blue;brightness;128N^G\a"'
alias tyellow='echo -en "\033]6;1;bg;red;brightness;255N^G\a" && echo -en "\033]6;1;bg;green;brightness;255N^G\a" && echo -en "\033]6;1;bg;blue;brightness;128N^G\a"'
alias tgreen='echo -en "\033]6;1;bg;red;brightness;128N^G\a" && echo -en "\033]6;1;bg;green;brightness;255N^G\a" && echo -en "\033]6;1;bg;blue;brightness;128N^G\a"'
alias tcyan='echo -en "\033]6;1;bg;red;brightness;128N^G\a" && echo -en "\033]6;1;bg;green;brightness;255N^G\a" && echo -en "\033]6;1;bg;blue;brightness;255N^G\a"'
alias tblue='echo -en "\033]6;1;bg;red;brightness;128N^G\a" && echo -en "\033]6;1;bg;green;brightness;128N^G\a" && echo -en "\033]6;1;bg;blue;brightness;255N^G\a"'
alias tmagenta='
@irskep
irskep / error.py
Last active January 2, 2016 17:39
class MyTable(...):
__tablename__ = 'my_table'
id = ...
unicode_col = Column(UnicodeText())
# (insert some rows into my_table)
assert type(session.query(MyTable).first()) == unicode # NOPE!
### workaround ###
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.session import Session
from sqlalchemy import (
create_engine,
Column,
Integer,
UnicodeText,
)
Base = declarative_base()
@irskep
irskep / sqlalchemy_mysql_objectid.py
Created February 19, 2014 19:08
MongoDB ObjectId column type for SQLAlchemy + MySQL
from bson import ObjectId
from sqlalchemy import types
from sqlalchemy.dialects.mysql import BINARY
class BinaryObjectId(types.TypeDecorator):
impl = BINARY
def process_bind_param(self, value, dialect):
if value:
def run_job(self):
"""Run the all steps of the job, logging errors (and debugging output
if :option:`--verbose` is specified) to STDERR and streaming the
output to STDOUT.
Called from :py:meth:`run`. You'd probably only want to call this
directly from automated tests.
"""
self.set_up_logging(quiet=self.options.quiet,
verbose=self.options.verbose,
- id: beginner
maleName: Bob
femaleName: Dora
genre: tutorial
goals:
- name: "Flower garden"
sampleObjectTypeIds: ['2h5i418']
minimumSubmitLevel: 2
templateQuery: ''
dimensions:
- id: beginner
maleName: Bob
femaleName: Dora
genre: tutorial
goals:
- name: "Flower garden"
verbPhrase: 'Enjoying flowers'
sampleObjectTypeIds: ['2h5i418']
minimumSubmitLevel: 2
templateQuery: 'tutorial garden'
@irskep
irskep / getUIImageForRGBAData.swift
Created December 5, 2014 03:13
Convert RGBA bytes to UIImage in Swift
func getUIImageForRGBAData(#width: UInt, #height: UInt, #data: NSData) -> UIImage? {
let pixelData = data.bytes
let bytesPerPixel:UInt = 4
let scanWidth = bytesPerPixel * width
let provider = CGDataProviderCreateWithData(nil, pixelData, height * scanWidth, nil)
let colorSpaceRef = CGColorSpaceCreateDeviceRGB()
var bitmapInfo:CGBitmapInfo = .ByteOrderDefault;
bitmapInfo |= CGBitmapInfo(CGImageAlphaInfo.Last.rawValue)