Skip to content

Instantly share code, notes, and snippets.

View shiftb's full-sized avatar

Brandon Leonardo shiftb

View GitHub Profile
@shiftb
shiftb / pushState.cljs
Last active March 6, 2017 19:23 — forked from danielsz/pushState.cljs
Example using pushState with ClojureScript + Secretary
; require [goog.events :as events]
; import [goog.history Html5History]
; [goog Uri]
; [goog.history EventType]
(defn listen [el type]
(let [out (chan)]
(events/listen el type
(fn [e] (put! out e)))
out))
@shiftb
shiftb / secure.sh
Created March 27, 2012 17:07
Securing Wordpress file permissions
find /path/to/wordpress/ -type d -exec chmod 755 {} \;
find /path/to/wordpress/ -type f -exec chmod 644 {} \;
echo "ServerName [name]" | tee /etc/apache2/conf.d/fqdn
service apache2 restart
hostname -f
# Potentially: vi /etc/hostname
# Setup IPTABLES
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
@shiftb
shiftb / toSentence.js
Created August 15, 2011 19:47
Rails to_sentence implemented in JavaScrip
/* Given an array of strings it returns a sentence. */
function toSentence(arr) {
arr = arr.slice(0);
switch (arr.length) {
case 0:
return "";
case 1:
return arr.pop();
default:
var lastItem = arr.pop();
@shiftb
shiftb / toSentence.js
Created August 15, 2011 19:47
Rails to_sentence implemented in JavaScrip
function toSentence(arr) {
arr = arr.slice(0);
switch (arr.length) {
case 0:
return "";
case 1:
return arr.pop().name;
default:
var lastItem = arr.pop();
return _.pluck(arr, 'name').join(', ') + " and " + lastItem.name;
@shiftb
shiftb / logger.js
Created April 4, 2011 17:21
A simple javascript logger
/*!
* Javascript Logger
* https://gist.github.com/gists/902014
*
* Copyright 2011, Brandon Leonardo
*/
var Logger = function(options) {
var opts = options || {};
this.debugMode = opts['debugMode'] || false;
@shiftb
shiftb / app.rb
Created March 20, 2011 23:52 — forked from trydionel/app.rb
A fast sinatra redis data viewer
require 'rubygems'
require 'haml'
require 'sinatra'
require 'redis'
helpers do
def redis
@redis ||= Redis.new
end
end
@shiftb
shiftb / example_usage.rb
Created February 27, 2011 10:23
This is a helper class that will take a signed request from Facebook's registration system and parse into a json hash.
registration_request = FacebookRegistration::SignedRequest.new(params[:signed_request])
registration_params = registration_request.parse_request
pp registration_params
@shiftb
shiftb / Convert MySQL DB To UTF8.sh
Created September 3, 2010 07:01
A script to convert a MySQL database to UTF-8
# Found this somewhere on the intertubes.
# Posting here for future use and posterity
mysqldump --user=username --password=password --default-character-set=latin1 --skip-set-charset dbname > dump.sql
sed -r 's/latin1/utf8/g' dump.sql > dump_utf.sql
mysql --user=username --password=password --execute="DROP DATABASE dbname; CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;"
mysql --user=username --password=password --default-character-set=utf8 dbname < dump_utf.sql
@shiftb
shiftb / gist:366067
Created April 14, 2010 17:12 — forked from reinh/hack.sh
#!/bin/sh -x
# git name-rev is fail
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
git checkout master
git pull origin master
git checkout ${CURRENT}
git rebase master