Skip to content

Instantly share code, notes, and snippets.

@kjleng
kjleng / hosting-stack.ts
Created May 3, 2021 23:29 — forked from timveletta/hosting-stack.ts
Static site hosting with AWS CDK
import { Stack, Construct, StackProps, CfnOutput } from "@aws-cdk/core";
import {
HostedZone,
IHostedZone,
ARecord,
RecordTarget,
} from "@aws-cdk/aws-route53";
import { CloudFrontTarget } from "@aws-cdk/aws-route53-targets";
import { BucketProps, BlockPublicAccess, Bucket } from "@aws-cdk/aws-s3";
import {
DELIMITER |
CREATE FUNCTION uuid_from_bin(b BINARY(16))
RETURNS CHAR(36) DETERMINISTIC
BEGIN
DECLARE hex CHAR(32);
SET hex = HEX(b);
RETURN CONCAT(LEFT(hex, 8), '-', MID(hex, 9,4), '-', MID(hex, 13,4), '-', MID(hex, 17,4), '-', RIGHT(hex, 12));
END
|
@kjleng
kjleng / cryptojs_base64_encrypt_decrypt.js
Created February 8, 2017 01:19 — forked from joecliff/cryptojs_base64_encrypt_decrypt.js
An example of base64 usage in cryptojs
var CryptoJS = require("crypto-js");//replace thie with script tag in browser env
//encrypt
var rawStr = "hello world!";
var wordArray = CryptoJS.enc.Utf8.parse(rawStr);
var base64 = CryptoJS.enc.Base64.stringify(wordArray);
console.log('encrypted:', base64);
//decrypt
var parsedWordArray = CryptoJS.enc.Base64.parse(base64);
@kjleng
kjleng / README.md
Created January 14, 2017 01:16 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@kjleng
kjleng / Vagrantfile
Last active February 18, 2016 23:05
sample Vagrantfile
##### Source: https://github.com/smdahlen/vagrant-hostmanager/blob/master/README.md
Vagrant.configure("2") do |config|
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.vm.define 'example-box' do |node|
node.vm.hostname = 'example-box-hostname'
node.vm.network :private_network, ip: '192.168.42.42'