Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh trueheart78

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 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
@trueheart78
trueheart78 / issue-puller.rb
Last active Aug 29, 2015
Github Issue Retriever for a particular user (exercism)
View issue-puller.rb
require 'json'
require 'open-uri'
OAUTH_TOKEN = ''
class Github
def auth_token
"access_token="+OAUTH_TOKEN unless OAUTH_TOKEN.empty?
end
end
@trueheart78
trueheart78 / fs-monitor.rb
Last active Aug 29, 2015
A simple ruby script to monitor filesizes during a large transfer. Setup to run through cron. Requires the mandrill-api gem to be installed, as well as a mandrill API key in your enviroment in MANDRILL_APIKEY
View fs-monitor.rb
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"
You can’t perform that action at this time.