Skip to content

Instantly share code, notes, and snippets.

@DVG
DVG / unciorn.rb
Last active August 29, 2015 14:17
Unicorn configuraiton
# set path to app that will be used to configure unicorn,
# note the trailing slash in this example
@dir = "/path/to/app/"
worker_processes 2
working_directory @dir
timeout 30
# Specify path to socket unicorn listens to,
@DVG
DVG / env
Created February 26, 2015 14:37
Environment Variables
COLORTERM=gnome-terminal
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-6qbTLpVXel,guid=65fcd2c788d00cd94308487600000093
DEFAULTS_PATH=/usr/share/gconf/gnome-fallback.default.path
DEFAULT_USER=me
DESKTOP_SESSION=gnome-fallback
DISPLAY=:0.0
EDITOR=vim
FTP_PROXY=http://ftp://proxy.mycompany.net:8000/
GDMSESSION=gnome-fallback
GDM_LANG=en_US
@DVG
DVG / Rakefile
Created September 29, 2014 19:33
Update background Image to National Geographic Photo of the day
TODAY = Time.now.strftime("%Y-%m-%d")
USER = "MY_USER"
PICTURES_DIR = "/home/#{USER}/Pictures/national-geographic/"
TODAYS_PICTURE = "#{PICTURES_DIR}#{TODAY}-ngeo.jpg"
PROXY_HOST = 'proxy.example.net'
PROXY_PORT = 8443
desc "Fetch National Geographic Photo of the Day"
task :get_photo_of_the_day do
# http://photography.nationalgeographic.com/photography/photo-of-the-day/
@DVG
DVG / ppa-behind-proxy.bash
Created April 3, 2014 14:38
ppa-behind-proxy.bash
# The ppa will have the sources listed on it's site: https://launchpad.net/~gwendal-lebihan-dev/+archive/cinnamon-stable
# edit /etc/apt/sources.list
deb http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu quantal main
deb-src http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu quantal main
# Add signing key
wget "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0xA777609328949509" -O out && sudo apt-key add out && rm out
@DVG
DVG / classy_delete_widget.coffee
Last active January 3, 2016 08:49
Delete Widget
class App.FancyDelete extends App.Object
constructor: (@_destroy_url, @_deleteSelector = '.js-delete', @_cancelSelector = '.js-cancel', @_deleteFilter = null, @_cancelFilter = null, @_container = "tr") ->
events = [new App.Event(@_deleteSelector, "click", @destroy, @_deleteFilter),
new App.Event(@_cancelSelector, "click", @cancel, @_cancelFilter)]
super(events)
destroy: (e) =>
e.preventDefault()
self = e.target
if self.find(".js-text").text() == "Delete"
@DVG
DVG / bradley_page_object.rb
Created December 13, 2013 16:32
Super simple page object pattern
require 'capybara'
require 'capybara/dsl'
include Capybara::DSL
Capybara.default_driver = :selenium
Capybara.run_server = false
# Keep selenium happy behind the proxy
ENV['no_proxy'] = "127.0.0.1"
ENV['NO_PROXY'] = "127.0.0.1"

Christmas List

Video Games

  • 3DS XL Charging Cradle - available here
  • PS Vita 32 Gb Memory Card
  • LEGO Marvel Super Heroes Xbox 360

Blu Rays

  • Wreck It Ralph
  • Game of Thrones Season 1 and 2
  • Dark Knight Rises

It's important to make sure your server-side app is secure when using a client-side application like Ember, since any user can alter your javascript at runtime to make it do whatever you want. Therefore you want to make sure you still use server-side validations to make sure that your persistant records are valid.

However, Ember doesn't include any built-in way of displaying these errors on a form like you might be used to coming from a Rails world. This is how I do it.

Let's take this login form as an example (using twitter bootstrap css):

<form class="form-horizontal" {{action sendRegistration on="submit"}}>
  <div class="control-group">
    <label class="control-label" for="email">Email</label>
StripfighterEmber.ApplicationController = Ember.Controller.extend
signOut: ->
StripfighterEmber.Auth.signOut()
StripfighterEmber.Auth.destroySession()
@DVG
DVG / my_active_record_class.rb
Last active December 17, 2015 09:19
Conditional alias attribute for changing a column name if the migrations haven't been run yet. Useful if your code deploy can possibly happen before you rmigration
unless self.column_names.include? "new_name"
alias_attribute :new_name, :old_name
end