Skip to content

Instantly share code, notes, and snippets.

# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
app.post('/login', function(req, res) {
console.log(res);
passport.authenticate('local', function(err, user) {
if (req.xhr) {
//thanks @jkevinburton
if (err) { return res.json({ error: err.message }); }
if (!user) { return res.json({error : "Invalid Login"}); }
req.login(user, {}, function(err) {
if (err) { return res.json({error:err}); }
return res.json(
@ifiokjr
ifiokjr / MacSetup.sh
Last active June 17, 2018 07:21
Simple script for installing essentials on a new mac
#!usr/bin/env sh
## Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew install wget
## Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@ifiokjr
ifiokjr / regen-domain-types.js
Created July 15, 2018 08:28 — forked from adamkl/regen-domain-types.js
Generating typescript definitions from .graphql files using apollo-codegen and graphql-code-generator
const { introspectSchema } = require("apollo-codegen");
const { executeWithOptions } = require("graphql-code-generator/dist/cli");
const fs = require("fs");
const path = require("path");
const graphqlPath = "./src/graphql/";
const schemaInput = "./src/graphql/temp.graphql";
const jsonOutput = "./src/graphql/temp.json";
const dtsOutput = "./src/graphql/domain.d.ts";
@ifiokjr
ifiokjr / index.js
Created July 15, 2018 11:16 — forked from codediodeio/index.js
Firebase Cloud Functions image thumbnail generator using Sharp for 4x faster resizing
const functions = require('firebase-functions');
const gcs = require('@google-cloud/storage')();
const sharp = require('sharp')
const _ = require('lodash');
const path = require('path');
const os = require('os');
exports.generateThumbnail = functions.storage.object('uploads/{imageId}').onChange(event => {
const object = event.data; // The Storage object.
@ifiokjr
ifiokjr / create-encryption-key.sh
Created October 16, 2018 07:02
Basic setup of manual encryption of files
#!/bin/bash
set -e
exit 1
# Guidance only. NOT TO BE USED
## https://raymii.org/s/tutorials/Encrypt_and_decrypt_files_to_public_keys_via_the_OpenSSL_Command_Line.html#Decrypt_the_random_key_with_our_private_key_file
mkdir secrets
@ifiokjr
ifiokjr / destructured-jest.ts
Last active November 13, 2018 04:26
TS code samples
/**
* Jest tests can be destructured. However it won't work with inlineSnapshots
*/
const thrower = () => {
throw new Error('test');
};
const simple = () => {
//
};
@ifiokjr
ifiokjr / getAllDirectories.js
Created October 27, 2018 07:40
Get all directories with nodejs 10+ fs.promises
const { lstat, readdir } = require('fs').promises;
const pFilter = require('p-filter'); // Promise filter although this can easily be replaced.
const isDirectory = async source => {
const stats = await lstat(source);
return stats.isDirectory();
};
const getDirectories = async source => {
const list = await readdir(source);
const resolvedList = list.map(name => join(source, name));
@ifiokjr
ifiokjr / twitter_oauth_getter.js
Created October 28, 2018 21:08 — forked from tanepiper/twitter_oauth_getter.js
A small command line nodejs script for doing Twitter OAuth.
#!/usr/bin/env node
var argv = require('optimist')
.usage('Usage: --key=[consumer key] -secret=[consumer secret]')
.demand(['key', 'secret'])
.argv
;
var OAuth = require('oauth').OAuth;
var Step = require('step');
@ifiokjr
ifiokjr / apollo-link-token.mjs
Created October 29, 2018 00:13 — forked from jaydenseric/apollo-link-token.mjs
An Apollo Link for setting an auth token header.