Skip to content

Instantly share code, notes, and snippets.

View voondo's full-sized avatar

Romain Lalaut voondo

View GitHub Profile
@chetan
chetan / yardoc_cheatsheet.md
Last active November 11, 2024 08:27
YARD cheatsheet
@afair
afair / get_mxers.rb
Created April 24, 2012 14:38
Ruby: lookup email MX servers for a domain
require 'resolv'
class Domain
def mxers(domain)
mxs = Resolv::DNS.open do |dns|
ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
ress.map { |r| [r.exchange.to_s, IPSocket::getaddress(r.exchange.to_s), r.preference] }
end
return mxs
@maciej
maciej / git-change-author.sh
Created July 2, 2013 13:19
Change the author & committer name and/or email of a single commit.
#!/bin/sh
#
# Change the author & committer name and/or email of a single commit.
#
# change-author [-f] commit-to-change [branch-to-rewrite [new-name [new-email]]]
#
# If -f is supplied it is passed to "git filter-branch".
#
# If <branch-to-rewrite> is not provided or is empty HEAD will be used.
@niccokunzmann
niccokunzmann / hanging_threads.py
Last active November 4, 2024 14:48
This module prints all hanging threads that are dead locked. It is for Python 2 and 3. Installable: https://pypi.python.org/pypi/hanging_threads
## The MIT License (MIT)
## ---------------------
##
## Copyright (C) 2014 Nicco Kunzmann
##
## https://gist.github.com/niccokunzmann/6038331
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the "Software"),
@tokenvolt
tokenvolt / simple_form_bootstrap3.rb
Last active November 2, 2023 11:55
Bootstrap 3 simple form initializer
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
@vdavez
vdavez / docx2md.md
Last active June 17, 2024 19:40
Convert a Word Document into MD

Converting a Word Document to Markdown in Two Moves

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

The Solution

As it turns out, there are several open-source tools that allow for conversion between file types. Pandoc is one of them, and it's powerful. In fact, pandoc's website says "If you need to convert files from one markup format into another, pandoc is your swiss-army knife." But, although pandoc can convert from markdown into .docx, it doesn't work in the other direction.

@iamralpht
iamralpht / .bashrc
Last active January 3, 2016 11:49
bashrc hacks for per-directory history
# Hack to implement per-directory history. If you run the same commands in the same directories,
# then why not have a separate history for each directory?
HISTBASE=~/.bash_directory_hist
LASTHIST=
_hash() {
echo "$@" | sha512sum | cut -f1 -d' '
}
@gfrey
gfrey / gist:8472007
Created January 17, 2014 11:34
Upstart script for haproxy with support for reload.
description "Properly handle haproxy"
start on startup
env PID_PATH=/var/run/haproxy.pid
env BIN_PATH=/usr/sbin/haproxy
script
exec /bin/bash <<EOF
$BIN_PATH -f /etc/haproxy.cfg -D -p $PID_PATH
@ruby-railings
ruby-railings / bulk_processor.rb
Last active January 7, 2016 00:46
This is a bulk processor for Paperclip. Depending on the number of styles, it can speed up the generation of multiple thumbnails. Read more at http://www.ruby-railings.de/de/rails/paperclip/2014/01/26/speed-up-paperclip.html (German) or http://www.ruby-railings.com/de/rails/paperclip/2014/01/26/speed-up-paperclip.html (English)
module Paperclip
# A wrapper for a queued item. Normally this would be a temporary file, but we can't do that, because Paperclip
# would copy the temporary file before the content is actually written.
class BulkQueueItem
attr_reader :destination
def initialize(destination)
@destination = destination
end
end
@mgdelacroix
mgdelacroix / autoloading.rb
Created April 13, 2014 17:57
Autoloading for rails 4 lib folder
# In config/application.rb
config.watchable_dirs['lib'] = [:rb]
# When requiring something, use require_dependency
# To use lib/myclass.rb
require_dependency 'myclass'