Skip to content

Instantly share code, notes, and snippets.

class GroupsController < ApplicationController
def index
@groups = Group.all
end
def show
@group = Group.find(params[:id])
#@posts = @group.posts
end
@poc7667
poc7667 / initd-nginx
Last active December 20, 2015 03:59
nginx init.d script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@poc7667
poc7667 / Rails App Environment
Created July 24, 2013 08:31
Install Nginx Passenger Rails on Ubuntu [Failed]
Project Path : /home/poc/Dropbox/Ruby/zeus
poc@ubuntu:zeus$ which ruby
/home/poc/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
poc@ubuntu:zeus$ gem list
*** LOCAL GEMS ***
actionmailer (4.0.0, 3.2.12)
@poc7667
poc7667 / schema.rb
Created July 25, 2013 03:38
How to reset primary key (??) I wanna set my primary key to translate_str , let it be unique in the table, But I've already create the table and have lots of date in the database.
create_table "translates", :force => true do |t|
t.string "translate_str"
t.string "EN"
t.string "DE"
t.string "ES"
t.string "FR"
t.string "IT"
t.string "JP"
t.string "PT"
t.string "CN"
@poc7667
poc7667 / index.html.erb
Created July 25, 2013 10:03
Rails 3 Simple Search Form Example (without Ajax)
<%= form_tag translate_search_path, :method => :get do %>
<%= text_field_tag :search %>
<%= submit_tag 'Search_key' %>
<% end %>
@poc7667
poc7667 / _search.html.erb
Created July 26, 2013 02:06
Search form with ajax not worked ?
<ul>
<% if !@results.nil? %>
<% @results.each do |result| %>
<li>
<%= result %>
</li>
<% end %>
<% else %>
<%= @results.inspect %>
class Categorization < ActiveRecord::Base
attr_accessible :category_id, :product_id
belongs_to :product
belongs_to :category
end
<%= f.hidden_field :user_id, :value => current_user.id %>
@poc7667
poc7667 / development.rb
Last active December 20, 2015 08:49
Setting ActionMailer
config.action_mailer.default_url_options = { :host => '172.16.77.88:3000' }
#remmembe to set in production.rb ,also
@poc7667
poc7667 / usage.py
Last active December 20, 2015 13:19
Beautifulsoup Notes
# fine Group and Subgroup, in <p> tag
grp_list=['Group','Subgroup']
grps = soup.find('body').findAll('p',text =re.compile('|'.join(grp_list)))
#remove \r\n , special characters by split + join
# 8. Useful\r\nFunctions' => 8. Useful Functions
print( ' '.join(belong_to_chap.split()))