Skip to content

Instantly share code, notes, and snippets.

class View < ActiveRecord::Base
belongs_to :item, polymorphic: true
class << self
attr_accessor :user
end
before_create :set_user
private
# Do you want something like this...
class CitiesDatatable < Datatable
datatable class_name: 'City', search_keys: [:name]
end
# where you would access the Datatable information like this, where self == controller.view_context ...
cities_datatable = CitiesDatatable.new(self)
cities_datatable.to_json # => { sEcho: 1, iTotalRecords: 20, iTotalDisplayRecords: 10, aaData: [...] }
class FooBar < ActiveRecord::Base
...
def program_ids_list=(list)
self.program_ids = list.split(',')
end
end
line_1_array_of_integers = gets.chomp.split(" ").map(&:to_i)
line_2_array_of_integers = gets.chomp.split(" ").map(&:to_i)
puts line_1_array_of_integers
puts line_2_array_of_integers
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
class CommentComponent
include Rafters::Component
attribute :subject
attribute :body
default :comment, nil
private
class ApplicationController
before_filter :override_current_user
...
private
def override_current_user
class_eval <<-METHODS, __FILE__, __LINE__ + 1
def current_user_with_sharding
do_stuff
# Get your project into GitHub
cd /your/project/directory
git init .
git add -A .
git commit -m "Initial import"
git remote add origin https://github.com/[user]/[repo].git
git push origin master
# After making some changes
git add -A .
var fetchPartialWithDatepicker = function (pathToPartial) {
var request = $.ajax({
method: 'GET',
url: pathToPartial,
data: {
whatever: "foo"
}
});
request.done(function (html) {
$.get(url ,function(table){
$('#'+lang).hide().html(table).fadeIn(1000);
var dateField = $('.dateField', $('#'+lang));
if (dateField.length > 0) {
dateField.datepicker({ options: "and", whatever: "you need" });
}
});