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
gg_replace() { | |
if [[ "$#" == "0" ]]; then | |
echo 'Usage:' | |
echo ' gg_replace term replacement file_mask' | |
echo | |
echo 'Example:' | |
echo ' gg_replace cappuchino cappuccino *.html' | |
echo | |
else | |
find=$1; shift |
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
.river-pics | |
= profile_image_for current_user | |
%p #{current_user.first_name}, #{current_user.age} | |
.blurb | |
%p | |
#content | |
%h1 Satisfied? | |
%p Hover your mouse over your picture. | |
%p This is how others will see you. |
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
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
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
Log onto bad mongo primary | |
Use mongotop to find bad database | |
Run this to find long running queries | |
db.currentOp()['inprog'].filter(function (t){return t.secs_running > 10}).map(function (t){return t.opid}) | |
Kill bad ops with | |
db.killOp(<opid>) |
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
def missing_number num_array: | |
n = num_array.length + 1 | |
expected = n * (n + 1) / 2 | |
actual = num_array.reduce :+ | |
missing = expected - actual | |
return missing | |
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
def fizzbuzz(max): | |
1.upto(max).each do |num| | |
line = '' | |
line << 'Fizz' if num % 3 == 0 | |
line << 'Buzz' if num % 5 == 0 | |
line = num if line.empty? | |
p line | |
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
def tokenize_query_split query, punctuation | |
punc_regex = /[#{punctuation}\s]+/ | |
tokens = query.split(punc_regex) | |
tokens.each do |token| | |
p token | |
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
## SUMMARY | |
# Use Hash($db) to maintain state | |
# Track # open transactions | |
# Memoize modified vars per transaction ($history) | |
# Be naught, use globals (not thread-safe) | |
$db = {} | |
$transactions = 0 | |
$history = {} |
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
$stack = [] | |
def solution(s) | |
s.each_char do |c| | |
case c | |
when /[0-9]/ | |
$stack.push c | |
puts c | |
when '+' | |
return -1 unless op_nums(lambda { |left, right| left + right }) |
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
# Check nums for rows, columns and blocks | |
def check(nums): | |
num_dict = {} | |
# assume nums is a list of integers | |
# placeholder for empty is None | |
for num in nums: | |
if not num: | |
continue | |
if num in num_dict: | |
return false |
OlderNewer