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
module SanitizerHelper | |
def sanitize text | |
text = text.to_s. | |
gsub("?xml",""). | |
gsub(/DOCTYPE|json|CDATA/,""). | |
gsub("<p><br></p>", "<br/>"). | |
gsub(/\<(script|iframe|xml|applet|body|code|em|form|html|head|header|footer|input|textarea|map|nav|pre|template|tab|var|video|canvas|audio|ruby|wbrxlink|xs|binding|soap|rdf|channel|rss)/,""). | |
gsub(/ +/," "). | |
gsub(/(\<br\>)+/,"<br>"). | |
gsub(/\n+/,"\n"). |
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
Object.class_eval do | |
def private_inspect | |
memo = {} | |
self.instance_variables.inject(memo) do |memo, var| | |
memo[var] = self.instance_variable_get(var).to_s | |
memo | |
end | |
except = [:__, :_, :_ex_, :_pry_, :_out_, :_in_, :_dir_, :_file_] |
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
require 'jwt' | |
require 'json' | |
API_KEY = "key" | |
API_SECRET = "secret" | |
token = JWT.encode({ | |
jti: SecureRandom.hex, | |
iss: API_KEY, | |
iat: Time.now.to_i, |
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
require "awesome_print" | |
module XmlParsing | |
require "ox" | |
class Reader < ::Ox::Sax | |
def initialize file_path, target, target_handler | |
@target_handler = target_handler | |
@target = target | |
@file_path = file_path |
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
require "sinatra" | |
require "oauth2" | |
DB = { | |
site: "http://api.local.com:3000/", | |
redirect_uri: "http://oauth2client:1758/callback" | |
} | |
get "/" do | |
DB[:uid] = params[:uid] |
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
amol_termsheet|fast!$ rf | grep Completed | |
Spring is not running | |
20:09:45 web.1 | Completed 200 OK in 5593ms (Views: 2031.4ms | ActiveRecord: 338.0ms) | |
20:09:50 web.1 | Completed 200 OK in 657ms (Views: 636.6ms | ActiveRecord: 7.4ms) | |
20:09:58 web.1 | Completed 200 OK in 604ms (Views: 579.4ms | ActiveRecord: 7.9ms) | |
20:10:08 web.1 | Completed 200 OK in 639ms (Views: 616.0ms | ActiveRecord: 9.8ms) | |
20:10:11 web.1 | Completed 200 OK in 657ms (Views: 635.3ms | ActiveRecord: 8.5ms) | |
20:10:17 web.1 | Completed 200 OK in 754ms (Views: 727.1ms | ActiveRecord: 7.7ms) | |
20:10:19 web.1 | Completed 200 OK in 680ms (Views: 655.1ms | ActiveRecord: 8.6ms) | |
20:10:20 web.1 | Completed 200 OK in 553ms (Views: 528.5ms | ActiveRecord: 8.5ms) |
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
module ActiveAdmin | |
module Views | |
class IndexAsTable < ActiveAdmin::Component | |
class IndexTableFor < ::ActiveAdmin::Views::TableFor | |
def timestamps_columns | |
column :created_at, :sortable => :created_at do |resource| | |
resource.created_at and resource.created_at.strftime('%b %-d %Y, %l %P') | |
end | |
column :updated_at, :sortable => :updated_at do |resource| |
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
## Prepare ################################################################### | |
# Remove RVM | |
rvm implode | |
# Ensure your homebrew is working properly and up to date | |
brew doctor | |
brew update | |
## Install ################################################################### |
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
### write your solution here | |
module M | |
def method_m | |
puts 'from m...' | |
end | |
end | |
module N | |
def method_n |
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
In Ruby class variables are denoted by `@@`, and instance variables are denoted by `@` | |
Instance variables | |
- are private to the class instance, cannot be accessed outside class unless shared | |
- they cannot be accessed outside class instance methods | |
- they get inherited | |
Class variables | |
- are private to the class instance, cannot be accessed outside class unless shared | |
- they cannot be accessed outside class instance methods |