Skip to content

Instantly share code, notes, and snippets.

View gstark's full-sized avatar

Gavin Stark gstark

View GitHub Profile
@gstark
gstark / tcpdump.txt
Created April 9, 2014 13:08
Use tcpdump to monitor mysql
Use tcpdump to monitor mysql
# Capture the packets
sudo tcpdump -i eth0 port 3306 -s 65535 -x -n -q -tttt > tcpdump.out
# analyze all the requests from a given host
pt-query-digest --type=tcpdump --filter '($event->{host} || $event->{ip} || "") =~ m/192.168.248.64/' tcpdump.out

Leaving this gist in the hopes that this helps someone some day.

I was using a docker image with Alpine linux. In this docker container I installed a specific version of node via several methods (nodenv, asdf, etc.) and each time I had to add the gcompat package so I could run glibc applications.

When I tried to install many npm packages such as yarn and corejs and others I would get the error:

Error: spawn sh ENOENT

I belive I finally realized that Error: spawn sh ENOENT is happening since npm is trying to launch sh and there is some incompatibility with a glibc app running with gcompat trying to launch a non-glibc app like sh

@gstark
gstark / gist:2554213
Created April 30, 2012 00:03
rails tests postgres

I'm trying to run the rails test suite but I keep getting this error:

$ bundle exec rake postgresql:build_databases
createdb: database creation failed: ERROR:  encoding UTF8 does not match locale en_US
DETAIL:  The chosen LC_CTYPE setting requires encoding LATIN1.
createdb: database creation failed: ERROR:  encoding UTF8 does not match locale en_US
DETAIL:  The chosen LC_CTYPE setting requires encoding LATIN1.
@gstark
gstark / workflow.md
Created January 26, 2010 20:42 — forked from zaach/workflow.md

Semantic Versioning

Details: http://semver.org/, http://apr.apache.org/versioning.html

Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API. MINOR versions retain source and binary compatibility with older minor versions, and changes in the PATCH level are perfectly compatible, forwards and backwards.

Patch level changes could also be for correcting incorrect APIs. In this case, the previous patch release may be incompatible, but because of bugs.

Minor versions may introduce new features, but do not alter any of the previous API.

@gstark
gstark / .irbrc
Created May 29, 2019 14:22
irbrc for suncoast handbook
require 'irb/completion'
require 'irb/ext/save-history'
# Require awesome_print in our environment
begin
require 'awesome_print'
rescue LoadError
end
# Keep an IRB history
def sum_groups(arr)
loop do
chunks = arr.chunk(&:even?).map(&:last)
return arr.length if chunks.all? { |list| list.size == 1 }
arr = chunks.map(&:sum)
end
end
@gstark
gstark / 01 Intro to Rails Crash Course.md
Last active March 29, 2018 14:24
Intro to Rails Crash Course

Weclome to the Iron Yard Intro to Rails Crash Course

First step is to install the correct version of the Ruby environment:

rvm install ruby-2.4.2
@gstark
gstark / bc_howto.txt
Created March 14, 2012 22:43
beyond compare howto
I've owned and used Beyond Compare for a long time and its my go-to tool whenever doing Windows work. I miss it so much I recently went to see if it would run under wine installed via Homebrew. Surprisingly it works quite well. I still won't let up on my yearly emails to Beyond Compare support to encourage a native verison.
brew install wine --use-gcc
<download the beyond compare installer exe>
wine ~/path/to/installer.exe
<install>
wine ~/.wine/drive_c/Program\ Files/Beyond\ Compare\ 3/BCompare.exe
Its a darn good diff tool with great directory compare support, lots of config options. Surprisingly on my Mac via WINE its pretty damn speedy (once X11 is already loaded...)
@gstark
gstark / snake_case.rb
Created April 7, 2016 18:23
ACR 2016 snake case code challenge
# Take the smallest case possible, a one wide grid
#
# .
#
# The number of ways of navigating this is 1 (do nothing)
#
# 1
#
# Extending this to a 2x2 grid still has the 0 case
#
class String
def py_slice(start, step = 1)
start.step(step < 0 ? 0 : self.length, step).map { |index| self[index] }
end
end
input = ARGF.readlines
for i in Range.new(0,input.size).step(4)
northLasers, conveyorBelt, southLasers = input[i,3]