Skip to content

Instantly share code, notes, and snippets.

# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
@valvallow
valvallow / dotimes.scm
Created May 25, 2010 13:53
dotimes, syntax, scheme
;; dotimes
(define-syntax dotimes
(syntax-rules ()
((_ n body ...)
(do ((i n (- i 1)))
((not (< 0 i)))
body ...))))
(dotimes 5
@mrluanma
mrluanma / cryptography_3des_demo.py
Last active July 23, 2019 06:09
Python 用 PyCrypto, M2Crypto, ncrypt, cryptography 3DES ECB mode 加密解密 demo。
import os
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.backends import default_backend
backend = default_backend()
key = os.urandom(16)
text = b'Hello, there!'
padder = padding.PKCS7(algorithms.TripleDES.block_size).padder()
@mhenrixon
mhenrixon / _form.html.haml
Created May 18, 2011 11:02
A complete sample of how to perform nested polymorphic uploads in rails using carrierwave
=semantic_form_for [:admin, @dog], validate: true, html: {multipart: true} do |f|
=f.inputs do
=f.input :name
=f.input :kennel_name
=f.input :birthdate
=f.input :gender, as: :radio, collection: {'Tik' => 'F', 'Hane' => 'M'}
=f.input :father_id, as: :select, collection: @dogs
=f.input :mother_id, as: :select, collection: @bitches
=f.semantic_fields_for :pictures do |pic|
@dgutov
dgutov / gist:1274520
Created October 10, 2011 02:35
ruby-indent-line advice for closing paren
(defadvice ruby-indent-line (after unindent-closing-paren activate)
(let ((column (current-column))
indent offset)
(save-excursion
(back-to-indentation)
(let ((state (syntax-ppss)))
(setq offset (- column (current-column)))
(when (and (eq (char-after) ?\))
(not (zerop (car state))))
(goto-char (cadr state))
@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
@agnoster
agnoster / README.md
Last active April 6, 2024 22:35
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 5, 2024 22:16
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@havenwood
havenwood / clip.rb
Last active December 14, 2015 18:39
Copy and Paste to OS X, BSD, and Linux clipboards with Ruby.
class Clipboard
CopyPaste = Struct.new :copy, :paste
def initialize
cmds = [['pbcopy', 'pbpaste'],
['xclip', 'xclip -o'],
['xsel', 'xsel -o']]
cmds.map! do |cmd|
CopyPaste.new cmd.first, cmd.last
@SaitoWu
SaitoWu / graph.rb
Last active December 25, 2017 07:30
Github Contribution Graph
require 'date'
author = "Saito"
email = "saitowu@gmail.com"
date = Date.new(2012, 7, 30)
s = %w{
. . . . . . .
. . o o o . .
. o . . . . .