Skip to content

Instantly share code, notes, and snippets.

View hongz1's full-sized avatar

Jae Hong Lee hongz1

  • @cranesupply
View GitHub Profile
@hongz1
hongz1 / mongo-autostart-osx.md
Created November 14, 2017 03:46 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

@hongz1
hongz1 / grab_emails.pl
Created August 14, 2018 05:17 — forked from DamianZaremba/grab_emails.pl
Perl script for grabbing emails from an IMAP folder
#!/usr/bin/perl
use strict;
use Mail::IMAPClient;
use IO::Socket;
use IO::Socket::SSL;
use Time::ParseDate;
use Data::Dumper;
# Config stuff
my $mail_hostname = '';
@hongz1
hongz1 / tempdir.pl
Created August 18, 2018 20:06 — forked from odyniec/tempdir.pl
An example Perl program that uses File::Temp to create a temporary directory for the time of program execution.
#!/usr/bin/env perl
use Cwd;
use File::Temp;
# Remember the current directory
my $oldcwd = getcwd;
# Create a temporary directory
my $dir = File::Temp->newdir;
# Go to the temporary directory
@hongz1
hongz1 / jwt-module.js
Created December 25, 2018 07:11 — forked from SiddharthaChowdhury/jwt-module.js
Implementation of JWT using private and public keys
const fs = require('fs');
const jwt = require('jsonwebtoken');
// http://travistidwell.com/blog/2013/09/06/an-online-rsa-public-and-private-key-generator/
// use 'utf8' to get string instead of byte array (1024 bit key)
var privateKEY = fs.readFileSync('./private.key', 'utf8'); // to sign JWT
var publicKEY = fs.readFileSync('./public.key', 'utf8'); // to verify JWT
module.exports = {
sign: (payload, $Options) => {
/*
@hongz1
hongz1 / material-icons.css
Created May 4, 2019 01:33 — forked from loicbisiere/material-icons.css
Material icons with unicode
/*
* CSS File of Material icons.
* CSS code based on:
* https://google.github.io/material-design-icons/#icon-font-for-the-web
*/
//= depend_on_asset "MaterialIcons-Regular.eot"
//= depend_on_asset "MaterialIcons-Regular.woff2"
//= depend_on_asset "MaterialIcons-Regular.woff"
//= depend_on_asset "MaterialIcons-Regular.ttf"
@hongz1
hongz1 / encryption.js
Created March 2, 2021 20:18 — forked from vlucas/encryption.ts
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@hongz1
hongz1 / xmlToJson.js
Created July 2, 2021 14:10 — forked from chinchang/xmlToJson.js
Function to convert XML to JSON
/**
* Changes XML to JSON
* Modified version from here: http://davidwalsh.name/convert-xml-json
* @param {string} xml XML DOM tree
*/
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) {
@hongz1
hongz1 / node-app
Created June 1, 2022 20:27 — forked from thehunmonkgroup/node-app
Redhat init script for managing a NodeJS app via forever
#!/bin/sh
##
## Redhat / Linux / LSB
##
# chkconfig: 345 85 15
# description: Startup script for Express / Node.js application with the \
## forever module.
##
## A modification of https://gist.github.com/1339289
##