This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Calculator | |
attr_accessor :x, :y | |
def initialize(x, y) | |
@x, @y = x, y | |
end | |
def Calculator.description | |
string = "Performs basic mathematical operations" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
attr_reader :first_name, :age, :gender, :family | |
def initialize(first_name, age, gender) | |
@first_name = first_name | |
@age = age | |
@gender = gender | |
@family = nil | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApplicationController | |
# Automatically create the strong parameters required method | |
def PostsController.filter_parameters(options = {}) | |
options[:for] = [options[:for]] if options[:for].is_a?(Symbol) | |
options[:for].each do |action_name| | |
define_method("#{action_name.to_s}_params") do | |
base = options[:require].keys.first | |
params.require(base).permit(*options[:require][base]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
filter_params require: {user: [:name, :description]}, only: [:create, :update] | |
def create | |
end | |
def update | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redis.watch("running") | |
if redis.exists("running") == true | |
puts "already running" | |
exit | |
end | |
redis.multi do | |
redis.setex("running", 300, true) | |
end | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Configuration | |
attr_reader :download_url, :speed | |
def initialize | |
@download_url = "" | |
@speed = :fastest | |
end | |
def url(new_download_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
link "http://api.plnkr.co/catalogue/packages?" | |
95.times do |i| | |
page = i + 1 | |
# use page here in the request | |
end | |
# ever use while like that again and i'll come over there and kill you |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_trailing_zeros(array = []) | |
if array.size > 0 && array[-1].to_i == 0 | |
array.pop | |
remove_trailing_zeros(array) | |
else | |
array | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require 'rubygems' | |
require 'skype' | |
Skype.config :app_name => "Prepare" | |
120.times do | |
Skype.message "miki.bergin", "תכין" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fetching git://github.com/radar/better_spree_paypal_express.git | |
remote: Reusing existing pack: 1284, done. | |
remote: Total 1284 (delta 0), reused 0 (delta 0) | |
Receiving objects: 100% (1284/1284), 181.85 KiB | 174.00 KiB/s, done. | |
Resolving deltas: 100% (388/388), done. | |
Fetching gem metadata from https://rubygems.org/........ | |
Fetching additional metadata from https://rubygems.org/.. | |
Resolving dependencies... | |
Bundler could not find compatible versions for gem "spree_core": | |
In Gemfile: |