Skip to content

Instantly share code, notes, and snippets.

View Gowiem's full-sized avatar
🌤️
Stoked on Terraforming

Matt Gowie Gowiem

🌤️
Stoked on Terraforming
View GitHub Profile
@Gowiem
Gowiem / haproxy_acls.conf
Created February 24, 2016 21:53
ACLs in Haproxy
# path_sub, path_beg, path_end are the ones I'll likely want to use again.
# ACL Docs: https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#7.1
acl sync_req path_sub config_settings
redirect prefix https://artisantools.com if sync_req
@Gowiem
Gowiem / delete_keys.sh
Last active February 15, 2016 20:27
Clean up Redis by deleting keys
# Pull all keys matching wildcard from your Replica so you're not using KEYS on your primary.
$ redis-cli -h $ELASTI_CACHE_REPLICA_URL KEYS "*WILDCARD*" > keys.txt
# For each key that has been collected, prepend the DEL command.
$ sed ':a;N;$!ba;s/\n/\n DEL /g' keys.txt > del_keys.txt
# Feed the new DEL commands into your primary. Run via nohup + background as deleting millions of keys can take hours.
$ nohup redis-cli -h $ELASTI_CACHE_URL < del_keys.txt &
@Gowiem
Gowiem / ember_run_issue.js
Created November 28, 2013 02:15
Ember Runloop and AJAX Callbacks Issue
// Testing Helper which I use to log a user in.
// This blows up before 'student logged in' is logged
var loginStudent = function(username, password) {
visit('/').click('.studentsLogin .btn span')
.fillIn('#email-field', username)
.fillIn('#password-field', password)
.click('#login-button').then(function() {
console.log("Student logged in");
});
}
@Gowiem
Gowiem / project.json
Last active December 26, 2015 01:39
Ember.js Projects JSON
{
teachers:[
{
id:"6504b6d64d61743f7c000000",
type:"Teacher"
}
],
students:[
{
id:"2905b6d64d61743f7c030000",
@Gowiem
Gowiem / cors_closure.js
Last active December 24, 2015 10:59
Why does jQuery#getJSON work outside of this closure?
// It seems my request is fine when its not wrapped in a closure,
// but blows up with CORS errors when inside...
// The following works fine with no issues
var videoUrl = "http://vimeo.com/api/v2/video/75738368.json?callback=?"
$.getJSON(videoUrl, function (data) {
console.log("Data: ", data)
});
Hist.VideoHandler = function() {
// The following method only returns the public static variables of the View class
// when called like so:
// Class klass = android.view.View.class;
// parser.getAllFieldsForClass(klass);
public Field[] getAllFieldsForClass(Class klass) {
Field[] fields = klass.getDeclaredFields();
if (fields.length == 0) {
return new Field[0];
} else {
@Gowiem
Gowiem / hacker-news.js
Created July 3, 2013 01:01
Hacker News Voting JavaScript
function byId(id) {
return document.getElementById(id);
}
function vote(node) {
var v = node.id.split(/_/); // {'up', '123'}
var item = v[1];
// hide arrows
byId('up_' + item).style.visibility = 'hidden';
@Gowiem
Gowiem / WebsocketMonitor
Created March 21, 2013 16:31
Initializing WebSocket Manager
def initialize
puts "--Initializing Message Monitor"
EM.run {
puts "before Faye::Websocket::Client.new()"
ws = Faye::WebSocket::Client.new("wss://somewebsocket.com:/ms/monitor")
puts "After Faye::Websocket::Client.new()"
ws.onopen do |event|
puts "WebSocket Opened!"
ws.send('Hello, world!')
@Gowiem
Gowiem / ember-csrf.js
Created October 24, 2015 00:59
Use CSRF Token in each Ember AJAX Request
// If using rails: Place the csrf_meta_tag helper in primary layout in the head tag:
// = csrf_meta_tag
// Initializer
// Include the CSRF Token in each ajax Request.
Ember.$.ajaxSetup({
headers: {
'X-CSRF-Token': Ember.$('meta[name="csrf-token"]').attr('content')
}
});
@Gowiem
Gowiem / vid-utility.rb
Created December 4, 2012 02:53
Ruby script to rename video files
#!/usr/bin/env ruby
# vid-utility
shows_folder = "/media/Gowie-Internal/Shared/TV-Shows/"
show_titles = %x(ls #{shows_folder}).split(/\r?\n/)
files = %x(ls)
files.each_line do |filename|