Skip to content

Instantly share code, notes, and snippets.

View marti1125's full-sized avatar
๐Ÿ

Willy Aguirre marti1125

๐Ÿ
View GitHub Profile
~/writermortis(master) [email protected] TEST_USER_PASSWORD=123456 TEST_USER_NAME=marti1125 ANON_PASSWORD=123456 rake db:seedrake aborted!
can't dup NilClass
/home/willy/writermortis/db/seeds.rb:9:in `dup'
/home/willy/writermortis/db/seeds.rb:9:in `<top (required)>'
/home/willy/.rvm/gems/ruby-1.9.3-p392@global/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:245:in `load'
/home/willy/.rvm/gems/ruby-1.9.3-p392@global/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:245:in `block in load'
/home/willy/.rvm/gems/ruby-1.9.3-p392@global/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/willy/.rvm/gems/ruby-1.9.3-p392@global/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:245:in `load'
/home/willy/.rvm/gems/ruby-1.9.3-p392@global/gems/railties-3.2.7/lib/rails/engine.rb:520:in `load_seed'
/home/willy/.rvm/gems/ruby-1.9.3-p392@global/gems/activerecord-3.2.7/lib/active_record/railties/databases.rake:309:in `block (2 levels) i
@marti1125
marti1125 / gist:5389288
Created April 15, 2013 16:19
application.yml
# Add application configuration variables here, as shown below.
#
# PUSHER_APP_ID: "2954"
# PUSHER_KEY: 7381a978f7dd7f9a1117
# PUSHER_SECRET: abdc3b896a0ffb85d373
# STRIPE_API_KEY: EdAvEPVEC3LuaTg5Q3z6WbDVqZlcBQ8Z
# STRIPE_PUBLIC_KEY: pk_BRgD57O8fHja9HxduJUszhef6jCyS
#
# Copy this file to application.yml
def create
@type = Type.find(params[:type_id])
@product = @type.products.create(params[:product])
if @product.save
redirect_to :action => :show, :id => @product.id
else
render 'new'
end
end
sudo ./manage.py syncdb --noinput && ./manage.py migrate
Syncing...
11:16:1367000195 django.db.backends:DEBUG (0.023)
SELECT name FROM sqlite_master
WHERE type='table' AND NOT name='sqlite_sequence'
ORDER BY name; args=() :/home/willy/mozillians/vendor/src/django/django/db/backends/util.py:50
Creating tables ...
11:16:1367000195 django.db.backends:DEBUG (0.001) SELECT "django_content_type"."id", "django_content_type"."name", "django_content_type"."app_label", "django_content_type"."model" FROM "django_content_type" WHERE ("django_content_type"."model" = permission AND "django_content_type"."app_label" = auth ); args=('permission', 'auth') :/home/willy/mozillians/vendor/src/django/django/db/backends/util.py:50
11:16:1367000195 django.db.backends:DEBUG (0.000) SELECT "django_content_type"."id", "django_content_type"."name", "django_content_type"."app_label", "django_content_type"."model" FROM "django_content_type" WHERE ("django_content_type"."model" = group AND "django_co
@marti1125
marti1125 / gist:5477234
Created April 28, 2013 15:34
splat ruby
def describe_favorites(*games)
games.each{|game| puts "Favorite Game: #{game}"}
end
describe_favorites('Mario', 'Contra', 'Metroid')
@marti1125
marti1125 / gist:5477461
Created April 28, 2013 16:42
Game class
class Game
attr_accessor :name, :year, :system
attr_reader :created_at
def initialize(name, options={})
@name = name
@year = options[:year]
@system = options[:system]
@created_at = Time.now
end
end
@marti1125
marti1125 / gist:5498800
Created May 1, 2013 22:12
error message
{% if (user_form.errors or profile_form.errors) %}
<div class="alert alert-error">
The following fields are required (optin is the checkbox in the last panel):
<ol>
{% for error in user_form.errors %}
<li>{{ error|escape }}</li>
{% endfor %}
{% for error in profile_form.errors %}
<li>{{ error|escape }}</li>
{% endfor %}
@marti1125
marti1125 / gist:5499069
Created May 1, 2013 23:03
ruby class plus init method
class Library
attr_accessor :games
def initialize(games)
@games = games
end
end
@marti1125
marti1125 / gist:5500141
Created May 2, 2013 04:26
register metho
@allow_public
def register(request):
"""Registers Users.
Pulls out an invite code if it exists and auto validates the user
if so. Single-purpose view.
"""
if 'code' in request.GET:
request.session['invite-code'] = request.GET['code']
return redirect('home')
@marti1125
marti1125 / gist:5543889
Created May 8, 2013 21:40
UUID Generator in JavaScript
function randomUUID() {
var s = [], itoh = '0123456789ABCDEF';
for (var i = 0; i <36; i++) s[i] = Math.floor(Math.random()*0x10);
s[14] = 4;
s[19] = (s[19] & 0x3) | 0x8;