Skip to content

Instantly share code, notes, and snippets.

View 2called-chaos's full-sized avatar
😐
perpetually bored

Sven Pachnit 2called-chaos

😐
perpetually bored
View GitHub Profile
@2called-chaos
2called-chaos / xray_rails.js
Last active December 23, 2024 11:42
xray-rails (crude edition) / screenshot below
// Note: make sure your editor in step 2 is non-blocking (i.e. not "subl -w")
//
// 1. Enable in your config/environment/development.rb
// config.action_view.annotate_rendered_view_with_filenames = true
//
// 2. Add this to your routes.rb
// post "__xray/open", to: ->(env) {
// editor = ENV["GEM_EDITOR"] || ENV["VISUAL"] || ENV["EDITOR"] || "/usr/local/bin/subl"
// params = JSON.parse(Rack::Request.new(env).body.read)
// path = Rails.root.join(params["path"].to_s)
@2called-chaos
2called-chaos / install_nginx_ppa.sh
Last active July 9, 2019 12:51
Install nginx from nginx.org PPA sources
# add source
cat >> /etc/apt/sources.list <<EOF
# Nginx
deb http://nginx.org/packages/ubuntu/ disco nginx
deb-src http://nginx.org/packages/ubuntu/ disco nginx
EOF
# add signing key
curl http://nginx.org/packages/keys/nginx_signing.key | sudo apt-key add -
@2called-chaos
2called-chaos / setup-autossh-tunnel.sh
Last active April 30, 2018 15:38
Adds a start script which will setup a port forwarding over SSH (via autossh) for database traffic tunneling. You can use this script for every port actually. I might called it different but I only need it for MySQL ;-)
#!/bin/bash
# Install:
# curl -O https://gist.githubusercontent.com/2called-chaos/4285767/raw/setup-autossh-tunnel.sh
# chmod u+x setup-autossh-tunnel.sh
# ./setup-autossh-tunnel.sh
SSH_USER="mysql_tunnel"
SSH_SERVER="db.example.net"
SSH_PORT="22"
@2called-chaos
2called-chaos / each_with_position.rb
Created October 2, 2012 22:56
Ruby Enumerable each_with_position (provides #first? #last? #prev #next ...)
##################################
### SCROLL DOWN FOR AN EXAMPLE ###
##################################
module Enumerable
# your each_with_position method
def each_pos &block
EachWithPosition.each(self, &block)
end
end