Skip to content

Instantly share code, notes, and snippets.

void Main()
{
var harmony = new Harmony("test");
harmony.PatchAll();
var group = new StatusItemGroup();
var items = new List<StatusItemGroup.Entry>() { StatusItemGroup.Entry.Make("A"), StatusItemGroup.Entry.Make("B") };
Traverse.Create(group).Field("items").SetValue(items);
var enumerator = group.GetEnumerator();
@howlingblast
howlingblast / gist:5814547
Created June 19, 2013 14:00
CoffeeScript: getter/setter example
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class Person
constructor: (@firstName, @lastName) ->
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
p = new Person 'Leroy', 'Jenkins'
@victorquinn
victorquinn / promise_while_loop.js
Last active March 30, 2023 04:29
Promise "loop" using the Bluebird library
var Promise = require('bluebird');
var promiseWhile = function(condition, action) {
var resolver = Promise.defer();
var loop = function() {
if (!condition()) return resolver.resolve();
return Promise.cast(action())
.then(loop)
.catch(resolver.reject);
@esemwy
esemwy / mkdim.py
Created June 10, 2015 12:13
Create DAZ Install Manager packages from zip or directory
#!/usr/bin/python
import uuid
import os
from zipfile import ZipFile, is_zipfile
import sys
import time
from random import randint
import argparse
import re
@carolineschnapp
carolineschnapp / gist:5397337
Last active January 20, 2023 10:11
Sample JavaScript file added with ScriptTag resource. This sample file is meant to teach best practices. Your app will load jQuery if it's not defined. Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
/* Sample JavaScript file added with ScriptTag resource.
This sample file is meant to teach best practices.
Your app will load jQuery if it's not defined.
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
Your app does not change the definition of $ or jQuery outside the app.
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2'
once the app is installed, even if the app uses jQuery 1.9.1:
jQuery.fn.jquery => "1.4.2"
$.fn.jquery -> "1.4.2"
*/
@nickelpro
nickelpro / yggdrasil.py
Created October 16, 2013 21:51
Yggdrasil Authentication implementation for Minecraft, implements all known Yggdrasil methods and is a lot simpler than some of the other implementations floating around
import urllib.request as request
from urllib.error import HTTPError
import json
class YggAuth:
def __init__(self,
client_token=None,
access_token=None,
username=None,
password=None
@kimsama
kimsama / Debug.cs
Created November 21, 2012 04:38
It overrides UnityEngine.Debug to mute debug messages completely on a platform-specific basis. [Edit] Added isDebugBuild property.
//#if UNITY_EDITOR
//#define DEBUG
//#endif
using UnityEngine;
using System.Collections;
using System;
using System.IO;
using System.Text.RegularExpressions;
using UnityEngineInternal;

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route: "/",
@also
also / gist:7729708
Last active June 1, 2021 09:02
how does /usr/libexec/java_home work?
# /usr/libexec/java_home -X
$ sudo opensnoop -n java_home
UID PID COMM FD PATH
501 79809 java_home 3 /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
501 79809 java_home 3 /dev/dtracehelper
501 79809 java_home 4 /System/Library/CoreServices/SystemVersion.bundle//English.lproj
501 79809 java_home -1 /System/Library/CoreServices/SystemVersion.bundle//Base.lproj
501 79809 java_home 4 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.strings
501 79809 java_home -1 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.stringsdict
501 79809 java_home 3 /usr/share/icu/icudt51l.dat