Skip to content

Instantly share code, notes, and snippets.

Michael Mahemoff mahemoff

Block or report user

Report or block mahemoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
diegopacheco /
Created Aug 10, 2016
How to Delete All Data in Elasticsearch?
curl -XDELETE localhost:9200/*
dimitrismistriotis /
Last active Jan 3, 2019
Migrating to new Linux checklist
View rack_gc_heap_instrumentation.rb
require 'statsd'
class RackGcHeapInstrumentation
def initialize(app)
@app = app
@statsd ='localhost', 8125)
def call(env)
GC.enable # Ensure garbage colletion is enabled
ret =
coleww / gist:55cea96ff08dd30af611
Created Jul 18, 2014
weighted shuffle in ruby.
View gist:55cea96ff08dd30af611
things.sort_by do |thing|
-((thing.created_at.to_f / * rand)
marcusphi / ansible_conditionals_examples.yaml
Created Oct 2, 2013
Ansible 1.3 Conditional Execution -- Very complete example with comments -- I find the conditional expressions to be ridiculously hard to get right in Ansible. I don't have a good model of what's going on under the surface so I often get it wrong. What makes it even harder is that there has been at least three different variants over the course …
View ansible_conditionals_examples.yaml
# This has been tested with ansible 1.3 with these commands:
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts"
# NB: The type of the variable is crucial!
- name: Ansible Conditionals Examples
hosts: $hosts
burke /
Last active Jul 30, 2019
This sets up keybindings in tmux that allow you to copy/paste to/from your OS X clipboard from tmux running inside an SSH connection to a remote host. Partially borrowed from

Local (OS X) Side


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
jrochkind /
Created Oct 15, 2012
Truncating html with nokogiri, with/without Rails

Rails has a handy truncate helper (which is actually mostly a method added to String ), but it warns you it's not safe to use on html source, it'll cut off end tags and such.

What if you want an HTML safe one? There are a variety of suggested solutions you can google, none of which were quite robust/powerful enough for me.

So I started with my favorite, by Andrea Singh, using nokogiri.


  • I modified it to not monkey-patch Nokogiri, but be a static method instead (sadly making already confusing code yet more confusing, but I didn't want to monkey patch nokogiri)
marktheunissen / pedantically_commented_playbook.yml
Created Jun 23, 2012 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
View pedantically_commented_playbook.yml
# ^^^ YAML documents must begin with the document separator "---"
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
View gist:2492118
class ActionDispatch::Routing::Mapper
def draw(routes_name)
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
View pluralize_with_delimiter
# Convenient little Rails view helper that does exactly what it says
def pluralize_with_delimiter(count, singular, plural = nil)
pluralize(number_with_delimiter(count), singular, plural)
You can’t perform that action at this time.