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
// stolen from: https://dev.to/gajus/my-favorite-css-hack-32g3 | |
* { background-color: rgba(255,0,0,.2); } | |
* * { background-color: rgba(0,255,0,.2); } | |
* * * { background-color: rgba(0,0,255,.2); } | |
* * * * { background-color: rgba(255,0,255,.2); } | |
* * * * * { background-color: rgba(0,255,255,.2); } | |
* * * * * * { background-color: rgba(255,255,0,.2); } | |
* * * * * * * { background-color: rgba(255,0,0,.2); } | |
* * * * * * * * { background-color: rgba(0,255,0,.2); } |
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
# inspired by this article: https://www.honeybadger.io/leveling-up/safeguarding-redis/ | |
# and adapted from this gist: https://gist.github.com/joshuap/c1ff2657c150df6fb1257398b1d2716b | |
# | |
# * needed a way to disable flushall and flushdb in Production only | |
# * wanted to add a way to add some basic tests for sanity and explicit documentation | |
# | |
############### config/initializers/redis.rb ######################### | |
require 'redis' | |
require 'redis_dangerous_commands' |
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 | |
# resets HEAD back one commit, recommits with provided message and force pushes to origin | |
commitmsg=$1 | |
# stole function from: .oh-my-zsh/lib/git.zsh | |
function current_git_branch() { | |
local ref | |
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) | |
local ret=$? |
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 BankAccount | |
attr_reader :balance | |
def initialize(starting_balance) | |
@balance = starting_balance | |
end | |
# if this were #irl we'd need to worry about race conditions here | |
def deposit(amount) | |
@balance += amount | |
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
# sed -i -f convert_to_snakecase __yourfile__ | |
# | |
# to run this within in vim: | |
# %s/[A-Z]/_\L&/g | %s/\<_//g | |
s/[A-Z]/_\L&/g; s/\b_//g |
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
#!/usr/bin/env ruby | |
changed_files = `git diff-tree --no-commit-id --name-only --diff-filter=AM -r HEAD`.lines.map(&:chomp) | |
return if changed_files.empty? | |
results = `bundle exec rubocop --color #{changed_files.join(" ")}` | |
no_offenses_detected = results.include?("\e[32mno offenses\e[0m detected") | |
return if no_offenses_detected |
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
return unless Rails.env.development? | |
MAX_LOG_SIZE = 2.megabytes | |
logs = File.join(Rails.root, 'log', '*.log') | |
if Dir[logs].any? { |log| File.size?(log).to_i > MAX_LOG_SIZE } | |
$stdout.puts "---------- \033[32m clearing dev logs \033[0m --------------" | |
`rails log:clear` | |
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
> rails g controller home index | |
> rails g channel chat | |
------- | |
config/routes.rb: | |
------- | |
root 'home#index' | |
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
INSTALL: | |
$ git clone --recursive https://github.com/WebAssembly/wabt | |
$ cd wabt | |
$ make clang-release | |
$ cd out/clang/Release | |
$ pwd | pbcopy (or just pwd and copy the output manually) | |
Add the pwd path to your shell config $PATH for ease of use. |
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 'digest' | |
class Block | |
attr_reader :index, :parent, :created_at, :data, :hash | |
def initialize(index:, data:, parent: '') | |
@index = index.to_i | |
@data = data | |
@parent = parent.empty? ? '0' : parent | |
@created_at = Time.now.to_s |
NewerOlder