Skip to content

Instantly share code, notes, and snippets.

View andys's full-sized avatar

Andrew Snow andys

View GitHub Profile
@andys
andys / dmesg.txt
Created April 30, 2016 02:39
X1 Carbon Gen 4 Ubuntu 16.04
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.4.0-21-generic (buildd@lgw01-21) (gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2) ) #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 (Ubuntu 4.4.0-21.37-generic 4.4.6)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-21-generic.efi.signed root=UUID=f71e08f7-6fc7-4189-a61c-15b413934388 ro
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
@andys
andys / keybase.md
Created November 18, 2014 03:34
keybase.md

Keybase proof

I hereby claim:

  • I am andys on github.
  • I am andy_snow (https://keybase.io/andy_snow) on keybase.
  • I have a public key whose fingerprint is A57D BDF8 5F6F AD3E A4E7 C310 D56D D97F 4C98 0A03

To claim this, I am signing this object:

@andys
andys / backupdaily.sh
Created May 20, 2014 04:21
ZFS snapshot backup
#!/usr/bin/bash
for fs in dir1 dir2 dir3 ; do
srcfs="tank/$fs"
dstfs="backup/$fs"
oldsnap=`zfs list -H -r -t snapshot $dstfs |cut -f1 | grep '0000$' | sort | tail -1 | sed -e 's/.*@//'`
newsnap=`zfs list -H -r -t snapshot $srcfs |cut -f1 | grep '0000$' | sort | tail -1 | sed -e 's/.*@//'`
if [ x$newsnap != x ] ; then
if [ x$oldsnap != x ] ; then
echo "$fs: from fat/san/$fs@$oldsnap to $newsnap if needed..."
[mysqld]
innodb_flush_method=nosync
default-storage-engine = innodb
innodb_flush_log_at_trx_commit = 0
innodb_doublewrite = 0
@andys
andys / gist:5217920
Last active December 15, 2015 06:39
example of filtering scope in controller
class PlayersController < ActiveController::Base
before_filter :player_scope, except: :create
def index
respond_with(@players = @scope.all)
end
def show
respond_with(@player = @scope.find(params[:id])
end
class Parent
def add(x,y)
x + y
end
end
class Child < Parent
def add
super
end
end
@andys
andys / gist:1686172
Created January 27, 2012 00:42
Yo I heard you liked parents in your parents
# rails generate model region name:string parent_id:integer
class Region < ActiveRecord::Base
belongs_to :parent, :class_name => self.to_s
def parent_name
parent.name
end
@andys
andys / gist:1057780
Created July 1, 2011 02:50
Disabling Garbage Collection around every rails request
class ApplicationController < ActionController::Base
around_filter :disable_garbage_collection
def disable_garbage_collection
unless @use_garbage_collection
GC.disable
begin
yield
ensure
vars = Variables()
vars.Add(BoolVariable('DEBUG', 'Set to disable optimizations', 1))
vars.Add(BoolVariable('PIC', 'Set to 1 for to always generate PIC code', 0))
env = Environment(variables = vars)
debug = env['DEBUG']
@andys
andys / gist:758283
Created December 29, 2010 06:55
javascript scroll to an element if it isn't visible
function scroll_to_if_not_visible(finder) {
var postop = $(finder).offset().top, win = $(window);
var posbottom = postop + $(finder).height();
if (posbottom > (win.height() + win.scrollTop())) {
$(finder).get(0).scrollIntoView(false);
}
else if (postop < win.scrollTop()) {
$(finder).get(0).scrollIntoView(true);
}