This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Helpful link: http://httpd.apache.org/docs/2.4/logs.html | |
require 'date' | |
line_count = 0 | |
File.open(ARGV[0]).readlines.each do |line| | |
line_count += 1 | |
result = /^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).*\[(.*)\].*(GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT)\s(.*)\"\s(\d+)\s(\d+)(.*)$/.match(line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name SludgeHammer | |
// @namespace gamerswithjobs | |
// @description Replaces marketing speak with English | |
// @exclude /github/ | |
// @author Chris Doggett | |
// ==/UserScript== | |
// Special thanks to Jeremy Banks at http://stackoverflow.com/a/6834930/64203 | |
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mandrill' | |
files = ["mh-files-wo-lb-20141026_0009.tar.gz","mh-files-lb-only-20141026_0009.tar.gz"] | |
files.each do |f| | |
if File.exist?(f) | |
size = File.stat(f).size | |
gb = 1024 ** 3 | |
mb = 1024 ** 2 | |
status = "#{size / gb} gb (#{size / mb} mb)" | |
puts "File #{f} - as of #{Time.now}:\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'open-uri' | |
OAUTH_TOKEN = '' | |
class Github | |
def auth_token | |
"access_token="+OAUTH_TOKEN unless OAUTH_TOKEN.empty? | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for f in `find ~/.ssh -perm 600 -type f` | |
do | |
add_key=true | |
for k in `ssh-add -l` | |
do | |
if [[ "$k" = "$f" ]] | |
then | |
add_key=false | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# chruby - https://github.com/postmodern/chruby | |
wget -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz | |
tar -xzvf chruby-0.3.9.tar.gz | |
cd chruby-0.3.9/ | |
sudo make install | |
echo "Add to you shellrc file: source /usr/local/share/chruby/chruby.sh" | |
# ruby-install - https://github.com/postmodern/ruby-install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RuboCopper | |
def analyze | |
system 'rubocop', '--display-cop-names', *files | |
end | |
def autofix | |
system 'rubocop', '--auto-correct', '--display-cop-names', *files | |
end | |
def valid? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/01_session_security.rb | |
module SessionSecurity | |
def generate_sid | |
sid = SecureRandom.hex(32) | |
sid.encode!(Encoding::UTF_8) | |
sid | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'net/http' | |
require 'uri' | |
require 'byebug' | |
require 'open-uri' | |
class LinuxKernel | |
OFFICIAL_KERNEL_URL = 'https://www.kernel.org/'.freeze | |
UBUNTU_KERNEL_BASE_URL = 'http://kernel.ubuntu.com/~kernel-ppa/mainline/'.freeze |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'etc' | |
commands = {} | |
File.readlines(File.join(Etc.getpwuid.dir, '.zsh_history')).each do |l| | |
l = l.encode('utf-8', 'binary', :undef => :replace) | |
next if l == '' | |
next unless l.match(/: \d+:/) | |
l = l.sub(';','[SPLIT]').split('[SPLIT]') | |
key = l.last.split.first |
OlderNewer