Skip to content

Instantly share code, notes, and snippets.

@balupton
balupton / blog-moving-docpad-forward-a-gui.md
Created June 10, 2012 15:40
Blog: Moving DocPad Forward, the rise of backend-agnostic GUIs

Moving DocPad Forward, the rise of backend-agnostic GUIs

A GUI, or rather a CMS interface for DocPad is the big next step. It was also one of the first proof of concepts I used to ensure DocPad would be able to scale into the web development platform of the future.

Proof of Concept

Back in the first early months of DocPad, I created three plugins:

  • Authenticate: To authenticate you against the project's maintainers to ensure that you have read and write access
  • REST: Provided authenticated users the ability to update documents via HTTP POST requests using JSON
@maccman
maccman / juggernaut.rb
Created June 26, 2012 02:49
Sinatra Server Side Event streaming.
# Usage: redis-cli publish message hello
require 'sinatra'
require 'redis'
conns = []
get '/' do
erb :index
end
@vicentereig
vicentereig / ruby_csv_simple_object_mapping.rb
Last active October 7, 2015 15:38
Awesome FasterCSV Features. Thanks @JEG2
# http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html#method-c-load
# http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html#method-c-dump
# https://github.com/JEG2/faster_csv/blob/master/test/tc_serialization.rb
require 'csv'
class Person
attr_accessor :id, :name, :email
def self.csv_load(meta, headers, row)
person = Person.new
@klj613
klj613 / gittips.md
Created September 4, 2012 16:12
Git Tips

...

  • treeish: anything which references a commit (e.g. branch, HEAD, HEAD10, master15, SHA)

git show <treeish>:<file>

Displays file from a specific commit

git checkout <treeish> -- <file>

Checkout a file from a specific commit

e.g.

@shostakovich
shostakovich / bootstrap.sh
Created October 1, 2012 17:16
Chef Solo on Mac OS X - examples
#!/bin/sh
USERNAME=shostakovich
mkdir ~/tmp
cd ~/tmp
# Install GCC + Git
curl https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg > GCC-10.7-v2.pkg
sudo installer -pkg GCC-10.7-v2.pkg -target /
@garethrees
garethrees / hash_arguments.rb
Last active October 12, 2015 14:08
Hash arguments, default values and asserting valid keys
def donate_to_charity(args = {})
# Set valid options that can be supplied. All others will be cut.
valid_args = [:user_id, :charity_id, :amount]
# Set default options if none are supplied
defaults = { :user_id => nil,
:charity_id => 1,
:amount => 25 }
# Raise ArgumentError if invalid keys are passed
@garethrees
garethrees / _analytics.html.erb
Created November 24, 2012 22:35
Rails Shared Templates
<%#
# Renders Google Analytics tracking script
#
# Example
#
# <%= render 'shared/analytics', ua_code: 'UA-XXXXXX-X' %>
#
#%>
<% if Rails.env.production? %>
<script type="text/javascript">
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@Odaeus
Odaeus / packages.md
Last active December 15, 2015 10:19
Packages for running Ruby on Rails on Ubuntu

Minimal for gem compilation

  • build-essential

Common for gems

  • libxml2
  • libxml2-dev (for nokogiri)

Ruby compilation

  • libreadline6
@qrush
qrush / gist:5301799
Created April 3, 2013 14:41
spring clean your git repos!
# remove any bad refs
git remote prune origin
# pipe into bash and auto-delete any branches that have been merged into master!
git log master --pretty=format:'%d' | grep '^ (origin' | tr -d ' ()' | sed 's/origin\//git push origin :/'