Skip to content

Instantly share code, notes, and snippets.

View pwightman's full-sized avatar

Parker Wightman pwightman

View GitHub Profile
@danking
danking / gist:1068185
Created July 6, 2011 19:55
A very simple example showing how to use Racket's lexing and parsing utilities
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@coreyhaines
coreyhaines / .rspec
Last active August 15, 2024 15:13
Active Record Spec Helper - Loading just active record
--colour
-I app
@davidjrice
davidjrice / redcarpet.rb
Created June 29, 2012 00:34
Rails 3.2 Markdown Template Handler
# config/initializers/redcarpet.rb
module ActionView
module Template::Handlers
class Markdown
class_attribute :default_format
self.default_format = Mime::HTML
def call(template)
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
markdown.render(template.source).html_safe.inspect
@mitfik
mitfik / gist:3169039
Created July 24, 2012 09:22
Helper for S3 direct upload file
def s3_form_tag(options = {})
bucket = options[:bucket]
access_key_id = options[:access_key_id]
secret_access_key = options[:secret_access_key]
key = options[:key] || ''
content_type = options[:content_type] || '' # Defaults to binary/octet-stream if blank
redirect = options[:redirect] || '/'
acl = options[:acl] || 'public-read'
expiration_date = options[:expiration_date].strftime('%Y-%m-%dT%H:%M:%S.000Z') if options[:expiration_date]
max_filesize = options[:max_filesize] || 671088640 # 5 gb
@jamesejr
jamesejr / .bashrc
Last active December 14, 2015 11:19
Personal .bashrc file with Terminal colors, Homebrew tab completion, and custom Bash/Git prompts
# Add Git branch prompt
function git-current-branch {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
# Add custom bash prompt via kirsle.net/wizards/ps1.html
export PS1="\u@macbook \[$(tput setaf 2)\][\W] \[$(tput setaf 1)\]\$(git-current-branch)\[$(tput setaf 7)\]> \[$(tput sgr0)\]"
# Add Git auto completion support
source /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
@chrisl8888
chrisl8888 / drupal-views-share-global-text-field
Last active April 23, 2024 04:07
share url's for facebook, twitter, pinterest with just get variables
<ul>
<li class="share-text">Share this>/li>
<li class="share-tw"><a href="http://twitter.com/share?text=[title]"><span></span></a></li>
<li class="share-fb"><a href="http://www.facebook.com/sharer.php?u=/node/[nid]&p=[title]"><span></span></a></li>
<li class="share-pinterest"><a href="http://pinterest.com/pin/create/button/?url=/node/[nid]&description=[title]"><span></span></a></li>
</ul>

How I Wish Racket Was First Explained To Me

I've been taking a compilers class this semester from Matt Might, which has been a great experience. Amongst the most challenging/interesting aspects of the course has been taming Racket, a Scheme-y/LISP-y language (I'll leave it at that).

Having never used anything functional/LISP-y in my days, this was a brand new experience. On the whole, it was good, but here's how I wish my first introduction to the language had gone as it would have set me on the right foot. While I'm focusing on Racket here, I imagine this same thing applies to LISP/Scheme and its derivatives.

Code vs. Data

I read everywhere that, "In Racket, code and data are the same thing." That sentence alone was useless to me, and it took a number of weeks before I "got it." Perhaps this explanation may have been more helpful:

@exce11ent
exce11ent / Merge two videos
Last active August 3, 2017 06:48
Merge two videos using AVFoundation ios
AVMutableComposition* mixComposition = [[AVMutableComposition alloc] init];
NSString *path1 = _exportPaths[0];
NSString *path2 = _exportPaths[1];
//load assets
AVURLAsset *asset1 = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:path1] options:nil];
AVURLAsset *asset2 = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:path2] options:nil];
//create mutable composition track and add all assets to this track
AVMutableCompositionTrack *track = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];