Skip to content

Instantly share code, notes, and snippets.

View X0nic's full-sized avatar

Nathan Lee X0nic

View GitHub Profile
@X0nic
X0nic / Vagrantfile
Created July 3, 2014 22:36
Vagrantfile loading run_list via json
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'multi_json'
Vagrant::Config.run do |config|
# Will load nodes/vagrant.json
VAGRANT_JSON = MultiJson.load(Pathname(__FILE__).dirname.join('nodes', 'vagrant.json').read)
@X0nic
X0nic / Vagrantfile
Last active August 29, 2015 13:59
Clean up chef server on vagrant destroy
# Borrowed from https://coderwall.com/p/sikrdw
module Vagrant
module Provisioners
class Base
require 'chef'
require 'chef/config'
require 'chef/knife'
end
@X0nic
X0nic / gist:8659912
Created January 28, 2014 00:02
nginx maintance
set $is_trusted_ip false;
if ($http_x_forwarded_for ~ "68\.148\.96\.174") {
set $is_trusted_ip true;
}
@X0nic
X0nic / renamer.rb
Last active January 2, 2016 06:09
Rename mp3s based on tags
#!/usr/bin/env ruby
# Thanks to: Ahmad Azizan
# http://blog.lab69.com/2012/02/renaming-mp3-files-with-ruby.html
# You need to require this..
require 'rubygems'
require 'mp3info'
# This variable will hold your first argument as directory
@X0nic
X0nic / list-memcache-keys.rb
Created November 19, 2013 19:36
List local memcache keys in ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Copied from: https://gist.github.com/bkimble/1365005
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@X0nic
X0nic / ip-ips.sh
Last active December 22, 2015 16:08
Top ips hitting the access log
#! /bin/env bash
cat {{web_logs}}/access.log | sort -k1 | awk '{print $1}' | uniq -c | sort -k 1 -nr | head -n 20
@X0nic
X0nic / sizes.sh
Created September 5, 2013 16:27
Calculate directory sizes
ls | xargs du -hs | sort -nr
@X0nic
X0nic / enable_php_errors.php
Created May 15, 2013 17:22
enable php errors
error_reporting(E_ALL);
ini_set('display_errors', '1');
@X0nic
X0nic / pow.sh
Created March 14, 2013 16:53
Disable / enable pow
#disable
launchctl unload "$HOME/Library/LaunchAgents/cx.pow.powd.plist"
#enable
launchctl load -Fw "$HOME/Library/LaunchAgents/cx.pow.powd.plist"
@X0nic
X0nic / replace.sh
Last active December 14, 2015 14:38
Search and replace in a folder
# osx
ack -l "ReplaceMe" | xargs sed -i "" "s/ReplaceMe/withMe/g"
# linux
ack -l "ReplaceMe" | xargs sed -i "s/ReplaceMe/withMe/g"
#amember
ack --php -l "Release: 3\..\..PRO \(.Revision\: .*\)" | xargs sed -i "" "s/Release: 3\..\..PRO.*$/Release: xxxxxxxxxxxxxxxxxxx/g"