Skip to content

Instantly share code, notes, and snippets.

@clarkdave
clarkdave / change-postgresql-data-dir.rb
Last active August 29, 2015 13:57
(CHEF) change PostgreSQL (9.2) data directory
# changing the postgresql data directory is an annoyingly non-trivial and fragile operation
# this should mostly do it but there are lots of things that can go wrong and if/when they do
# you will have lots of fun trying to eradicate broken postgres installs between chef runs
#
config_dir = "etc/postgresql/#{node[:postgresql][:version]}/main"
bash 'change_data_directory' do
code <<-CODE
mkdir /tmp/pg_conf_backup
@clarkdave
clarkdave / logstash.conf
Created May 10, 2014 08:16
Logstash / Sentry config
input {
redis {
'data_type' => "list"
'host' => "127.0.0.1"
'key' => "logstash"
'type' => "redis-input"
}
}
filter {
@clarkdave
clarkdave / js-center-popup.coffee
Created December 4, 2014 09:50
Create JS popup centered on screen (dual-screen friendly)
# from here: http://www.xtf.dk/2011/08/center-new-popup-window-even-on.html
w = 800
h = 600
dualScreenLeft = if window.screenLeft isnt undefined then window.screenLeft else screen.left
dualScreenTop = if window.screenTop isnt undefined then window.screenTop else screen.top
width = if window.innerWidth then window.innerWidth else (
if document.documentElement.clientWidth then document.documentElement.clientWidth else screen.width)
@clarkdave
clarkdave / gist:609fc3049dcf9c8aa559
Last active August 29, 2015 14:16
gevent ubuntu 12.04 setuptools issue

Error, on Ubuntu 12.04

$ sudo -H pip install gevent
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 232, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 339, in run
    requirement_set.prepare_files(finder)

File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 229, in prepare_files

@clarkdave
clarkdave / vows-phantom.js
Created November 24, 2011 10:43
Testing with Vows and PhantomJS
var phantom = require('phantom'),
vows = require('vows'),
assert = require('assert');
// nesting tests inside phantom callback so we only
// have to create it once
phantom.create(function(ph) {
var get_page_result = function(url, fn, result) {
ph.createPage(function(page) {
@clarkdave
clarkdave / index.html
Created February 7, 2012 11:38
ZombieJS ignoring jQuery $.delegate
<!doctype html>
<html>
<head>
<title>ZombieJS test</title>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
</head>
<body>
<a href='#' id='clicker1'>Clicker one</a>
<a href='#' id='clicker2'>Clicker two</a>
<a href='#' id='clicker3'>Clicker three</a>
@clarkdave
clarkdave / widget.js
Created October 28, 2012 03:14
widget stuff
function loadScript(url, fn) {
var script = document.createElement('script');
script.async = true;
script.src = '//' + url;
var entry = document.getElementsByTagName('script')[0];
entry.parentNode.insertBefore(script, entry);
script.onload = script.onreadystatechange = function() {
var rdyState = script.readyState;
@clarkdave
clarkdave / sublimetext3.json
Created November 10, 2015 15:49
sublime text 3 config
{
"auto_find_in_selection": true,
"base64fold_all_uris": false,
"bold_folder_labels": false,
"caret_style": "blink",
"color_scheme": "Packages/User/SublimeLinter/Blackboard (SL).tmTheme",
"enable_tab_scrolling": false,
"fade_fold_buttons": false,
"find_selected_text": true,
"font_face": "Source Code Pro Light",
@clarkdave
clarkdave / pygments.css
Created March 8, 2013 16:51
pygments styles for clarkdave.net
code { background: #f8f8f8; }
code .hll { background-color: #ffffcc }
code .c { color: #8f5902; font-style: italic } /* Comment */
code .err { color: #a40000; border: 1px solid #ef2929 } /* Error */
code .g { color: #000000 } /* Generic */
code .k { color: #204a87; font-weight: bold } /* Keyword */
code .l { color: #000000 } /* Literal */
code .n { color: #000000 } /* Name */
code .o { color: #ce5c00; font-weight: bold } /* Operator */
code .x { color: #000000 } /* Other */
@clarkdave
clarkdave / log-user-out-rails.coffee
Created May 12, 2013 12:56
Log user out in Rails via JS
$('.logout').on 'click', (e) ->
link = $(e.currentTarget)
csrf_token = $('meta[name="csrf-token"]').attr('content')
form = $('<form>')
form.hide()
form.attr('method', 'post').attr('action', link.attr('href'))
$("<input type='hidden' name='authenticity_token' value='#{csrf_token}'>").appendTo(form)