Skip to content

Instantly share code, notes, and snippets.

View utensil's full-sized avatar

Utensil utensil

  • 00:01 (UTC +08:00)
View GitHub Profile
@tdreyno
tdreyno / config.rb
Created August 3, 2011 23:22
Latex 2 PDF Middleman
# Find all markdown files
path = File.join(File.dirname(__FILE__), "source", "**/*.html.markdown")
# Also generate .latex files along side
Dir[path].each do |markdown_file|
http_path = markdown_file.split("source").last.gsub(".html.markdown", "")
page "#{http_path}.latex", :proxy => "#{http_path}.html", :latex => true, :layout => false
end
require "fileutils"
@jessykate
jessykate / Jekyll nd Octopress Liquid tag for MathJax.rb
Created February 18, 2011 23:37
A simple liquid tag for Jekyll/Octopress that converts {% m %} and {% em %} into inline math, and {% math %} and {% endmath %} into block equations, by replacing with the appropriate MathJax script tags.
module Jekyll
class MathJaxBlockTag < Liquid::Tag
def render(context)
'<script type="math/tex; mode=display">'
end
end
class MathJaxInlineTag < Liquid::Tag
def render(context)
'<script type="math/tex">'
end
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active October 27, 2025 08:27
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@yugui
yugui / gist:1724
Created July 23, 2008 13:39
Decorator for Ruby, inspired by Python
class Module
def declare(decorator, *args)
orig_method_added = method(:method_added)
metaclass = (class << self; self end)
defined_methods = []
metaclass.send(:define_method, :method_added) do |name|
orig_method_added.call(name)
defined_methods << name
end
begin