Skip to content

Instantly share code, notes, and snippets.

View stevecrozz's full-sized avatar

Stephen Crosby stevecrozz

View GitHub Profile
@stevecrozz
stevecrozz / copy-to-heroku.md
Last active September 25, 2024 23:31
Copy a file to remote heroku dyno

If you ever want to copy a local file to a remote heroku dyno, you can! Steps:

  1. Execute heroku ps:exec with the --ssh arg to connect to a dyno of your choice (and reveal the native ssh connection parameters). For example heroku ps:exec --app=my-app --dyno=web.1 --ssh
  2. Find the ssh command that was used using ps. For example ps ax | grep ssh | grep heroku-exec-key
  3. Pipe your file right into that ssh command, receive it with cat on the other end and redirect it wherever you want. For example: cat myawesomefile | ssh -o UserKnownHostsFile=/var/folders/fs/v_kjxw8s1nl1lcd9lm_r1vs80000gq/T/heroku-exec-proxy-key2024825-1652-7r5vmz.q7vch -o ServerAliveInterval=10 -o ServerAliveCountMax=3 -p 80 -i /var/folders/fs/v_kjxw8s1nl1lcd9lm_r1vs80000gq/T/heroku-exec-key2024825-1652-4trc3k.akeov [email protected] "cat > /tmp/myawesomefile"
@stevecrozz
stevecrozz / mullvad-config-to-edgerouter-config.sh
Created July 29, 2024 16:04
Process mullvad ini config into some edgerouter config
#! /bin/bash
private_key=$(grep PrivateKey "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
public_key=$(grep PublicKey "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
allowed_ips=$(grep AllowedIPs "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
address=$(grep Address "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
endpoint=$(grep Endpoint "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}')
echo $private_key
echo $public_key
@stevecrozz
stevecrozz / r-png.rb
Created February 23, 2021 23:24
Ruby PNG Reader
require 'zlib'
module RImage
class InvalidSignature < Exception
end
class InvalidChecksum < Exception
end
class RImage
@stevecrozz
stevecrozz / read-rails-session.js
Last active March 9, 2019 04:49
read rails 5.1 sessions from nodejs
const crypto = require('crypto');
const rawCookie = 'raw-cookie-contents';
class SessionReader {
constructor({
secret_key_base,
salt,
iterations,
keylen,
# Author: Peter Prettenhofer <[email protected]>
# Olivier Grisel <[email protected]>
# Mathieu Blondel <[email protected]>
# Lars Buitinck
# License: BSD 3 clause
from __future__ import print_function
import re
import logging
@stevecrozz
stevecrozz / doit.rb
Created February 1, 2019 21:58
autogenerate mobx-state-tree models from ruby mongoid models
def doit
type_map = {
BSON::ObjectId => 'string',
Time => 'date',
Object => 'reference',
Hash => 'map',
Integer => 'integer',
DateTime => 'Date',
String => 'string',
Array => 'array',
@stevecrozz
stevecrozz / Dockerfile.kramdown-minified
Created January 4, 2019 06:27
Dockerfile.kramdown-original
FROM ruby:2.6-alpine
RUN gem install kramdown && \
rm -R /usr/local/bundle/gems/kramdown-1.17.0/test/ && \
rm -R /usr/local/bundle/gems/kramdown-1.17.0/doc/ && \
rm -R /usr/local/bundle/cache/
@stevecrozz
stevecrozz / drone-io-aws-cloudwatch-metrics-producer.py
Created March 22, 2018 23:54
drone.io AWS CloudWatch metrics producer
#! /usr/bin/env python
import json, sys, urllib2
from subprocess import call
request_headers = {
"Authorization": "Bearer ..."
}
request = urllib2.Request("https://.../api/info/queue", headers=request_headers)
recent = !git for-each-ref refs/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset)|%(color:bold green)%(committerdate:relative)%(color:reset)|%(contents:lines=1)|%(color:magenta)%(authorname)%(color:reset)' --count 100 --sort=-committerdate | column -ts '|' | less -SXRF
# clone into the appropriate place in your $GOPATH
git clone [email protected]:63cb64e5217beab99342e4b0aea9551f.git

# change into the buggy project
cd 63cb64e5217beab99342e4b0aea9551f

# generate a client package
"$GOPATH/bin/goagen" -o . -d gist.github.com/63cb64e5217beab99342e4b0aea9551f client