Skip to content

Instantly share code, notes, and snippets.

View mikker's full-sized avatar
👋

Mikkel Malmberg mikker

👋
View GitHub Profile
@voldy
voldy / gist:271377
Created January 7, 2010 17:15
Using Formtastic and JQuery DatePicker
##formtastic_datepicker_interface
module Formtastic
module DatePicker
protected
def datepicker_input(method, options = {})
format = options[:format] || ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS[:default] || '%d %b %Y'
string_input(method, datepicker_options(format, object.send(method)).merge(options))
end
@jlong
jlong / config.ru
Created June 23, 2011 19:56
Directory Index w/ Rack
# The project root directory
$root = ::File.dirname(__FILE__)
# Common Rack Middleware
use Rack::ShowStatus # Nice looking 404s and other messages
use Rack::ShowExceptions # Nice looking errors
#
# From Rack::DirectoryIndex:
# https://github.com/craigmarksmith/rack-directory-index/
function rake {
if [ -e Gemfile ]; then
bundle exec rake $@
else
`which rake` $@
fi
}
function rspec {
if [ -e Gemfile ]; then
@JackNorris
JackNorris / rbenv-install-system-wide.sh
Created January 29, 2012 17:36
CentOS: rbenv install and system wide install
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
make bzip2 autoconf automake libtool bison iconv-devel git-core
@chetan
chetan / yardoc_cheatsheet.md
Last active October 17, 2025 13:49
YARD cheatsheet
@jpfuentes2
jpfuentes2 / rbenv-install-system-wide.sh
Created March 8, 2012 19:47
CentOS: rbenv install and system wide install
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
make bzip2 autoconf automake libtool bison iconv-devel git-core
@kapkaev
kapkaev / gist:4619127
Created January 24, 2013 09:30
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. Resque
$ redis-cli
> config set stop-writes-on-bgsave-error no
@jbgo
jbgo / wtf_notepad.md
Last active March 10, 2023 12:53
Safely remove byte order marks (BOM) and carriage returns (^M) from files edited with Notepad on windows

TLDR: File.read(a_file).sub("\xEF\xBB\xBF", "").gsub("\r", "")

I tried using combinations of find/awk/sed, but I ended up corrupting my project files including the git index because I don't understand those commands very well. So instead, I turned to my good old friend ruby. This also has the advantage that I can use it in my program that processes these files. They've been ninja-edited (modfied outside of source control) in the past, which makes it likely that someone will come by and ninja edit them again in the future. But instead of convincing people that it's bad to edit files in notepad or outside of source control, we can just silently fix it on the fly and smile and say "Happy Friday!"

Here is the example of what I'm cleaning up. Thankfully, git's diff viewer is brutally honest and shows these characters. Unfortunately, most editors (including the good ones) simply hide these characters and put them back in when you save the file. The byte order marks were causing browsers to skip CSS declarations

@n8henrie
n8henrie / QS_Action_Template.applescript
Last active August 15, 2022 03:57
Template for writing Quicksilver (>= v1.0) actions in AppleScript
(*
Template for writing Quicksilver (>= v1.0) actions in AppleScript
See post at: http://n8henrie.com/2013/03/template-for-writing-quicksilver-actions-in-applescript/
Reference: http://qsapp.com/wiki/AppleScript_Types
See another example at:
http://blog.qsapp.com/post/46268365849/quicksilver-comes-of-age
## Update 20160318:
@jedi4ever
jedi4ever / dns tuning ssh login speedup vagrant
Created May 27, 2013 13:37
speeding up DNS/SSH connections in vagrant
- Tune /etc/ssh/sshd_config
UseDNS no # Disable DNS lookups
GSSAPIAuthentication no # Disable negotation of slow GSSAPI
don't forget to restart it, use a script provider to set it , or create it with veewee or snapshot it
- Tune Vagrantfile
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]