Skip to content

Instantly share code, notes, and snippets.

View leomayleomay's full-sized avatar

Hao Liu leomayleomay

View GitHub Profile
class Post < ActiveRecord::Base
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 500.kilobytes,
:resize_to => '320x200>',
:thumbnails => { :thumb => '100x100>' }
belongs_to :user
validates_presence_of :user_id
end
>> Post.create(:user_id => 1, :title => "foo", :body => "bar", :uploaded_data => File.open("Monalisa.jpg", "rb"))
<html>
<head>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'1234', // order ID - required
jQuery(".edit_game_image").live("mousedown", function(event) {
jQuery(this).facebox({
loadingImage : '/images/facebox/loading.gif',
closeImage : '/images/facebox/closelabel.gif'
});
return false;
});
Started POST "/users" for 127.0.0.1 at 2010-08-13 20:18:09 +0800
Processing by Devise::RegistrationsController#create as HTML
Parameters: {"_snowman"=>"☃", "authenticity_token"=>"414K4VX7W2VQmVMTRlycvizG3ha+j5CdkVD42MdvlVs=", "user"=>{"username"=>"danny", "email"=>"danny@foobar.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
SQL (0.1ms) BEGIN
User Load (0.0ms) SELECT `users`.`id` FROM `users` WHERE (LOWER(`users`.`email`) = LOWER('danny@foobar.com')) LIMIT 1
User Load (0.0ms) SELECT `users`.`id` FROM `users` WHERE (`users`.`username` = BINARY 'danny') LIMIT 1
SQL (0.6ms) describe `users`
SQL (38.2ms) INSERT INTO `users` (`created_at`, `current_sign_in_at`, `current_sign_in_ip`, `email`, `encrypted_password`, `last_sign_in_at`, `last_sign_in_ip`, `password_salt`, `remember_created_at`, `remember_token`, `reset_password_token`, `sign_in_count`, `updated_at`, `username`) VALUES ('2010-08-13 12:18:10', NULL, NULL, 'danny@foobar.com', '$2a$10$BCBemJx0
def boxshot_for(country = nil)
country ||= 'us'
catalog_images.all(:order => "display_order asc").select{|item| item.country_list && item.country_list.include?(country)}.first
end
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
# app/helpers/resources_helper.rb
def options_for(resources)
result = []
resources.each do |c|
result << [c.id, "-"*c.ancestors.size + c.name]
unless c.children.empty?
result += options_for(c.children)
end
end
We couldn’t find that file to show.
@leomayleomay
leomayleomay / PhantomTypeReasonML.md
Created March 9, 2018 22:31 — forked from busypeoples/PhantomTypeReasonML.md
Phantom types in ReasonML

Phantom types in ReasonML

Introduction

"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.