Skip to content

Instantly share code, notes, and snippets.

View srt32's full-sized avatar

Simon Taranto srt32

  • GitHub
  • WORLD
  • 04:13 (UTC -04:00)
View GitHub Profile
@srt32
srt32 / killportprocs.bash
Created April 29, 2019 16:58
`killportprocs 3000` - will print and then kill all the pids bound to port 3000
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
}
@srt32
srt32 / phew.md
Created March 14, 2019 19:38
Figure out which methods a Ruby object has

One of my favorite Ruby tricks:

> "foo".methods.sort - Object.methods
@srt32
srt32 / kill.bash
Created March 5, 2019 20:36
kill processes running on a port
lsof -i :4327 | awk '{ print $2 }' | tail -n+2 | xargs kill -9
@srt32
srt32 / query.graphql
Last active October 2, 2018 02:56
find recently changed issues / PR's - https://developer.github.com/v4/explorer/
{
viewer {
pullRequests(first: 10, orderBy: {field: UPDATED_AT, direction: DESC}) {
nodes {
title
closedAt
url
}
}
issues(first: 10, orderBy: {field: UPDATED_AT, direction: DESC}) {
@srt32
srt32 / application.rb
Created May 17, 2018 22:23
logging current user.id in Rails logs
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}"
}
]
@srt32
srt32 / honeybadger_parser.rb
Last active November 8, 2022 19:56
parse the JSONL export from honeybadger.io
# 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
@srt32
srt32 / circleci.yml
Created June 15, 2017 16:35
Building and Deploying Docker Images to Heroku via CircleCI
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
@srt32
srt32 / migration
Created September 26, 2014 17:04
welcome-wagon create table
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);
});
});
}