Skip to content

Instantly share code, notes, and snippets.

View josefdlange's full-sized avatar
🌱

Joey Lange josefdlange

🌱
View GitHub Profile
@josefdlange
josefdlange / FlagDrawer.class
Created December 5, 2012 20:46
Class to hold flag data given user input and (potentially) draw it.
import javax.swing.*;
import java.lang.*;
class FlagDrawer {
private int countryCode;
private int flagWidth;
private int flagHeight;
public static void main(String args[]) {
@josefdlange
josefdlange / SwipeUpViewControllerDemo
Last active August 29, 2015 14:05
Early Swift version of CSRevealingViewController (Two VCs, one gist)
//
// BottomViewController.swift
// SwipeUpViewControllerDemo
//
// Created by Lange, Josef on 7/14/14.
//
import UIKit
class BottomViewController: UIViewController {
@josefdlange
josefdlange / RevealingViewController.m
Created August 8, 2014 06:01
Objective-C port of Swift SwipeUpViewController port
//
// RevealingViewController.m
//
// Created by Lange, Josef on 7/15/14.
//
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
Verifying I am +josefdlange on my passcard. https://onename.com/josefdlange
@josefdlange
josefdlange / gist:bdea97655d8c56fb2d1c
Last active August 29, 2015 14:21
Class Attributes
class Pet(object):
fur_length = 10
is_alive = False
def __init__(self, name):
self.name = name
fido = Pet("Fido")
fluffy = Pet("Fluffy")
@josefdlange
josefdlange / UIImage+Resizing.m
Created August 28, 2015 20:40
Resizing a UIImage, leveraging UIViewContentMode
- (UIImage *)resizedWithNewSize:(CGSize)size contentMode:(UIViewContentMode)contentMode {
CGFloat x = 0.0f;
CGFloat y = 0.0f;
CGFloat w = size.width;
CGFloat h = size.height;
BOOL scale = YES;
switch (contentMode) {
case UIViewContentModeScaleToFill: {
break;
}
@josefdlange
josefdlange / killer_logging.py
Last active October 10, 2015 00:19
Short, sweet, to-the-point logging in a Python application.
import logging
import logging.handlers
"""
Call me once at initialization of your application.
@param level A level from the logging package. You can also
pass in common levels as strings, I believe ('INFO', 'DEBUG', etc)
"""
def setup_logging(level):
@josefdlange
josefdlange / .tmux.conf.old
Created November 18, 2015 16:08
old tmux configuration
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
set -g default-terminal "screen-256color"
set-option -g allow-rename off
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g mouse on
set -g default-terminal "screen-256color"
set-option -g allow-rename off
set-option -g renumber-windows on
source ~/.tmuxline.sh
@josefdlange
josefdlange / custom_serializer_class.py
Created November 30, 2015 15:54
Implementing custom JSON logic for the Python json module.
import json
from json import JSONEncoder
class MyComplexObject(object):
"""
A trivial Python object that has its own special serialized output
that for some reason would differ from __repr__.
"""
def __init__(self, arbitrary_value, optional_value=None):