Skip to content

Instantly share code, notes, and snippets.

Avatar
💖

Josh Mills trueheart78

💖
View GitHub Profile
@trueheart78
trueheart78 / web-servers.md
Created May 28, 2021 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@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 Apr 2, 2021
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