Skip to content

Instantly share code, notes, and snippets.

View ahawthorne's full-sized avatar

Andrew Hawthorne ahawthorne

View GitHub Profile
@ahawthorne
ahawthorne / .bashrc
Created May 18, 2012 20:10
msysgit ssh-agent
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null
@ahawthorne
ahawthorne / gist:3940260
Created October 23, 2012 17:37
search and replace, recalculate string-length in serialized array
<?php
$in = file_get_contents('input.sql');
// change domain(s)
$in = preg_replace('/old.example.com/', 'new.example.com', $in);
$in = preg_replace('/older.example.com/', 'newer.example.com', $in);
// recalculate string lengths in serialized arrays
$out = preg_replace('/s:(\d+):\\\"(.*?)\\\";/e', "'s:'.strlen('$2').':\"$2\";'", $in);
@ahawthorne
ahawthorne / detect_ie.js
Last active December 17, 2015 20:19
JavaScript to detect IE version using conditional tags and add classes to the html tag.
window.ie = (function() {
var undef,
v = 3,
htmlClass = document.documentElement.className,
div = document.createElement('div'),
all = div.getElementsByTagName('span');
do {
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><span></span><!endif]-->';
} while (all[0]);
@ahawthorne
ahawthorne / en.yml
Last active December 18, 2015 21:59
Rails i18n format - eg. "Fri, 10/26/2012"
en:
hello: "Hello world"
time:
formats:
date_only1: "%a, %m/%d/%Y"
date:
formats:
date_only1: "%a, %m/%d/%Y"
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName site.lvh.me
ServerAlias www.site.lvh.me
DocumentRoot /var/www/site
<Directory /var/www/site>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
@ahawthorne
ahawthorne / 10-touchpad.conf
Created October 7, 2013 16:14
Default touchpad configuration in Fedora (and Linux in gerneral) is pretty frustrating. This configuration should provide palm detection, scroll coasting, tap-to-click (without jumpiness), two-finger scrolling, and three-finger middle click Place this file in /etc/X11/xord.conf.d/. Set owner and group to root, permissions to 644.
Section "InputClass"
Identifier "Touchpad"
Driver "synaptics"
MatchIsTouchpad "on"
Option "PalmDetect" "1"
Option "PalmMinWidth" "1"
Option "PalmMinZ" "1"
Option "VertScrollDelta" "40"
Option "HorizScrollDelta" "40"
Option "CoastingSpeed" "1"
@ahawthorne
ahawthorne / gist:7201871
Created October 28, 2013 18:20
quick touchpad fix
synclient PalmDetect=1 PalmMinWidth=1 PalmMinZ=1 VertScrollDelta=40 HorizScrollDelta=40 CoastingSpeed=1 CoastingFriction=60 TapButton1=1 TapButton2=3 TapButton3=2 VertTwoFingerScroll=1 HorizTwoFingerScroll=1 FingerHigh=45 FingerLow=40 EmulateMidButtonTime=180
/* ghosttest.c: GHOST vulnerability tester */
/* Credit: http://www.openwall.com/lists/oss-security/2015/01/27/9 */
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
<?xml version="1.0" encoding="utf-8"?>
<Client name="Chromecast">
<!-- Author: Plex Inc. -->
<TranscodeTargets>
<VideoProfile protocol="http" container="matroska" codec="h264" audioCodec="aac" subtitleCodec="ass" context="streaming">
<Setting name="VideoEncodeFlags" value="-x264opts bframes=3:cabac=1" />
</VideoProfile>
<MusicProfile container="matroska" codec="mp3" />
<PhotoProfile container="jpeg" />
</TranscodeTargets>
@ahawthorne
ahawthorne / .rubocop.yml
Created March 23, 2015 15:06
Rubocop config
Style/Documentation:
Enabled: false
Style/WordArray:
MinSize: 4
Metrics/LineLength:
Max: 120
Metrics/AbcSize: