Skip to content

Instantly share code, notes, and snippets.

View meesterdude's full-sized avatar
🎯
Building something cool

Russell meesterdude

🎯
Building something cool
View GitHub Profile
#!/usr/bin/env macruby
framework 'Cocoa'
# Cocoa documentation reference:
# http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSSound_Class/Reference/Reference.html
def play_sound
if @sound.empty?
NSApplication.sharedApplication.terminate(nil)
else
sound_file = @sound
@meesterdude
meesterdude / product.rb
Created April 19, 2012 22:54
trying to get @product_results to not contain products who are already in a given @category
class Product < ActiveRecord::Base
has_and_belongs_to_many :product_groups
...
scope :in_categories, lambda {|ids| where(:category_id => ids) }
scope :visible, where(:visible => true)
scope :search, lambda {|kw| where(
@meesterdude
meesterdude / whattolearn.markdown
Created May 15, 2012 19:45
Stay curious, learn anything.

There's been some buzz around jeff atwoods Please Don't Learn to Code and i'd like to chip in my two cents:

fuck anyone who tells you that you should not learn something.

I once worked for a guy who always said "I'm not a programmer" and his code showed it. Does that mean he was performing at his peak? no. He was just boxing himself in. It was an excuse to be sloppy. Anyone can be sloppy. A key difference between him and I, was giving a damn.

Don't put yourself in a box, and say "I'm not a programmer" or "I'm just a receptionist" or what have you. You can be more than one thing, with varying levels of skill set. And you can get better. You may be REALLY great at one, and suck at another. Or be generally mediocre. But you can usually get better; it'll be a good while before you've ACTUALLY hit your "limit". And rarely is your limit not good enough, sans competitive sports or what have you, where the best's best outbests the second

class StoreController < ApplicationController
before_filter :check_store_status, :except => :store_closed
before_filter :find_cart, :except => :store_closed
before_filter :confirm_cart_not_empty, :only => [:display_cart, :checkout, :confirm_order, :save_order]
layout 'store'
def checkout
unless @cart.all_items_purchasable?
@meesterdude
meesterdude / image_finder.rb
Created October 1, 2012 05:07
Automatically fixes missing images by downloading from live site, if present.
# check pages for missing images. if present on live site, pull down to same path.
# in app controller
def correct_missing_file
return unless Rails.env == 'development'
tpath = params[:file].split('?').first
fpath = tpath.split('/')
fpath.pop
fpath = fpath.join('/')
uri = URI('http://www.creativebug.com' + tpath)
@meesterdude
meesterdude / simpler-rails.sublime-project
Created December 19, 2012 19:19
Sublime Text 2 Project file for day to day Ruby on Rails work.
{
"folders":
[
{
"path": "/",
"folder_exclude_patterns": [
"app/mailers",
"app/helpers",
"app/assets/images",
@meesterdude
meesterdude / gist:4380860
Created December 26, 2012 15:12
solr console output
[ruru64@ruru64s-iMac] ~/adev/creativebug(resend_gift)$ solr ~/adev/creativebug/solr/
2012-12-26 10:11:40.998:INFO:oejs.Server:jetty-8.1.2.v20120308
2012-12-26 10:11:41.013:INFO:oejdp.ScanningAppProvider:Deployment monitor /usr/local/Cellar/solr/4.0.0/libexec/example/contexts at interval 0
2012-12-26 10:11:41.017:INFO:oejd.DeploymentManager:Deployable added: /usr/local/Cellar/solr/4.0.0/libexec/example/contexts/solr.xml
2012-12-26 10:11:41.675:INFO:oejw.StandardDescriptorProcessor:NO JSP Support for /solr, did not find org.apache.jasper.servlet.JspServlet
2012-12-26 10:11:41.714:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/solr,file:/usr/local/Cellar/solr/4.0.0/libexec/example/solr-webapp/webapp/},/usr/local/Cellar/solr/4.0.0/libexec/example/webapps/solr.war
2012-12-26 10:11:41.714:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/solr,file:/usr/local/Cellar/solr/4.0.0/libexec/example/solr-webapp/webapp/},/usr/local/Cellar/solr/4.0.0/libexec/example/webapps/solr.war
Dec 26, 2012 10:11:41 AM
@meesterdude
meesterdude / _before.rb
Last active December 12, 2015 09:59
before and after comments. Note the changes in clarity and depth of understanding.
require "semantic"
require "pp"
corpus = Semantic::Corpus.new([], :transforms => [:LSA])
Dir.glob("/tmp/some_texts/*.txt").each do |file|
corpus << Semantic::Document.new(open(file), :name => File.basename(file))
end
corpus.build_index
@meesterdude
meesterdude / gist:4982567
Created February 19, 2013 02:21
bash_profile
PS1="[\u@\h] \w\$(git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/(\1)/')\$(git stash list 2> /dev/null | grep -e 'stash' | wc -l | sed 's/^ *//' | sed -n 's/\([1-9]\)/\{stashed:\1\}/p')\$ "
=> [ruru64@ruru64s-iMac] ~/adev/creativebug(master){stashed:1}$
or if no git..
=> [ruru64@ruru64s-iMac] ~/adev$
@meesterdude
meesterdude / gist:5063477
Created March 1, 2013 09:24
chef_client output
[2013-03-01T10:21:52+01:00] INFO: Storing updated cookbooks/openssl/metadata.json in the cache.
[2013-03-01T10:22:02+01:00] INFO: Storing updated cookbooks/openssl/metadata.rb in the cache.
[2013-03-01T10:22:12+01:00] INFO: Storing updated cookbooks/openssl/README.md in the cache.
[2013-03-01T10:22:22+01:00] INFO: Storing updated cookbooks/iptables/recipes/chef.rb in the cache.
[2013-03-01T10:22:32+01:00] INFO: Storing updated cookbooks/iptables/recipes/default.rb in the cache.
[2013-03-01T10:22:42+01:00] INFO: Storing updated cookbooks/iptables/recipes/statsd.rb in the cache.
================================================================================
Error Syncing Cookbooks: