Skip to content

Instantly share code, notes, and snippets.

@nall
nall / makefile
Created June 4, 2009 22:34
USBTiny Example OSX Driver
all:
gcc -g -std=c99 -o usbtiny_osx usbtiny_osx.m -framework Foundation -framework IOKit
clean:
rm -rf usbtiny_osx
@hoverlover
hoverlover / active_admin_heroku.rb
Created June 7, 2011 16:35
Rails initializer for using ActiveAdmin with Sass on Heroku
if Rails.env.production?
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "admin"))
template_path_one = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/app/assets/stylesheets"
template_path_two = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/lib/active_admin/sass"
old_compile_path = "#{Rails.root}/public/stylesheets/admin"
new_compile_path = "#{Rails.root}/tmp/stylesheets/admin"
Sass::Plugin::remove_template_location template_path_one
@kcbraunschweig
kcbraunschweig / chef-api-ha
Created July 22, 2011 01:41
chef and unicorn and nginx
Just to get you started.
https://github.com/blog/517-unicorn
http://unicorn.bogomips.org/index.html
http://wiki.nginx.org/Configuration
http://blog.tomkersten.com/2010/11/14/nginx-unicorn-rvm-server-setup.html
http://nginx.org/en/docs/http/configuring_https_servers.html
http://nginx.org/en/docs/http/request_processing.html
https://github.com/merb/merb/wiki/HOWTO-Use-Unicorn
@zaius
zaius / open_uri.rb
Created October 7, 2011 21:46
Allow open-uri to follow unsafe redirects (i.e. https to http)
# Allow open-uri to follow unsafe redirects (i.e. https to http).
# Relevant issue:
# http://redmine.ruby-lang.org/issues/3719
# Source here:
# https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb
module OpenURI
class <<self
alias_method :open_uri_original, :open_uri
alias_method :redirectable_cautious?, :redirectable?
@sinisterchipmunk
sinisterchipmunk / LICENSE
Last active September 8, 2023 17:57
tar, gzip, and untar files using ruby in memory without tempfiles
Copyright (C) 2011 by Colin MacKenzie IV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@jclulow
jclulow / 00_info.md
Created May 5, 2012 23:46
SmartOS rc.local

So, to get something like /etc/rc.local you can use the custom SMF import facility. (See the source for more information about how this actually works.)

/opt is mounted out of zones/opt by default. You can create a directory /opt/custom/smf and populate it with SMF manifests. Any manifests you put in there will be imported by SmartOS when it boots. Below is an example SMF manifest that simply starts /opt/custom/bin/postboot, a self-explanatory shell script that you can use like /etc/rc.local.

Note that it would likely be better to customise and respin your own images, as putting a bunch of platform state in the zones pool undoes some of the benefits of the ramdisk platform architecture that SmartOS has.

@jlesech
jlesech / assert.ino
Created July 11, 2012 11:55
How to use assertions with Arduino.
#define __ASSERT_USE_STDERR
#include <assert.h>
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
@ferd
ferd / erlang-shell-search-history.patch
Created December 20, 2012 13:59
Add search to Erlang shell's history Search mode can be entered by pressing ctrl-r. Enter terms and press ctrl-r again to search backwards, or ctrl-s to then search forward (if you terminal doesn't eat up that one). Press enter to execute the line, or use tab, arrow keys, or other control sequences (^D, ^K, etc.) to exit search mode while remain…
From d98e6c32d44e00f954c3912b08c6ebf48d55729c Mon Sep 17 00:00:00 2001
From: Fred Hebert <mononcqc@ferd.ca>
Date: Thu, 20 Dec 2012 08:41:33 -0500
Subject: [PATCH] Add search to Erlang shell's history
Search mode can be entered by pressing ctrl-r. Enter terms and press
ctrl-r again to search backwards, or ctrl-s to then search forward (if
you terminal doesn't eat up that one). Press enter to execute the line,
or use tab, arrow keys, or other control sequences (^D, ^K, etc.) to
exit search mode while remaining on the last found line.
@skull-squadron
skull-squadron / iso_from_files_and_folders.sh
Last active December 12, 2015 02:59
turn files and folders into an iso (put this into an applescript)
vol_name="`basename \\"$1\\"`"
iso="$vol_name.iso"
counter=1
while [ -e "$iso" ]; do
counter=$[counter+1]
iso="$vol_name $counter.iso"
done
hdiutil makehybrid -iso -joliet -o "$iso" "$@"
@chourobin
chourobin / RKAppDelegate.m
Last active October 22, 2018 14:22
Setting up magical record with RestKit
#import <RestKit/RestKit.h>
#import "CoreData+MagicalRecord.h"
// Use a class extension to expose access to MagicalRecord's private setter methods
@interface NSManagedObjectContext ()
+ (void)MR_setRootSavingContext:(NSManagedObjectContext *)context;
+ (void)MR_setDefaultContext:(NSManagedObjectContext *)moc;
@end
@implementation AppDelegate