Playlist https://www.youtube.com/playlist?list=PLS6F722u-R6KYlGyUv65EFpGKl2Esmurr
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
// Place your key bindings in this file to override the defaultsauto[] | |
[ | |
{ | |
"key": "ctrl+e", | |
"command": "-extension.vim_ctrl+e", | |
"when": "editorTextFocus && vim.active && vim.use<C-e> && !inDebugRepl" | |
}, | |
{ | |
"key": "ctrl+a", | |
"command": "-extension.vim_ctrl+a", |
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
# config/environments/test.rb | |
# ... | |
# Already had this: | |
config.action_mailer.default_url_options = { host: "www.example.com" } | |
# Had to add this: | |
Rails.application.routes.default_url_options = { host: "www.example.com" } |
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
rails r 'require "redis"; redis = Redis.new; pattern = "jbuilder/*"; cursor = 0; loop do;cursor, keys = redis.scan(cursor, match: pattern);redis.del(*keys) unless keys.empty?;break if cursor == "0";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
namespace :dump do | |
task db: :environment do | |
if !Rails.env.development? | |
raise "This task is only available in development environment" | |
end | |
puts "Removing potential existing backups..." | |
if File.directory?("/tmp/backups") | |
FileUtils.rm_rf("/tmp/backups") | |
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
ActiveRecord::Base.connection.execute(<<-SQL) | |
UPDATE projects | |
SET comments_count = ( | |
SELECT COUNT(*) | |
FROM comments | |
WHERE comments.commentable_id = projects.id | |
AND comments.commentable_type = 'Project' | |
) | |
SQL |
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
// TODO: Make typescript happy here. | |
type JSONValue = | |
| string | |
| number | |
| boolean | |
| { [x: string]: JSONValue } | |
| Array<JSONValue>; | |
interface JSONObject { | |
[x: string]: JSONValue; |
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
if ARGV.empty? | |
data = DATA.readlines(chomp: true) | |
else | |
data = File.readlines(ARGV[0], chomp: true) | |
end | |
solved = {} | |
expressions = {} | |
data.each do |line| |
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
if ARGV.empty? | |
data = [1, 2, -3, 3, -2, 0, 4] | |
else | |
data = File | |
.readlines(ARGV[0], chomp: true) | |
.map(&:to_i) | |
end | |
def mix(data) | |
# iterate over all the elements and |
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
if ARGV.empty? | |
data = DATA.readlines(chomp: true) | |
else | |
data = File.readlines(ARGV.first, chomp: true) | |
end | |
def blueprints(data) | |
data.map do |line| | |
match = /Blueprint (?<id>\d+): Each ore robot costs (?<ore_robot_ore>\d+) ore. Each clay robot costs (?<clay_robot_ore>\d+) ore. Each obsidian robot costs (?<obsidian_robot_ore>\d+) ore and (?<obsidian_robot_clay>\d+) clay. Each geode robot costs (?<geode_robot_ore>\d+) ore and (?<geode_robot_obsidian>\d+) obsidian./.match(line) |
NewerOlder