One of my favorite Ruby tricks:
> "foo".methods.sort - Object.methods
killportprocs() { | |
local targetport=${1:?pass in target port} | |
local pids=$(lsof -i :$targetport | awk '{print $2}' | tail +2) | |
echo "$pids" | |
echo $pids | xargs kill -9 | |
} |
One of my favorite Ruby tricks:
> "foo".methods.sort - Object.methods
lsof -i :4327 | awk '{ print $2 }' | tail -n+2 | xargs kill -9 |
{ | |
viewer { | |
pullRequests(first: 10, orderBy: {field: UPDATED_AT, direction: DESC}) { | |
nodes { | |
title | |
closedAt | |
url | |
} | |
} | |
issues(first: 10, orderBy: {field: UPDATED_AT, direction: DESC}) { |
config.log_tags = [ | |
:request_id, | |
:subdomain, | |
->(req) { | |
session_key = (Rails.application.config.session_options || {})[:key] | |
session_data = req.cookie_jar.encrypted[session_key] || {} | |
user_id = session_data["user_id"] || "guest" | |
"user: #{user_id.to_s}" | |
} | |
] |
# usage: cat ~/Downloads/log_foo-bar-baz.jsonl | ruby honeybadger_parser.rb | |
require 'json' | |
data = ARGF.read | |
lines = data.split("\n") | |
grouped = lines.group_by do |line| | |
JSON.parse(line)["request"]["context"]["project_id"] | |
end |
machine: | |
services: | |
- docker | |
dependencies: | |
override: | |
- echo "no deps" | |
test: | |
post: |
require 'minitest' | |
require 'minitest/autorun' | |
class ReduceTest < Minitest::Test | |
def test_capitalize_keywords_in_phrase_one_fish_two_fish_red_fish_blue_fish | |
keywords = ["fish", "blue"] | |
phrase = 'one fish two fish red fish blue fish' | |
result = phrase.split.reduce do |updatedPhrase, word| | |
new_word = word |
CREATE TABLE IF NOT EXISTS users ( | |
email varchar PRIMARY KEY NOT NULL, | |
started_on date NOT NULL | |
); | |
CREATE UNIQUE INDEX users_email_index ON users (email); |
// original | |
function updateImage(){ | |
square_urls.map(function(urls){ | |
urls.map(function(u){ | |
console.log(u); | |
}); | |
}); | |
} | |