Skip to content

Instantly share code, notes, and snippets.

Andrew Snow andys

Block or report user

Report or block andys

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
@andys
andys / dmesg.txt
Created Apr 30, 2016
X1 Carbon Gen 4 Ubuntu 16.04
View dmesg.txt
[ 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
View 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
ZFS snapshot backup
View backupdaily.sh
#!/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..."
View mysql faster settings
[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 Dec 15, 2015
example of filtering scope in controller
View gist:5217920
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
View gist:3058918
class Parent
def add(x,y)
x + y
end
end
class Child < Parent
def add
super
end
end
@andys
andys / gist:1686172
Created Jan 27, 2012
Yo I heard you liked parents in your parents
View gist:1686172
# 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 Jul 1, 2011
Disabling Garbage Collection around every rails request
View gist:1057780
class ApplicationController < ActionController::Base
around_filter :disable_garbage_collection
def disable_garbage_collection
unless @use_garbage_collection
GC.disable
begin
yield
ensure
View gist:861329
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 Dec 29, 2010
javascript scroll to an element if it isn't visible
View gist:758283
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);
}
You can’t perform that action at this time.