Skip to content

Instantly share code, notes, and snippets.

@stack
stack / gist:486408
Created July 22, 2010 18:52
A script for switching between git profiles
#!/bin/bash
case "$1" in
'place1')
git config --global user.name "Your Name"
git config --global user.email foo@bar.com
;;
*)
git config --global user.name "Your Other Name"
git config --global user.email bar@baz.com
@stack
stack / copy.ps1
Created November 11, 2010 17:56
A script for copying files from a corrupt hard drive
$source = $args[0];
$dest = $args[1];
$files = Get-ChildItem "$source" -recurse
foreach($file in $files) {
if ($file.psiscontainer) {
$common_directory = $file.FullName.Replace($source, "")
$new_directory = $dest + $common_directory
Write-Host "Creating directory $new_directory"
New-Item $new_directory -type directory
@stack
stack / close-status.rb
Created January 17, 2011 22:55
A script to turn off my chat accounts at the end of the day
#!/usr/bin/env ruby
require 'rubygems'
require 'dbus'
# Get the proper DBus session address
pid = nil
programs = %w( gnome-session )
programs.each do |program|
pid = `pidof -s #{program}`
@stack
stack / embedded_mailer.rb
Created April 7, 2011 16:40
Multipart Alternative + Multipart Related Email with ActionMailer for Rails 2
class EmbeddedMailer < ActionMailer::Base
def embedded_mail(to, from, subject, html_message, text_message, files = {}, embeds = {})
# Hack TMail to allow embeds
TMail::HeaderField::FNAME_TO_CLASS.delete 'content-id'
recipients to
from from
subject subject
@stack
stack / embedded_mailer.rb
Created April 7, 2011 16:41
Multipart Alternative + Multipart Related Email with ActionMailer for Rails 3
class EmbeddedMailer < ActionMailer::Base
def embedded_mail(to, from, subject, html_message, text_message, files = {}, embeds = {})
mail(:to => to, :from => from, :subject => subject) do |format|
format.text { render :text => text_message }
format.html { render :text => html_message }
end
# Embeds
embeds.each do |key, embed|
@stack
stack / lighttpd.conf
Created May 25, 2011 20:34
Lighttpd config file for local development
server.bind = "0.0.0.0"
server.port = 3000
server.document-root = CWD
index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" )
server.modules = ( "mod_fastcgi" )
## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server += ( ".php" =>
<html>
<body>
<script type="text/javascript">
document.write(navigator.userAgent);
</script>
</body>
</html>

Keybase proof

I hereby claim:

  • I am stack on github.
  • I am stack (https://keybase.io/stack) on keybase.
  • I have a public key whose fingerprint is 21E9 80DD 2C0D 1421 F5C3 9859 D5D3 F4F8 C270 4B4E

To claim this, I am signing this object:

@stack
stack / net detect.rb
Created November 27, 2015 05:06
A script for my friend to help with a failing wireless card
#!/usr/bin/env ruby
require 'rubygems'
require 'net/ping'
require 'time'
TEST_SITES = [
"http://www.google.com",
"http://www.yahoo.com"
].freeze
@stack
stack / UIView+Superviews.swift
Created February 19, 2016 04:00
An extension of UIView that gives a superviews property as a sequence
//
// UIView+SuperviewSequence.swift
// PhotoKeeper
//
// Created by Stephen Gerstacker on 2/18/16.
// Copyright © 2016 net.shortround. All rights reserved.
//
import UIKit