Skip to content

Instantly share code, notes, and snippets.

@designium
designium / gist:2930247
Created June 14, 2012 13:17
Nested form
<% @product.images.build if @product.images.blank? %>
<%= f.simple_fields_for :images do |img| %>
<% unless @product.images.first.file.blank? %>
<div class="control-group">
<label class="controls"><%= image_tag @product.images.first.file %></label>
</div>
<%= img.input :_destroy, :label => "Remove", :as => :boolean %>
<% end %>
<%= img.input :file, :as => :file, :label => "Picture", input_html: { class: "input-hundredpercent" } %>
<% end %>
require 'mechanize'
keyword = 'mixer'
@target_url = "http://www.canadiantire.ca/search/search_results.jsp?bmForm=form_endeca_search&bmFormID=1343016788618&bmUID=1343016788618&bmIsForm=true&bmText=quick_search_term&quick_search_term=#{keyword}&bmSubmit=quick_search"
@agent = Mechanize.new
@agent.get(@target_url)
@all_news_links = []
ruby -v
ruby 2.0.0dev (2013-02-08 trunk 39161) [x86_64-darwin12.2.0]
--------------------------------------------------
$ bundle update
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3)
Using i18n (0.6.4)
@designium
designium / deploy.rb
Created March 18, 2013 00:59 — forked from stas/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
0x598c1EDcf5Feb6415d25f655ceA524dF4338d5C3
0xd8e863a7d76D08Dd8540f691F544D31296e708A7
pragma solidity ^0.4.11;
contract Counter {
/* define variable count of the type uint */
uint count = 0;
/* this runs when the contract is executed */
function increment() public {
count = count + 1;
@designium
designium / read-access.sql
Created May 24, 2019 20:36 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;