Skip to content

Instantly share code, notes, and snippets.

View jsmestad's full-sized avatar
👾

Justin Smestad jsmestad

👾
View GitHub Profile
@dmsul
dmsul / vim_crash_course.md
Last active May 5, 2024 00:53
Vim Crash Course

NOTE: Specific examples given for options, flags, commands variations, etc., are not comprehensive.

NORMAL MODE

Vim has 2 main "modes", that chance the behavior of all your keys. The default mode of Vim is Normal Mode and is mostly used for moving the cursor and navigating the current file.

Some important (or longer) commands begin with ":" and you will see the text you enter next at the bottom left of the screen.

:q[uit] - quit (the current window of) Vim. ("Window" here is internal to Vim, not if you have multiple OS-level windows of Vim open at once.)
:q! - force quit (if the current buffer has been changed since the last save)
:e[dit] {filename} - read file {filename} into a new buffer.

@gkaemmer
gkaemmer / Elixir_Supervision_Trees.md
Last active December 18, 2023 14:37
Quick guide to creating Elixir supervision trees from scratch

Elixir Supervision Trees Made Easy

I started with Elixir just a couple weeks after the switch from 1.4 to 1.5, so the bulk of online resources were out of date (or at least resulted in deprecation warnings). This guide is for defining Elixir 1.5 supervised modules.

It's not actually terribly complicated. It's just sometimes unclear from examples what's implemented by the language and what you actually have to implement yourself.

Say we want a supervision tree like this (where each atom is a process):

    :a

/ \

emacs --daemon to run in the background. emacsclient.emacs24 <filename/dirname> to open in terminal

NOTE: "M-m and SPC can be used interchangeably".

  • Undo - C-/
  • Redo - C-?
  • Change case: 1. Camel Case : M-c 2. Upper Case : M-u
  1. Lower Case : M-l
@mars
mars / json_api_base_serializer.rb
Last active April 8, 2016 19:31
ActiveModel Serializers for JSON-API (with association sideloading)
# Ancestor for JSON-API serializers, implements
# "application/vnd.api+json" media type conventions.
#
# See: http://jsonapi.org
#
class JsonApiSerializer < ActiveModel::Serializer
# Always make pluralized root JSON property.
#
def self.inherited(subclass)
@stevenharman
stevenharman / sidekiq.rb
Last active March 6, 2020 17:35
The best solution I've found for reliably configuring Sidekiq's ActiveRecord connection pool size on Heroku.
# /config/initializers/sidekiq.rb
current_web_concurrency = Proc.new do
web_concurrency = ENV['WEB_CONCURRENCY']
web_concurrency ||= Puma.respond_to?
(:cli_config) && Puma.cli_config.options.fetch(:max_threads)
web_concurrency || 16
end
local_redis_url = Proc.new do
@snooc
snooc / nginx.conf
Last active December 18, 2015 11:29
Install systemwide rbenv and ruby on Ubuntu 13.04
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
worker_rlimit_nofile 8192;
events {
worker_connections 1024;
}
@sr75
sr75 / wildcard-ssl-cert-for-testing-nginx-conf.md
Created June 1, 2013 18:35
create a self signed wildcard ssl cert for testing with nginx.conf example

just change out app_name for your purposes

openssl genrsa 2048 > app_name-wildcard.key

openssl req -new -x509 -nodes -sha1 -days 3650 -key app_name-wildcard.key > app_name-wildcard.cert

# Common Name (eg, your name or your server's hostname) []:*.app_name.com

openssl x509 -noout -fingerprint -text &lt; app_name-wildcard.cert &gt; app_name-wildcard.info
@wrburgess
wrburgess / gist:5528649
Last active November 24, 2022 15:29
Backup Heroku Postgres database and restore to local database

Grab new backup of database

Command: heroku pgbackups:capture --remote production

Response: >>> HEROKU_POSTGRESQL_COLOR_URL (DATABASE_URL) ----backup---> a712

Get url of backup download

Command: heroku pgbackups:url [db_key] --remote production

@tpope
tpope / foremux
Last active August 11, 2016 16:42
#!/usr/bin/env ruby
# Install in PATH as foremux
if %w(help --help -h).include?(ARGV.first)
$stderr.puts <<-help
Usage:
foremux [PROCESS]
Options:
-e, [--env=ENV] # Specify an env file to load, defaults to .env