Skip to content

Instantly share code, notes, and snippets.

View heph's full-sized avatar
:shipit:

Heph Adams heph

:shipit:
View GitHub Profile
@iangreenleaf
iangreenleaf / yaml.vim
Created March 15, 2011 17:38
Dumb-smart indentation for Yaml
" Vim indent file
" Language: Yaml
" Author: Ian Young
" Get it bundled for pathogen: https://github.com/avakhov/vim-yaml
if exists("b:did_indent")
finish
endif
"runtime! indent/ruby.vim
"unlet! b:did_indent
@heph
heph / gist:2714799
Created May 16, 2012 23:12
populate hash with command line arguments in the form of ./script.rb key=value key.key=value key.key.key=value
#!/usr/bin/ruby
require 'rubygems'
require 'json'
h = {}
ARGV.each do |a|
position = ObjectSpace._id2ref(h.object_id)
keys,value = a.split('=')
@supairish
supairish / gist:2951524
Created June 18, 2012 23:58
Nginx - how to limit requests by User Agent
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {
@heph
heph / gist:5260581
Last active December 15, 2015 12:29
Capistrano prompt for username and password with default value
set(:user, Capistrano::CLI.ui.ask("Username ") {|q| q.default = Etc.getlogin })
set(:password, Capistrano::CLI.password_prompt("Password "))
# bash <(curl -s https://gist.github.com/drye/5387341/raw/ec72cddfe43ec3d39c91a3c118cb68ab14a049f8/enable_dnsmasq_on_osx.sh)
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# ----------------------
# adding resolver for vbox domain
# ----------------------
@jamescway
jamescway / gist:5770667
Last active December 18, 2015 10:48
Find in nested hashes, prints key path recursively
def search_in_hash(hash, target, args={}, keys='ROOT')
find_key = (args[:find_key] == true)
hash.each do |key, value|
find_target = find_key ? key.to_s : value
if find_target == target
keys = "#{keys} -> '#{key}' => #{target}"
puts keys
keys = ""
end
@ogrrd
ogrrd / dnsmasq OS X.md
Last active June 12, 2024 16:25
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@nerd0
nerd0 / gist:8ceb47227015b6b72d38
Created November 5, 2014 02:11
Jenkins .gitgnore
bash -c 'cat << EOF > /var/lib/jenkins/.gitignore
*
!*.xml
!.gitignore
!jobs
!jobs/.gitignore
!jobs/*
!jobs/*/*
EOF'
@jpf
jpf / app.py
Created March 21, 2015 00:46
Example SAML SP using PySAML2. Can handle IdP initiated requests and make SP initated (authn) requests
# -*- coding: utf-8 -*-
import logging
import os
import uuid
from flask import Flask
from flask import redirect
from flask import request
from flask import url_for
from flask.ext.login import LoginManager
@tmaybe
tmaybe / ignore.md
Last active February 7, 2024 03:18
ignoring merge conflicts for specific files in a git repository

How to Ignore Merge Conflicts for Specific Files in a Git Repository

Create a directory and git init it

$ mkdir merge-test
$ cd merge-test/
$ git init