Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am gmcmillan on github.
  • I am mcmgr (https://keybase.io/mcmgr) on keybase.
  • I have a public key whose fingerprint is 1AE8 6C97 4E2B 903B 250C 0A63 5B88 A21A 0B47 7BB5

To claim this, I am signing this object:

@gmcmillan
gmcmillan / .gemrc
Created October 7, 2010 14:53
site5
---
gemhome: /home/USERNAME/.gems
gempath:
- /home/USERNAME/.gems
- /usr/lib/ruby/gems/1.8
@gmcmillan
gmcmillan / rdio.scpt
Created November 29, 2012 17:27
rdio.scpt
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
on shortenUrl(str)
set curl_cmd to "curl -s https://www.googleapis.com/urlshortener/v1/url"
set json to " -H 'Content-Type: application/json' -d '{\"longUrl\": \"" & str & "\"}'"
set grep_cmd to "grep -Eo 'http:\\/\\/goo\\.gl\\/[0-9A-Za-z]*'"
set command to curl_cmd & json & " | " & grep_cmd
do shell script command
irb(main):002:0> "AaAAaAA".match('\A[a-zA-Z]')
=> #<MatchData "A">
root@cvm01 [/var/cpanel]# /usr/local/cpanel/bin/fetch_cpconf_value access_log
/usr/local/cpanel/logs/access_log

1. Install Xcode

2. Use XCode to install Command Line Utilities (GCC)

Open Xcode. Click the "Xcode" button in the top left of the screen near the Apple logo, then click "Preferences", then click "Downloads".

3. Install rbenv:

@gmcmillan
gmcmillan / parse_ini.rb
Created January 21, 2013 17:58
Simple parser for my.cnf/ini files without needing an external library.
class Config
# The path to the config file as a String.
attr_reader :file
# Attributes used while config is parsed.
#
# Example:
# [mysqld] # group
# param = val # param, val
FileBench Version 1.4.4
filebench> load webserver
98008: 3.236: Webserver Version 2.1 personality successfully loaded
98008: 3.236: Usage: set $dir=<dir>
98008: 3.236: set $filesize=<size> defaults to 16384
98008: 3.236: set $nfiles=<value> defaults to 1000
98008: 3.236: set $dirwidth=<value> defaults to 20
98008: 3.236: set $nthreads=<value> defaults to 100
98008: 3.236: set $iosize=<size> defaults to 1048576
98008: 3.236: run runtime (e.g. run 60)
@gmcmillan
gmcmillan / safe_browsing.rb
Last active May 16, 2016 12:50
Ruby Class to Query Google Safe Browsing API in Batches
# Note: POST requests are limited to 500 domains each with the SB API, which is why this code splits it into batches
require 'net/https'
require 'open3'
class SafeBrowsing
attr_reader :opt
attr_accessor :results
@gmcmillan
gmcmillan / purge-ban-domain-varnish.md
Created March 30, 2017 14:55 — forked from aderowbotham/purge-ban-domain-varnish.md
Purge (ban) an entire domain in Varnish Cache 3

How to purge ('ban') an entire domain in Varnish Cache 3

#####EDIT: NB Ban is technically different from Purge. Banned objects remain in memory but banning is faster than purging. Read the Varnish 3 documentation here and here.

Purge may be a more appropriate action for your use-case; although the examples in the gist below work, it's not necessarily the best way of doing this.