Skip to content

Instantly share code, notes, and snippets.

View nnhansg's full-sized avatar
🏠
Working from home

Nathan nnhansg

🏠
Working from home
View GitHub Profile
@nnhansg
nnhansg / tmux-cheatsheet.markdown
Created March 5, 2020 08:15 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

How To Secure Nginx with Let's Encrypt on Ubuntu 16.04

Step 1 — Installing Certbot

First, add the repository.

sudo add-apt-repository ppa:certbot/certbot

You'll need to press ENTER to accept. Then, update the package list to pick up the new repository's package information.

sudo apt-get update
@nnhansg
nnhansg / slugify.js
Created May 16, 2019 04:05 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}

OS X Terminal color prompt

Update .bash_profile with content:

export CLICOLOR=1
export PS1="\[\e[36m\]\w\[\e[0m\]$ "
alias ll='ls -GFhl' dir='ls -GFhl'
alias start=open
printf "\033]0;`date "+%a %d %b %Y %I:%M %p"`\007"
@nnhansg
nnhansg / rabbit_publisher.rb
Created October 8, 2018 06:54 — forked from ntamvl/rabbit_publisher.rb
RabbitMQ Ruby Example
# an initializer
# gem install bunny
# written by: Tam Nguyen (twitter: @nguyentamvn)
require 'bunny'
require 'json'
class RabbitPublisher
def initialize(options = {})
bunny_config = {
@nnhansg
nnhansg / tutorial.md
Created July 17, 2018 06:05 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

ActionCable: How to use dynamic channels

Pass a roomId on your subscription creation in javascripts/channels/room.js:

MakeMessageChannel = function(roomId) {
  // Create the new room channel subscription
  App.room = App.cable.subscriptions.create({
    channel: "RoomChannel",
    roomId: roomId
 }, {