Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Hoffman nickhoffman

  • Toronto, Canada
View GitHub Profile
View gist:579623b5d1f98a621cd8
Chart
http://www.cpubenchmark.net/high_end_cpus.html
http://products.amd.com/en-us/DesktopCPUResult.aspx
http://ark.intel.com/
http://ark.intel.com/compare/80814,80809,80808,80806,80807
http://processors.findthebest.com/d/n/AMD
@nickhoffman
nickhoffman / setup-statsd.sh
Created Apr 19, 2011 — forked from collegeman/setup-statsd.sh
Turn an Ubuntu 10.04 linode into a StatsD/Graphite server
View setup-statsd.sh
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
@nickhoffman
nickhoffman / DB stuff
Created Jun 8, 2011
pcalendar joins stuff
View DB stuff
rails g scaffold user name:string
rails g scaffold prediction title:string
rails g scaffold position believes_it:boolean
rails g migration position_belongs_to_user
#class PositionBelongsToUser < ActiveRecord::Migration
# def self.up
# add_column :positions, :user_id, :integer
# end
#
@nickhoffman
nickhoffman / changed_specs.rb
Created Aug 27, 2011
A rake task for running all of the spec files that've been modified.
View changed_specs.rb
RSpec::Core::RakeTask.new('spec:changed') do |t|
changed_files = `git status -s | grep '^ M spec/' | grep '_spec.rb$'`.split "\n"
changed_files.each {|file| file.sub! /\A M /, '' }
puts
puts "Found #{changed_files.count} changed spec file(s):"
changed_files.each {|file| puts " #{file}"}
puts
@nickhoffman
nickhoffman / spreadsheet_importer.rb
Created Aug 29, 2011
Why does this error occur in the spec?: undefined method `each_pair'
View spreadsheet_importer.rb
$ bundle exec rspec --fail-fast -b spec/models/spreadsheet_importer_spec.rb
No examples were matched by {:focus=>true}, running all
F
Failures:
1) SpreadsheetImporter instance variables has a reader for @catalog
Failure/Error: @importer = SpreadsheetImporter.new @catalog, @excel, @photos_dir
NoMethodError:
undefined method `each_pair' for #<Catalog:0xb0475bc>
View app-controllers-sessions_controller.rb
class SessionsController < Devise::SessionsController
def create
if request.xhr?
resource = warden.authenticate! :scope => resource_name
if resource.nil?
render :json => {
:status => 'fail',
:data => {
:cause => 'invalid',
View app-cells-product_have_cell.rb
class ProductHaveCell < Cell::Rails
def description(have)
condition = have.condition
desc = "#{have.quantity}x #{condition.name}"
if have.sealed
desc += ' ' + I18n.t('words.Sealed').downcase
elsif have.packaging
desc += ' ' + I18n.t('phrases.product_haves.with_packaging')
end
View gist:1282105
###################
# CREATE THE INDEX:
###################
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"settings" : {
"analysis" : {
"filter" : {
"edge_ngram" : {
"side" : "front",
@nickhoffman
nickhoffman / gist:1283380
Created Oct 13, 2011
Why does a search for a misspelling ("optius" instead of "optimus") find no documents?
View gist:1283380
echo 'Delete the index.'
curl -X DELETE 'http://localhost:9200/test_products/?pretty=true'
echo; echo
echo 'Create the index. Copied directly from https://gist.github.com/961303 .'
curl -X PUT 'http://localhost:9200/test_products/?pretty=true' -d '
{
"settings" : {
"analysis" : {
View gist:1284790
// curl -X GET 'localhost:9200/development_products/_search?pretty=true' -d '
{
explain: true,
query: {
dis_max: {
queries: [
{ field: { "name": "grmlock" } },
{ field: { "catalog.name": "grmlock" } },
{ field: { "items.name": "grmlock" } },
{ field: { "properties.character": "grmlock" } },