Skip to content

Instantly share code, notes, and snippets.

View nchapman's full-sized avatar

Nick Chapman nchapman

View GitHub Profile
require 'redis/list'
require 'redis/value'
class RedisModel
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :id
class ActiveOhm < Ohm::Model
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
include Ohm::Boundaries
include Ohm::Callbacks
include Ohm::Timestamping
include Ohm::Typecast
growMessageBody: function() {
var messageBody = $("message_body");
var rows = messageBody.value.split('\n').length;
if (rows <= 1)
rows = 2;
if (rows >= 10)
rows = 10;
local http = require "socket.http"
local function url_encode(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
@nchapman
nchapman / expand.rb
Created May 12, 2011 20:17
Convert tabs to spaces
# ruby expand.rb /path/to/files
Dir["#{ARGV[0]}/**/*"].each do |file|
if file =~ /\.(rb|scss|css|erb|sql|conf|html|js)$/
`expand -t 2 #{file} > #{file}.tmp`
`mv #{file}.tmp #{file}`
end
end
@nchapman
nchapman / gist:1420115
Created December 1, 2011 21:44
Overflowing tables
<!DOCTYPE html>
<html>
<head>
<style>
table {
border: 1px solid #555;
table-layout: fixed;
width: 100%;
}
@nchapman
nchapman / gist:1862601
Created February 19, 2012 08:24 — forked from mudge/gist:1076046
CoffeeScript version of ActiveSupport's to_sentence method.
toSentence = (array = [], wordsConnector = ", ", twoWordsConnector = " and ", lastWordConnector = ", and ") ->
switch array.length
when 0 then ""
when 1 then array[0]
when 2 then array[0] + twoWordsConnector + array[1]
else array.slice(0, -1).join(wordsConnector) + lastWordConnector + array[array.length - 1]
class OrganizationsController < ApplicationController
def index
@organizations = Organization.all
respond_with(@organizations)
end
def show
@organization = Organization.find(params[:id])
@nchapman
nchapman / setup.sh
Last active October 1, 2024 19:17
Ubuntu setup
# wget -O - https://raw.github.com/gist/4211882/<REVISION>/setup.sh | bash
# Get updates
apt-get -y update
apt-get -y upgrade
# Install build tools
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev curl git-core mysql-client libmysqlclient-dev libxslt-dev libxml2-dev python-software-properties
# Install Ruby

Dead-End Jobs: Are You Suffering From Stockholm Syndrome?

By Chad Fowler
Published: December 30, 2010

Have you heard of Stockholm Syndrome? It’s a name given to the condition wherein hostages develop positive feelings toward their captors despite being held in negative, unfavorable and even life-threatening conditions. Victims of Stockholm Syndrome will even inexplicably stay with their captors even when given the chance at freedom.

Hopefully nobody reading this is literally being held hostage right now. If you are, good luck!

For the rest of you, why might I suggest that you are suffering from Stockholm Syndrome? Because employment relationships can manifest themselves in this very way.