Skip to content

Instantly share code, notes, and snippets.

View doppioslash's full-sized avatar

Claudia Doppioslash doppioslash

View GitHub Profile
@oleganza
oleganza / NSObject+OAPerformBlockAfterDelay.m
Created December 2, 2010 21:12
perform blocks on main thread after delay and cancel them when you please
@interface NSObject (OAObjectHelpers)
+ (id) performBlock:(void(^)())aBlock afterDelay:(NSTimeInterval)seconds;
+ (void) cancelPreviousPerformBlock:(id)aWrappingBlockHandle;
@end
@implementation NSObject (OAPerformBlockAfterDelay)
@sishen
sishen / Emacs-JSLint
Created January 7, 2011 12:43
Emacs Func: Use ~/bin/jslint4java-1.4.4.jar to automatically JSLint the Javascript file
;;; C-x c calls jslint and outputs to the *compilation* buffer.
(setq jslint-wrapper (concat "java -jar " (substitute-in-file-name "$HOME") "/bin/jslint4java-1.4.4.jar "))
(require 'compile)
(add-hook 'javascript-mode-hook
(lambda ()
(set (make-local-variable 'compilation-read-command) nil)
(set (make-local-variable 'compile-command)
(concat jslint-wrapper buffer-file-name))
(local-set-key (kbd "C-x c") 'compile)))
@briandealwis
briandealwis / gist:782862
Created January 17, 2011 13:55 — forked from spullara/gist:782523
One-liner to turn jar with Main-Class into executable shell script
# turn a jar with a Main-Class into a stand alone executable
(echo '#!/usr/bin/env java -jar'; cat blahblah.jar) > blah
# turn a jar with a particular main clas into a stand alone executable
(echo '#!/usr/bin/env java -jar package.MainClass'; cat blahblah.jar) > blah
@aaronpowell
aaronpowell / FieldMacro.cs
Created March 2, 2011 12:55
A macro to convert a field to a property, also adds c#-esq naming
public class FieldMacro : AbstractAstMacro
{
public override Statement Expand(MacroStatement macro)
{
if (macro.Arguments.Count == 1)
{
var tryCastExpression = (TryCastExpression)macro.Arguments.First;
var referenceExpression = (ReferenceExpression)tryCastExpression.Target;
var property = new Property(referenceExpression.Name)
@robfe
robfe / NodeList.cs
Created March 6, 2011 22:58
A lock-free, thread-safe RX IScheduler that runs as part of an XNA game loop
public class NodeList<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>> where TKey : IComparable<TKey>
{
readonly Node start = new Node(default(TKey), default(TValue));
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
for (Node n = start.GetNext(); n != null; n = n.GetNext())
{
yield return new KeyValuePair<TKey, TValue>(n.key, n.value);
}
@tbatchelli
tbatchelli / pallet-vmfest.md
Created March 12, 2011 20:25
Setup pallet with vmfest
  1. Install VirtualBox on your machine
  2. Disable login credential: $ VBoxManage setproperty websrvauthlibrary null
  3. Download and uncompress the following image https://s3.amazonaws.com/vmfest-images/ubuntu-10-10-64bit-server.vdi.gz
  4. Clone the image to the directory where you want it to be permanently stored: $ VBoxManage clonehd /path/to/downloaded/ubuntu-10-10-64bit-server.vdi /path/to/permanent/location/ubuntu...-server.vdi
    • This should produce a uuid for your new image. Keep it around
  5. Start VirtualBox (the GUI) and:
    1. Create an new image Linux - Ubuntu (64bit)
  6. Select "Use existing hard disk" and if your newly cloned image doesn't appear in the drop-down list, click on the folder icon and find the image in your hard disk (the one you just cloned)
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
@tarnacious
tarnacious / accumulators.erl
Created April 22, 2011 08:26
Hello World Process Chain
-module(accumulators).
-export([average/1]).
average(X) -> average(X, 0, 0).
average([H|T], Length, Sum) ->
average(T, Length + 1, Sum + H);
average([], Length, Sum) ->
Sum / Length.
@jonah-williams
jonah-williams / build.sh
Created April 30, 2011 17:46
Command line iOS project builds and over-the-air distribution
#!/bin/bash
# https://gist.github.com/949831
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/
# command line OTA distribution references and examples
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html
anonymous
anonymous / indicator-sysload.c
Created May 20, 2011 14:01
indicator-sysload is an Ubuntu appindicator that displays the system load (CPU, memory usage, network traffic).
/*
This is an Ubuntu appindicator that displays the system load
(CPU, memory usage, network traffic).
It looks like this: http://imgur.com/W4PCc .
Compile with:
gcc -Wall `pkg-config --cflags --libs gtk+-2.0 appindicator-0.1 libgtop-2.0` -o indicator-sysload ./indicator-sysload.c