Skip to content

Instantly share code, notes, and snippets.

View russleyshaw's full-sized avatar
💭
Converting people to the TypeScript hivemind.

Russley Shaw russleyshaw

💭
Converting people to the TypeScript hivemind.
View GitHub Profile
@russleyshaw
russleyshaw / dependency_stripper
Created September 8, 2013 05:37
A script made by @cherez. This little bit of Unix magic finds what Boost dependencies will be used and copies only the necessary bits into the current directory. It assumes there is a folder called "boost" in the parent directory.
gcc -M -I .. main.cpp | sed 's/ /\n/g' | grep boost | sed 's/\\$//g' | sort | uniq | (while read i;do x=$(echo $i | sed 's|^\.\./|./|g');mkdir -p $(dirname $x);cp $i $x;done )
@russleyshaw
russleyshaw / astar.py
Last active December 28, 2015 15:29
Python A* implementation for a grid.
import heapq
class path_finder:
def __init__(self, ai, cache):
#AI contains things such as objects, and properties of the game.
self.__ai = ai
#Cache is loaded at the start of each game.
self.__cache = cache
@russleyshaw
russleyshaw / rotator.py
Created March 14, 2015 03:29
Python Fu GIMP Hue Rotator
images = gimp.image_list()
image = images[0]
layers = image.layers
layer = image.layers[0]
steps = 60
OFFSET = 360/steps
ALL_HUES = 0
for i in xrange(steps):
pdb.gimp_hue_saturation(layer, ALL_HUES, OFFSET, 0, 0)
filename = 'hue_rotator/{}.jpeg'.format(i)
//Macro for simple base and inherited exception creation
#ifndef _EASY_EXCEPTION_H
#define _EASY_EXCEPTION_H
#include <exception>
#define EASY_EXCEPTION(NAME, WHAT) \
class NAME: public std::exception { \
public: \
@russleyshaw
russleyshaw / dancing_text_md.py
Created January 23, 2017 18:26
Convert text into dancing gifs in markdown
gifMap = {
'a': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-a-50-transa.gif',
'b': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-b-50-transa.gif',
'c': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-c-50-transa.gif',
'd': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-d-50-transa.gif',
'e': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-e-50-transa.gif',
'f': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-f-50-transa.gif',
'g': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-g-50-transa.gif',
'h': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-h-50-transa.gif',
'i': 'http://toons.artie.com/alphabet/ralph/color_cycling/arg-i-50-transa.gif',
@russleyshaw
russleyshaw / viewbb.py
Created March 2, 2017 08:06
Given a 64 bit integer, print out the corresponding bit chess board using Little-Endian Rank-File Mapping
# Russley Shaw 2017
# Given a 64 bit integer,
# print out the corresponding bit chess board
# using Little-Endian Rank-File Mapping
# Usage: python3 viewbb.py 0x<hex>
# Usage: python3 viewbb.py <int>
# Example: python3 viewbb.py 0x8080808080808080
@russleyshaw
russleyshaw / to_ul.hpp
Created April 4, 2017 04:03
Converts class enum to underlying type.
#ifndef RUS_TO_UL_HPP
#define RUS_TO_UL_HPP
#include <type_traits>
/**
* Convert a class enumeration to its underlying type.
* Got tired of writing out static_casts and std::underlying type
* @param enumeration
* @return Value of enumeration
@russleyshaw
russleyshaw / GenericClassConstructor.ts
Last active September 15, 2017 21:49
Allow generic extended construction.
interface FooConstructor<T> {
new(val: number): T;
}
interface FooInterface {
myVal: number;
}
class Foo implements FooInterface {
myVal: number;
@russleyshaw
russleyshaw / .vimrc
Created December 8, 2017 15:58
.vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'itchyny/lightline.vim'

Keybase proof

I hereby claim:

  • I am russleyshaw on github.
  • I am russleyshaw (https://keybase.io/russleyshaw) on keybase.
  • I have a public key ASCD7W2jii1zMCbyHtO5Rh4TmU08pu7DxVaAmVwIcamdKQo

To claim this, I am signing this object: