Skip to content

Instantly share code, notes, and snippets.

@capnslipp
capnslipp / ghfmd.rb
Created February 19, 2012 03:03
Markdown Renderer, avec GitHub-Flavor™
#!/usr/bin/env ruby
# ^ 1.8.x or 1.9, folks!
require 'rubygems'
require File.expand_path('./md_izer', File.dirname(__FILE__))
render_options = {
:fenced_code_blocks => true,
:autolink => true,
:space_after_headers => true
## encoding: utf-8
## Alex D's solution (1st revision) to http://stackoverflow.com/questions/5390537/best-practices-and-implementation-for-macro-and-class-level-accessor-methods/9019388#9019388
module MacroMethods
private
def full_name(full_name)
# non-trivial, one-time-only set-up code exists here in actual usage
self.class_eval { const_set :FULL_NAME, full_name.to_s }
@capnslipp
capnslipp / group-permissify.sh
Created April 5, 2012 17:28
*nix Group Permissionify (if it works for me, it should work for my buddies too)
#!/usr/bin/env bash
shared_group="$1" # e.g.: 'admin'
group_exists=`grep "^$shared_group:" /etc/group`
if [ -z $group_exists ]; then
echo "Error: There seems to be no group by the name of \"$shared_group\" (totally checked out your '/etc/group' file)."
else
echo "Permissifying within ./ directory..."
@btipling
btipling / unfucktenxer.js
Created June 14, 2012 06:13
Remove tenxer github hooks. They will not delete the hooks they add to your private repos even if you tell them to remove your github info. I had to remove 173 hooks added by tenxer.
#!/usr/local/bin/node
var https = require('https');
var token, username;
var tenxer = 'tenxer';
var shitsFucked = 0;
var shitsUnfucked = 0;
var reposCount = 0;
process.argv.forEach(function (arg) {
@capnslipp
capnslipp / where_am_i.rb
Created October 18, 2012 22:42
where_am_i: tiny Ruby debugging extension to sum up the current location in the object graph
## encoding: utf-8
## author: Slipp Douglas Thompson <http://slippyd.com/>
class Object
  # notice: it's a verbal statement
  def where_i_am
    object_index = self.object_id
    class_name = self.class.name
    
    class_lineage = begin
@benui-dev
benui-dev / OrderTester.cs
Created May 17, 2013 06:29
Unity order tester. Comment out lines you don't care about. Update etc. will be especially noisy.
using UnityEngine;
using System.Collections;
public class OrderTester : MonoBehaviour {
void Update() { Debug.Log("Update()"); }
void LateUpdate() { Debug.Log("LateUpdate()"); }
void FixedUpdate() { Debug.Log("FixedUpdate()"); }
void Awake() { Debug.Log("Awake()"); }
void Start() { Debug.Log("Start()"); }
void Reset() { Debug.Log("Reset()"); }
@samgro
samgro / FSQSplitViewController.h
Last active July 13, 2016 01:27
FSQSplitViewController
//
// FSQSplitViewController.h
//
// Copyright (c) 2015 Foursquare. All rights reserved.
//
#import "FSCoreViewController.h"
NS_ASSUME_NONNULL_BEGIN;
#pragma once
// This provides a library for stubbing and mocking C++ code as is. It works by requiring
// explicit hooks to be inserted into the code that is to be mocked. In a regular build,
// these hooks will do nothing. In a testing build, they will expand to calls into the
// framework here to allow the code being executed to be hijacked from outside.
//
// NOTE: Thread-safety! Arranging fakes must be done on a single thread. Using fakes can
// be done from multiple threads concurrently.
//
@slembcke
slembcke / ProjectedBounds.cs
Last active April 29, 2019 18:16
Calculate a bounded mvp matrix for an object.
using UnityEngine;
[ExecuteInEditMode]
public class ProjectedBounds : MonoBehaviour {
private Transform _transform;
private Renderer _renderer;
private Mesh _mesh;
private MaterialPropertyBlock _block;
private void Start(){
@capnslipp
capnslipp / KeyedEventActionForwarder.cs
Last active December 5, 2019 15:47
SingleEventAction, KeyedEventActions, & Friends
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: Forwards keyed events to a KeyedEventActions component elsewhere.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Needs to be put on the same GameObject as the Mecanim Animator component or “legacy” Animation component.
/// Animation events should be configured in the Unity Editor's Animation timeline view or model import settings › Animations tab › Events disclosure (or via the scripting API, I suppose) to call “Function: Action, Parameter String: «your-decided-key-string-for-this-action»”.
/// @intended project path: Assets/Utils/EventAction/KeyedEventActionForwarder.cs
/// @interwebsouce: https://gist.github.com/capnslipp/50db1dc724514bb3db91
using System;