Skip to content

Instantly share code, notes, and snippets.

View denisdefreyne's full-sized avatar

Denis Defreyne denisdefreyne

View GitHub Profile
{
"^m" = {
"^m" = {
"?" = {
"!" = ("insertText:", "\U203D"); /* ‽ */
};
"o" = {
"/" = {
"\\~" = ("insertText:", "\U266A"); /* ♪ */
@davatron5000
davatron5000 / gist:2254924
Created March 30, 2012 20:57
Static Site Generators

Backstory: I decided to crowdsource static site generator recommendations, so the following are actual real world suggested-to-me results. I then took those and sorted them by language/server and, just for a decent relative metric, their Github Watcher count. If you want a heap of other projects (including other languages like Haskell and Python) Nanoc has the mother of all site generator lists. If you recommend another one, by all means add a comment.

Ruby

@perky
perky / ProFi.lua
Created May 30, 2012 20:32
ProFi, a simple lua profiler that works with LuaJIT and prints a pretty report file in columns.
--[[
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php.
Example:
ProFi = require 'ProFi'
ProFi:start()
some_function()
another_function()
coroutine.resume( some_coroutine )
ProFi:stop()
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@dummied
dummied / metaweblog_to_nanoc.rb
Created January 10, 2013 15:58
Hacked together metaweblog api to generate posts in nanoc, circa 2009. Only bit missing was generating/uploading the relevant content. Could have also looked at reading/writing directly to the text files, but a small sql db didn't seem like a big burden at the time.
# Erik Kastner 2008-02-16 small blog engine with XMLRPC, hAtom and S3 upload (through xlmrpc) support
require 'rubygems'
require 'sinatra'
require 'xmlrpc/marshal'
require 'active_record'
require 'aws/s3'
require 'stringex'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "sin.db")
NANOC_DIR = "/Users/cvannoy/personal/dummied/content/blog"
@headius
headius / gist:5304764
Last active December 15, 2015 18:30
Bad Ruby! No performance for you!
# $~ and $_ are frame-local, but they're set across frames and you don't know when
def foo(a, b)
p $~ # => nil
a[b] # call to String#[], b is a regexp
p $~ # => MatchData
end
foo("hello", /hel/)
@gpakosz
gpakosz / compass.rb
Created April 19, 2013 12:59
Better yet hacky Compass / nanoc integration.
def compass_sass_engine_options
fail "configuring Compass with 'relative_assets = true' doesn't make much sense in the context of nanoc" if Compass.configuration.relative_assets?
options = Compass.sass_engine_options
options[:load_paths].each do |x|
class << x
alias _inspect inspect
def inspect
_inspect.gsub(/:0x\h+/, '')
@rentalcustard
rentalcustard / gist:5524668
Last active January 13, 2022 14:21
Removing all literals from Ruby

Literals are ugly. Let's remove them.

True/false:

2.0.0p0 :001 > !Date
=> false
2.0.0p0 :002 > require Date.to_s.downcase
=> true

Integers and floats:

@txus
txus / afk.rb
Created July 15, 2013 14:45
AFK
while true
value = rand > 0.8 ? "\e[031mF\e[0m" : "\e[032m.\e[0m"
print value
sleep rand / 2
end
@bburton
bburton / Rules
Created January 15, 2014 16:08
Better default Rules for nanoc static site compiler (http://nanoc.ws version 3.x) that for the simple cases require little to no configuration. Files that are considered to be pages (based on a list of extensions), are appropriately filtered and routed for some common file types such as Haml, Markdown and Textile. All other text files and binary…
#!/usr/bin/env ruby
# This Rules file is an attempt at a near zero configuration for the common
# use cases when creating a simple site with nanoc. It's meant to have
# better defaults so new users don't have to configure it much if at all.
# For the most part, it copies all files from the content folder to the
# output folder with the same name. It has the following features:
#
# * Certain predefined page extensions such as html, haml, md, markdown and
# textile are routed to "clean" URI's (see below regarding Item identifiers).