Skip to content

Instantly share code, notes, and snippets.

View codingChewie's full-sized avatar
💭
(╯'□')╯︵ ┻━┻

Chewie codingChewie

💭
(╯'□')╯︵ ┻━┻
View GitHub Profile
# Terminal Cheat Sheet
pwd # print working directory
ls # list files in directory
cd # change directory
~ # home directory
.. # up one directory
- # previous working directory
help # get help
-h # get help
@codingChewie
codingChewie / ultimate-ut-cheat-sheet.md
Created February 11, 2021 00:13 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@codingChewie
codingChewie / gitHub-curl.sh
Created December 1, 2020 17:06 — forked from Integralist/GitHub curl.sh
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
@codingChewie
codingChewie / index.js
Created November 9, 2019 20:38 — forked from jwo/index.js
Simple way to sign in with github for oAuth in Node/Express
const express = require("express")
const app = express()
var passport = require("passport")
var session = require("express-session")
var GitHubStrategy = require("passport-github2").Strategy
const GITHUB_CLIENT_ID = "your-client-id-here" // or get from process.env.GITHUB_CLIENT_ID
const GITHUB_CLIENT_SECRET = "your-client-secret-here" // or get from process.env.GITHUB_CLIENT_SECRET
const GITHUB_CALLBACK_URL = "http://localhost:5000/auth/github/callback" // or get from process.env.GITHUB_CALLBACK_URL
@codingChewie
codingChewie / node_nginx_ssl.md
Created November 1, 2019 13:55 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@codingChewie
codingChewie / app.js
Created September 19, 2019 04:06 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@codingChewie
codingChewie / express_in_electron.md
Created September 9, 2019 23:55 — forked from maximilian-lindsey/express_in_electron.md
How to run Express inside an Electron app

How to run Express inside an Electron app

You can run your Express app very easily inside your Electron app.

All you need to do is to:

  • place all the files of your Express app inside a new app folder in your_electron_app\resources\app
  • reconfigure the app.js file
  • refactor some relative pathes in your Express app
@codingChewie
codingChewie / rule.js
Created August 29, 2019 17:32 — forked from vktr/rule.js
Add Stripe Customer Id to Auth0 via custom rule
function (user, context, callback) {
user.app_metadata = user.app_metadata || {};
if ('stripe_customer_id' in user.app_metadata) {
context.idToken['https://example.com/stripe_customer_id'] = user.app_metadata.stripe_customer_id;
return callback(null, user, context);
}
var stripe = require('stripe')('sk_....');
var customer = {
@codingChewie
codingChewie / image64.sh
Created July 14, 2019 17:21 — forked from puppybits/image64.sh
Create data URI image from Terminal command
#!/bin/sh
# Examples:
# ./image64.sh myImage.png
# outputs: data:image/png;base64,xxxxx
# ./image64.sh myImage.png -img
# outputs: <img src="data:image/png;base64,xxxxx">
filename=$(basename $1)
xtype=${filename##*.}
append=""
@codingChewie
codingChewie / archive.html
Created June 29, 2019 15:43 — forked from tuananh/archive.html
Group posts by month in Jekyll archive page
---
layout: default
title: Archive
---
<div class="post">
<h2>Archive</h2>
<ul>
{% for post in site.posts %}
{% unless post.next %}