This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is _definitely_ my own implementation of rangeCheck and no one else's. Definitely not infringing on anything. | |
| private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { | |
| if (fromIndex > toIndex) | |
| throw new IllegalArgumentException("fromIndex(" + fromIndex +") > toIndex(" + toIndex+")"); | |
| if (fromIndex < 0) | |
| throw new ArrayIndexOutOfBoundsException(fromIndex); | |
| if (toIndex > arrayLen) | |
| throw new ArrayIndexOutOfBoundsException(toIndex); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os, sys, tempfile | |
| def use_editor(text): | |
| """ | |
| Write out text to a temp file, instruct the system to open it in an editor, | |
| and when control is returned to us, re-open that temp file and return its contents. | |
| """ | |
| tmp = tempfile.NamedTemporaryFile(delete=False) | |
| tmp.write(text) | |
| tmp.seek(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'aws-sdk' | |
| require 'pry' | |
| require 'awesome_print' | |
| # ------------------------------------------------------------------------------ | |
| # Credentials | |
| # ------------------------------------------------------------------------------ | |
| # pick up AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY by default from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a pretty lazy way to do mosh tunnelling, but it works. | |
| mosh user@host.that.is.public.com -- mosh user2@host.that.is.private.com | |
| # You can also do the internal session as SSH, since that connection is probably pretty solid and not subject to broken pipes. | |
| mosh user@host.that.is.public.com -- ssh user2@host.that.is.private.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Run your tests and throw the return code into a variable. | |
| RESULT=$(python -m tests.__init__ $1) | |
| # Only if osascript exists (AKA only on OS X) | |
| if type "osascript" > /dev/null; then | |
| SUCCESS="Successful" | |
| MESSAGE="All Tests Complete" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (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; | |
| } |