Skip to content

Instantly share code, notes, and snippets.

@thomasd
thomasd / gd_watermark.inc.php
Created December 4, 2009 10:33
Overlays an image with a watermark image (phpThumb-Plugin for GD-lib)
<?php
/**
* GD Watermark Lib Plugin Definition File
*
* This file contains the plugin definition for GD Watermark
* Usage:
* <?php
* require_once 'path/to/ThumbLib.inc.php';
* $pic = PhpThumbFactory::create('path/to/pic/destination');
* $watermark = PhpThumbFactory::create('path/to/watermark/destination');
@nragaz
nragaz / unicorn.rb
Created July 12, 2010 03:34
unicorn.rb
# unicorn_rails -c /srv/myapp/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
working_directory (rails_env == 'production' ? "/srv/myapp/current" : `pwd`.gsub("\n", ""))
worker_processes (rails_env == 'production' ? 10 : 4)
preload_app true
timeout 30
if rails_env == 'production'
@chrisroos
chrisroos / gpg-import-and-export-instructions.md
Created September 9, 2011 10:49
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@jeffrafter
jeffrafter / gist:1328625
Last active December 26, 2018 12:54
Local nginx proxy to rails s
worker_processes 1;
error_log /usr/local/var/log/nginx.error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
@redinger
redinger / Emacs.md
Created November 26, 2011 03:22
Setting up Emacs daemon on OS X

Setting up Emacs daemon on OS X

Tired of waiting for emacs to start on OS X? This step by step guide will teach you how to install the latest version of emacs and configure it to start in the background (daemon mode) and use emacsclient as your main editor.

Install Cocoa Emacs

Download the latest pretest version of [Emacs for Mac OS X]: http://emacsformacosx.com/builds

@chumpy
chumpy / yaml_compare.rb
Created January 29, 2012 00:20
compare two yaml files in ruby
#require 'active_support/core_ext'
class YamlCompare
def self.compare_keys first_file_info, second_file_info, results_location
first_file = Hash.new
second_file = Hash.new
deltas_file = Hash.new
File.open( first_file_info[:file_location] ) { |yf| first_file = YAML.load( yf ) }
File.open( second_file_info[:file_location] ) { |yf| second_file = YAML.load( yf ) }
first_file[first_file_info[:root]].each_pair do |k,v|
@drj42
drj42 / org-mode-reference-in.org
Created February 6, 2012 23:53
This is a cheat sheet for Emacs org-mode... in org-mode format!

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@jfarmer
jfarmer / 01-truthy-and-falsey-ruby.md
Last active April 16, 2024 03:40
True and False vs. "Truthy" and "Falsey" (or "Falsy") in Ruby, Python, and JavaScript

true and false vs. "truthy" and "falsey" (or "falsy") in Ruby, Python, and JavaScript

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False. But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.).

This outlines how this works in Ruby, with some basic examples from Python and JavaScript, too. The idea is much more general than any of these specific languages, though. It's really a question of how the people designing a programming language wants booleans and conditionals to work.

If you want to use or share this material, please see the license file, below.

Update

@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a