Skip to content

Instantly share code, notes, and snippets.

View xirukitepe's full-sized avatar
🙈
See No Evil

Shi xirukitepe

🙈
See No Evil
View GitHub Profile
@xirukitepe
xirukitepe / setAttribute.js
Created March 2, 2013 09:13
setAttribute
$("#add-item").click(function() {
var divs = document.getElementsByClassName('budget-field');
var divs2 = document.getElementsByClassName('mini-field');
var divs3 = document.getElementsByClassName('text-area');
var divs4 = document.getElementsByClassName('check-box');
var divs5 = document.getElementsByTagName('select');
for (i = 0; i < divs.length; i++) {
divs[i].setAttribute('readonly',true);
@xirukitepe
xirukitepe / rails.org
Created March 11, 2013 06:54 — forked from map7/rails.org
/*
* Unobtrusive autocomplete
*
* To use it, you just have to include the HTML attribute autocomplete
* with the autocomplete URL as the value
*
* Example:
* <input type="text" data-autocomplete="/url/to/autocomplete">
*
* Optionally, you can use a jQuery selector to specify a field that can
@xirukitepe
xirukitepe / import.rake
Created May 21, 2013 07:45
import data from a CSV file
require 'csv'
desc "Imports a CSV file into local or production database"
task :import, [:filename] => :environment do
CSV.foreach('public/cats.csv', :headers => true) do |row|
Category.find_or_create_by_description(row.to_hash)
end
end
/*
* Unobtrusive autocomplete
*
* To use it, you just have to include the HTML attribute autocomplete
* with the autocomplete URL as the value
*
* Example:
* <input type="text" data-autocomplete="/url/to/autocomplete">
*
* Optionally, you can use a jQuery selector to specify a field that can
/*! jQuery UI - v1.9.2 - 2013-02-12
* http://jqueryui.com
* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS%2CHelvetica%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=dddddd&bgTextureHeader=glass&bgImgOpacityHeader=35&borderColorHeader=bbbbbb&fcHeader=444444&iconColorHeader=999999&bgColorContent=c9c9c9&bgTextureContent=inset_soft&bgImgOpacityContent=50&borderColorContent=aaaaaa&fcContent=333333&iconColorContent=999999&bgColorDefault=eeeeee&bgTextureDefault=glass&bgImgOpacityDefault=60&borderColorDefault=cccccc&fcDefault=3383bb&iconColorDefault=70b2e1&bgColorHover=f8f8f8&bgTextureHover=glass&bgI

Security is Hard

Massive Assignment

  • watch for ActiveRecord Relation, like has_many, has_many :through
  • watch for user_roles, `group_users
  • UPDATE action

Admin

# MySQL. Versions 4.1 and 5.0 are recommended.
#
# 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
@xirukitepe
xirukitepe / development_mailer.rb
Created August 12, 2013 06:02
development_mailer.rb
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: 'gmail.com',
authentication: "plain",
enable_starttls_auto: true,