Skip to content

Instantly share code, notes, and snippets.

View kbparagua's full-sized avatar

Karl Bryan Paragua kbparagua

View GitHub Profile
{
	"bold_folder_labels": true,
	"color_scheme": "Packages/Materialize/schemes/Material Solarized Dark.tmTheme",
	"ensure_newline_at_eof_on_save": true,
	"font_size": 14,
	"highlight_line": true,
	"ignored_packages":
	[
	],
@kbparagua
kbparagua / tmux.conf
Created March 24, 2018 03:58 — forked from spicycode/tmux.conf
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000

Ruby Style Guide

This style guide is based on this community style guide.

Most of the rules listed will have a brief explanation to understand the reasoning behind each. If none is provided, maybe it's too obvious, or assume that its main purpose is to improve readability.

All new projects must adhere to this style guide. Existing and ongoing projects should stick with their current conventions or they can adapt this if no convention is being followed yet.

General

@kbparagua
kbparagua / 9605.rb
Last active January 11, 2017 07:18
prefixes = [
:generic_uncommon, :missing_information, :closed_account, :incorrect_information, :insufficient_funds, :not_authorized
]
['', '_follow_up', '_suspended'].each do |suffix|
prefixes.each do |prefix|
method = "#{prefix}#{suffix}"
FailedBillingMailer.send(method, Company.full_service.active.last).deliver
end
end
We couldn’t find that file to show.

Security is Hard

Massive Assignment

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

Admin

class Pacman
def self.get_instance
# instantiate the singleton instance if it is not existing yet.
if @instance.nil?
@instance = Pacman.new
end
@instance
end
# move up the singleton instance
Pacman.instance.move_up
# the same instance will move right
Pacman.instance.move_right
# the same instance will move down
Pacman.instance.move_down
def authenticate email, password
user = User.find_by_email email
if password.nil? || email !=~ /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i || user.nil?
return false
end
encrypted_password = BCrypt::Password.new password
if user.encrypted_password == encrypted_password
user