Skip to content

Instantly share code, notes, and snippets.

Josh trueheart78

Block or report user

Report or block trueheart78

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
@trueheart78
trueheart78 / api-gateway-taylor-showtime-2018.markdown
Last active Jun 11, 2018
API Gateway - Taylor Showtime 2018
View api-gateway-taylor-showtime-2018.markdown
View git-functions.sh
# remap git to point to g()
git () {
g "$@"
}
# git super command
# make sure with zsh that the git plugin is not used
# as it will override this command
g () {
if [[ $# -gt 0 ]]
@trueheart78
trueheart78 / zsh-history-parser.rb
Last active Feb 27, 2018
A Z Shell History Parser
View zsh-history-parser.rb
#!/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
@trueheart78
trueheart78 / download_recent_stable_kernel.rb
Last active Feb 4, 2018
Detect and download the most recent stable Ubuntu kernel version
View download_recent_stable_kernel.rb
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
@trueheart78
trueheart78 / 01_session_security.rb
Created Dec 12, 2017
64 Digit Session ID for Rails
View 01_session_security.rb
# config/initializers/01_session_security.rb
module SessionSecurity
def generate_sid
sid = SecureRandom.hex(32)
sid.encode!(Encoding::UTF_8)
sid
end
end
View rubo_copper.rb
class RuboCopper
def analyze
system 'rubocop', '--display-cop-names', *files
end
def autofix
system 'rubocop', '--auto-correct', '--display-cop-names', *files
end
def valid?
@trueheart78
trueheart78 / chruby-ruby-setup.sh
Last active Aug 31, 2016
Chruby + Ruby Install Setup
View chruby-ruby-setup.sh
#!/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
View sludgehammer.user.js
// ==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)})};
View apache-access-log-parser.rb
#!/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)
View SSH-Autoloader.sh
#!/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
You can’t perform that action at this time.