Skip to content

Instantly share code, notes, and snippets.

View mattmccray's full-sized avatar

Matt McCray mattmccray

View GitHub Profile
@jdonaldson
jdonaldson / hxn.sh
Last active December 15, 2015 11:49
Simple bash script for switching between haxe nightly and stable
export OLDPATH=$PATH
export HAXE_NIGHTLY=$HOME/bin/haxe_nightly
hxn(){
if [ -z "$USE_HAXE_NIGHTLY" ] || $USE_HAXE_NIGHTLY; then
echo "Changing to Haxe stable version"
export HAXE_STD_PATH=$OLD_HAXE_STD
export PATH=$OLDPATH
export USE_HAXE_NIGHTLY=false
else
echo "Changing to Haxe nightly at: $HAXE_NIGHTLY"
@willurd
willurd / web-servers.md
Last active April 28, 2024 21:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@CanOfColliders
CanOfColliders / split-skymap-into-images.py
Created July 15, 2013 10:08
Simple script to split a cubemap/skymap image produced by blender into 6 separated image files for use in Unity3Ds skybox materials.
#!/usr/bin/env python
# Will split a png cubemap/skymap image produced by blender into 6 separated image files for use in a skybox within unity
# Requires Python Imaging Library > http://www.pythonware.com/products/pil/
# The author takes no responsibility for any damage this script might cause,
# feel free to use, change and or share this script.
# 2013-07, CanOfColliders, m@canofcolliders.com
from PIL import Image
@petehunt
petehunt / React sortable
Created December 9, 2013 22:30
Here's an example of React + jQuery UI sortable. The key thing to note is that we have the render() method do absolutely nothing and use componentDidUpdate() + React.renderComponent() to proxy updates through to the children. This lets us manage the DOM manually but still be able to use all the React goodies you know and love.
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://fb.me/react-0.5.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script>
</head>
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@Schniz
Schniz / plaintext-contenteditable.css
Last active April 8, 2022 17:46
Plain-Text ContentEditable div for React.js
.comPlainTextContentEditable {
-webkit-user-modify: read-write-plaintext-only;
}
.comPlainTextContentEditable--has-placeholder::before {
content: attr(placeholder);
opacity: 0.5;
color: inherit;
cursor: text;
}
@omgwtfgames
omgwtfgames / A set of Unity3D extension methods
Last active March 2, 2024 17:44
Some useful extension method for Unity3D
A collection of useful C# extension methods for the Unity engine.
///
/// Simple pooling for Unity.
/// Author: Martin "quill18" Glaude (quill18@quill18.com)
/// Latest Version: https://gist.github.com/quill18/5a7cfffae68892621267
/// License: CC0 (http://creativecommons.org/publicdomain/zero/1.0/)
/// UPDATES:
/// 2015-04-16: Changed Pool to use a Stack generic.
///
/// Usage:
///
1) Make a download dir to store the node source and download it.
mkdir downloads
cd downloads
git clone https://github.com/joyent/node.git
Find the latest version
2) List all of the tags in the repository, and check out the most recent.
git tag
git checkout v0.9.9
@gaearon
gaearon / slim-redux.js
Last active April 25, 2024 18:19
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {