Skip to content

Instantly share code, notes, and snippets.

View marklocklear's full-sized avatar

J. Mark Locklear marklocklear

View GitHub Profile
@marklocklear
marklocklear / gist:5757086
Last active December 18, 2015 08:49
Summer of Rails
Week 4
>rails g migration add_completed_to_ideas completed:boolean
>
<div class="field">
<%= f.label :completed %><br />
<%= f.check_box :completed %>
</div>
>rails g migration add_range_to_ideas range:integer
<
<div class="field">
require 'brewery_db'
brewery_db = BreweryDB::Client.new do |config|
config.api_key = 'b7a3521dc50ce9c2e6c675dd896c276a'
end
=begin
abv = brewery_db.beers.all(abv: '5.5')
abv.each do |b|
puts b.name
#main.rb
require "./include.rb"
@board = Array.new
@board = {'ul' => 'ul', 'um' => 'um', 'ur' => 'ur',
'ml' => 'ml', 'mm' => 'mm', 'mr' => 'mr',
'll' => 'll', 'lm' => 'lm', 'lr' => 'lr'}
puts "Enter a move in the following sequence\n
#include.rb
def show_board
count = 0
@board.each { |key, value|
print "#{value}" + " | "
if count == 2 or count == 5 then print "\n______________\n" end
count += 1
}
print "\n"
end
A big thank you to anyone who has donated already - it is very truly appreciated.
My brother Nate is fighting stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (unpaid FMLA), no insurance coverage, and cannot afford treatment. Nate and his family need your help. Thank you.
Josh Goebel, Pastie creator
Donate now Read Nate's story Hide this message
Pastie Pastie << self Blog
@marklocklear
marklocklear / heat map
Created August 28, 2012 23:33
heat map
app/views/tags/index.html.slim
==heatmap(@histogram)
app/models/tag.rb
has_many :user_votes, :through => :items
def frequency
self.user_votes.count
end
class Product < ActiveRecord::Base
#serialize :data, ActiveRecord::Coders::Hstore
attr_accessible :name, :category, :price, :description
validates_numericality_of :runtime, allow_blank: true
%w[author rating runtime].each do |key|
attr_accessible key
scope "has_#{key}", lambda { |value| where("properties @> (? => ?)", key, value) }
define_method(key) do
Started POST "/products" for 127.0.0.1 at 2012-06-26 08:56:23 -0400
Processing by ProductsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"bheB/PpRy3HIjAaye8vR/VlpxgIrGG22P5TQjMdnf8k=", "product"=>{"name"=>"A Few Good Men", "price"=>"13.95", "author"=>"Aarron Sorrkin", "rating"=>"PG", "runtime"=>"3"}, "commit"=>"Create Product"}
(0.2ms) BEGIN
SQL (119.1ms) INSERT INTO "products" ("created_at", "name", "price", "properties", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["created_at", Tue, 26 Jun 2012 12:56:23 UTC +00:00], ["name", "A Few Good Men"], ["price", 13], ["properties", {"author"=>"Aarron Sorrkin", "rating"=>"PG", "runtime"=>"3"}], ["updated_at", Tue, 26 Jun 2012 12:56:23 UTC +00:00]]
PG::Error: ERROR: Syntax error near 'a' at position 4
: INSERT INTO "products" ("created_at", "name", "price", "properties", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"
(0.2ms) ROLLBACK
Completed 500 Internal Server Error in 125ms
ubuntu@domU-12-31:/var/www/myrailsapp$ bundle exec rake routes
todos GET /todos(.:format) todos#index
POST /todos(.:format) todos#create
new_todo GET /todos/new(.:format) todos#new
edit_todo GET /todos/:id/edit(.:format) todos#edit
todo GET /todos/:id(.:format) todos#show
PUT /todos/:id(.:format) todos#update
DELETE /todos/:id(.:format) todos#destroy
ubuntu@domU-C:/var/www/myrailsapp$ apache2ctl -t -D DUMP_MODULES
@marklocklear
marklocklear / appmobi
Created February 21, 2012 19:21
Appmobi path
http://localhost:58888/_emulator/_ide/login.html