Skip to content

Instantly share code, notes, and snippets.

View oddlyzen's full-sized avatar
:electron:
Working with Electron

Mark Coates oddlyzen

:electron:
Working with Electron
View GitHub Profile
alias gc='git commit -am'
alias lsd='ls -la'
alias coed='cd ~/code/collegeonly && mate .'
alias cost='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start && rake sunspot:solr:start && rake sunspot:solr:start RAILS_ENV=cucumber &&
rake redis:development:start && rake redis:test:start && script/server -p2323'
alias gco='git co'
alias ss="script/server"
alias sc="script/console"
alias cdco="cd ~/code/collegeonly"
alias cdan="cd ~/code/achievenext"
@oddlyzen
oddlyzen / render.rb
Created November 17, 2010 19:41
Neat-oh. (on Rails)
module Render
def csv(filename = nil)
filename ||= params[:action]
filename += '.csv'
if request.env['HTTP_USER_AGENT'] =~ /msie/i
headers['Pragma'] = 'public'
headers["Content-type"] = "text/plain"
headers['Cache-Control'] = 'no-cache, must-revalidate, post-check=0, pre-check=0'
headers['Content-Disposition'] = "attachment; filename=\"#{filename}\""

Note to Self

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy

#!/bin/sh
# Some fixes are from http://blog.segment7.net/articles/2006/03/02/fast-memcached-on-os-x
#
# AFTER RUNNING THIS SCRIPT:
#
# Set the environment variable EVENT_NOKQUEUE to 1
# * csh and derivatives: setenv EVENT_NOKQUEUE 1
# * sh and derivatives (like bash): export EVENT_NOKQUEUE=1
#
<script>
// test for localStorage support
if(('localStorage' in window) && window['localStorage'] !== null){
var f = document.getElementById('mainform');
// test with Ruby if the form was sent (the submit button has the name "sent")
<% if params[:sent] %>
// get the HTML of the form and cache it in the property "state"
localStorage.setItem('state',f.innerHTML);
// if the form hasn't been sent...
<% else %>
div.header {
padding: 0;
height: 100px;
}
div.header a.logo {
display: block;
width: 237px;
height: 43px;
background: url(img/logo.png) no-repeat;
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
class HoboType::Cents < DelegateClass(Fixnum)
COLUMN_TYPE = :integer
HoboFields.register_type(:cents, self)
def initialize(value)
super(centsify value)
end
Xzibit = Object clone do(
dawg = method(what,
"yo dawg" print.
what print.
"clone" print.
self
).
so_you_can = method(
"so you can print" print.
// (Excerpt from http://tinyurl.com/c4e47q)
// At this point, I'd like to take a moment to speak to you about the Adobe PSD format.
// PSD is not a good format. PSD is not even a bad format. Calling it such would be an
// insult to other bad formats, such as PCX or JPEG. No, PSD is an abysmal format. Having
// worked on this code for several weeks now, my hate for PSD has grown to a raging fire
// that burns with the fierce passion of a million suns.
// If there are two different ways of doing something, PSD will do both, in different
// places. It will then make up three more ways no sane human would think of, and do those
// too. PSD makes inconsistency an art form. Why, for instance, did it suddenly decide
// that *these* particular chunks should be aligned to four bytes, and that this alignement