Skip to content

Instantly share code, notes, and snippets.

View todgru's full-sized avatar

todgru

  • Portland, OR
View GitHub Profile
@davestevens
davestevens / LetsEncrypt.md
Last active November 6, 2024 11:48
Let’s Encrypt setup for Apache, NGINX & Node.js

Let's Encrypt

Examples of getting certificates from Let's Encrypt working on Apache, NGINX and Node.js servers.

Obtain certificates

I chose to use the manual method, you have to make a file available to verify you own the domain. Follow the commands from running

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
@JadedEvan
JadedEvan / TUTORIAL-ruby-instance-methods-versus-attribute-accessors.md
Last active July 20, 2016 16:54
An article highlighting the difference in using instance methods over attribute accessors in Ruby classes. A fundamental concept that is often overlooked by beginner and intermediate Rubyists that can lead to cleaner, more predictable code

Ruby Design Patterns - Methods over Attributes

Overview

The objective of this article is to highlight the subtle differences between using class attributes and class methods in Ruby. Both offer a valid way to manipulate the state of an instance of a class. Things can get increasingly complex, hard to test and hard to maintain as more instance variables are introduced. Beginner and intermediate Rubyists often miss this subtle but important point which can introduce bugs that may be hard to fix in their native habitat.

The reasons I prefer to use methods over instance variables:

  • Increases predictability of method calls
  • Increases predictability when testing
@joerx
joerx / index.js
Last active May 17, 2023 12:58
Mocking S3 in Node.js using Sinon
var Aws = require('aws-sdk');
var sinon = require('sinon');
// Only works for 'createBucket', 'update' and a few others since most API methods are generated dynamically
// upon instantiation. Very counterintuitive, thanks Amazon!
var createBucket = sinon.stub(Aws.S3.prototype, 'createBucket');
createBucket.yields(null, 'Me create bucket');
// For other methods, we can 'assign' the stubs to the proto, already defined function won't be overridden
var listBuckets = Aws.S3.prototype.listBuckets = sinon.stub();
@chrisciampoli
chrisciampoli / list.js
Last active March 13, 2024 11:11
Javascript List ADT (Abstract Data Type)
function List() {
this.listSize = 0;
this.pos = 0;
this.dataStore = []; // initializes an empty array to store list elements
this.clear = clear;
this.find = find;
this.toString = toString;
this.insert = insert;
this.append = append;
this.remove = remove;
@todgru
todgru / rake.sh
Last active August 29, 2015 14:06 — forked from felixhummel/rake.sh
# bash completion for rake
#
# some code from on Jonathan Palardy's http://technotales.wordpress.com/2009/09/18/rake-completion-cache/
# and http://pastie.org/217324 found http://ragonrails.com/post/38905212/rake-bash-completion-ftw
#
# For details and discussion
# http://turadg.aleahmad.net/2011/02/bash-completion-for-rake-tasks/
#
# INSTALL
#
@todgru
todgru / .tmux.conf.sh
Created June 24, 2014 20:32
Tmux Conf taken from the internet
# So we can send prefix to nested tmux sessions, then note that other tmux sessions may still use ctrl-b
bind-key a send-prefix
bind-key Up resize-pane -U
bind-key Down resize-pane -D
bind-key Left resize-pane -L
bind-key Right resize-pane -R
# unbind { key - i keep accidentally hitting it!
unbind-key {
@todgru
todgru / aws-ec2-redis-cli.md
Created June 12, 2014 23:01
AWS redis-cli on EC2
@todgru
todgru / git-rebase-interactive.md
Last active February 13, 2025 19:33
git interactive rebase

#Git Interactive Rebase

Scenario: We have a topic branch we've been working on. We want to combine the last few commits into one single commit. Our intention is to merge this topic branch, with one clean commit, into our main dev branch.

Solution: Git Rebase Interactive

Checkout your topic branch and look at your commit history:

$ git checkout topic-branch
@todgru
todgru / ssh-tunnel.md
Last active May 6, 2023 15:32
How to set-up a SSH tunnel for AWS RDS

SSH Tunnel

Our db is hosted on Amazon. Our web server can connect to the db. Connections to the db are not allowed outside of the web server.

Run ssh tunnel locally:

This creates a tunnel from my local machine to the web server:

ssh -N -L 3307:my-rds-db.us-east-1.rds.amazonaws.com:3306 ec2-my-web-server.compute-1.amazonaws.com
@srt32
srt32 / gist:8535548
Created January 21, 2014 06:59
nginx.conf file for running multiple apps using passenger
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;