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
#!/bin/bash | |
## | |
# Interactive search. | |
# Usage: `ff` or `ff <folder>`. | |
# | |
[[ -n $1 ]] && cd $1 # go to provided folder or noop | |
RG_DEFAULT_COMMAND="rg -i -l --hidden --no-ignore-vcs" | |
selected=$( |
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
## | |
# MySQL 8 CTE | |
# tree (id int, pid int, name varchar(255)) | |
# | |
WITH recursive tbl AS ( | |
SELECT | |
t.id, | |
1 AS depth, | |
cast(name as CHAR(500)) AS path | |
FROM tree t WHERE t.pid IS NULL |
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
// create a mutable set | |
Set<String> set = Sets.newHashSet("Jay", "Betsy"); | |
// create an immutable set | |
Set<String> set = ImmutableSet.of("Jay", "Betsy", "Jenny"); | |
// create a mutable list | |
List<String> list = Lists.newArrayList("Jay", "Betsy"); | |
// create an immutable list | |
List<String> list = ImmutableList.of("Jay", "Betsy", "Jenny"); |
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
## | |
# cap rails:console | |
# https://gist.github.com/benedikt/1115513#comment-576015 | |
# | |
namespace :rails do | |
desc "Remote console" | |
task :console, roles: :app do | |
run_interactively "bundle exec rails console #{rails_env}" | |
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
- Set theory [https://en.wikipedia.org/wiki/Set_theory] | |
- Graph theory [https://en.wikipedia.org/wiki/Graph_theory] | |
- Number theory [https://en.wikipedia.org/wiki/Number_theory] | |
- Combinatorics [https://en.wikipedia.org/wiki/Combinatorics] | |
- Linear algebra [https://en.wikipedia.org/wiki/Linear_algebra] | |
- Relational algebra [https://en.wikipedia.org/wiki/Relational_algebra] |
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
# controllers/application_controller.rb | |
class ApplicationController | |
# @override | |
def current_ability | |
@current_ability ||= Ability::Factory.build(user) | |
end | |
end | |
# ability/factory.rb | |
class Ability::Factory |
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
## | |
# Hooks: | |
# extended (Class that called with extend) | |
# included (Class that called with include) | |
# prepended (Class that called with prepend) | |
# inherited (Class that was inherited with <) | |
# method_added (Method symbol of new method created) | |
# method_removed (Method symbol when method removed) | |
# method_undefined (Method symbol of undefined method) | |
# singleton_method_added (Method symbol of new method created) |
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
# syntax | |
can(action, object_class) | |
# ability.rb | |
can(:custom_ability, Person) | |
can(:controller_action, Person) | |
cannot(:read, Feedback) { |model| true } | |
# persons_controller.rb | |
def action |