Skip to content

Instantly share code, notes, and snippets.

View nathany's full-sized avatar
🙃

Nathan Youngman nathany

🙃
View GitHub Profile
@nathany
nathany / i18n-default-interpoliations.rb
Created April 23, 2010 16:38
allow default options for Rails i18n
# override I18n.translate to support default_options
module I18n
mattr_accessor :default_options
self.default_options = {}
class << self
def translate_with_default_options(key, options = {})
translate_without_default_options(key, default_options.merge(options))
end
filesMatching(folder) { (file, dir) => // looks alot like a Ruby block
println(file + ": " + dir) // multiple statements
file.endsWith(query) && dir == false
}
///////////////////////////////////////////////////////////////////////////////
//
// jquery.protect.js
// Copyright (c) 2010 Yardstick Software
//
// This plugin allows you protect a page from selection/copying the text.
//
// Doesn't do anything about Print Scrn, Save As...
//
///////////////////////////////////////////////////////////////////////////////
# sudo gem install octopi
require "octopi"
include Octopi
y = User.find("yegrb")
y.public_repo_count
y.followers_count
y.gravatar_id
y.name, y.company, y.location, y.login, y.email
@nathany
nathany / search_procs.sql
Created May 31, 2010 19:31
SQL Server search through stored procedure and trigger code
USE MyDatabase
GO
SELECT mprod.object_id, oprod.name
FROM sys.sql_modules mprod
LEFT JOIN sys.objects oprod ON mprod.object_id = oprod.object_id
WHERE mprod.definition LIKE '%SearchString%'
* mixins (include and extend) for simple modularization (vs. multiple inheritance or traits in other languages)
* innovations in the web space (haml, rack middleware, etc.)
* standardized around MIT and GIT
* no public properties (attr_accessor, etc.)
* open classes
* tooling (gem, rake)
* animal references (ducks, monkeys, bacon)
* metaprogramming (unicorns)
* TDD/BDD emphasis and tools
gem: --no-ri --no-rdoc
#!/bin/sh
# Copies all data from the production database and populates the staging
# database with the dumped data.
echo "Dumping production data..."
mysqldump --add-drop-table --add-locks -e -l ys_production > /tmp/db_prod2stage.sql
echo "Populating staging data..."
mysql -e "use ys_staging; source /tmp/db_prod2stage.sql;"
require 'rake'
begin
require 'vlad'
Vlad.load :scm => :git, :app => nil # use git, don't use mongrel
rescue LoadError
# do nothing (vlad/vlad-git not requird on server,
# unfortunately this hides the error if vlad-git isn't installed locally)
end
# list authors (by # of commits?)
git shortlog -s -n