Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / nconf-yaml.js
Created August 20, 2014 11:19
Load YAML config files using nconf (nodejs)
var nconf = require('nconf');
var yaml = require('js-yaml');
var app_config = __dirname + '../config/application.yml';
// load cmd line args and environment vars
nconf.argv().env();
// load a yaml file using a custom formatter
nconf.file({
@clarkdave
clarkdave / currencies.json
Last active February 5, 2016 19:17
Currencies parsed from the RubyMoney library - https://github.com/RubyMoney/money - this ONLY includes currencies which have a subunit of 100 (e.g. 100 cents == 1 dollar)
{
"usd": {
"code": "USD",
"symbol": "$",
"name": "United States Dollar",
"symbol_first": true
},
"eur": {
"code": "EUR",
"symbol": "€",
@clarkdave
clarkdave / logstash-sentry.rb
Last active May 15, 2023 11:34
(Logstash) Sentry output plugin
# The MIT License (MIT)
# Copyright (c) 2014 Dave Clark
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@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 / ansible-prestashop.yml
Created April 25, 2014 10:17
(Ansible) Playbook to provision a Ubuntu VM for Prestashop, designed for vagrant
# this will provision a Ubuntu box with a basic lamp stack including a db/user for Prestashop
# it downloads Prestashop 1.5 into /tmp but doesn't install it, although you could quite easily
# extend this playbook to do that as you can run the prestashop installer via the shell
---
- hosts: all
sudo: True
tasks:
- name: apt-get update
command: apt-get update
@clarkdave
clarkdave / pgsql-query-json-array.sql
Created March 26, 2014 16:05
(PostgreSQL) Query something in a JSON array in a WHERE clause
-- when you have a record which looks like this
--
-- id: 5,
-- properties: {
-- ages: [20, 30]
-- }
--
-- it is a bit of a pain if you need to query based on the contents of the "ages" array inside the JSON object "properties"
-- because PG currently lacks easy to use operators to work with JSON arrays
@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