Skip to content

Instantly share code, notes, and snippets.

@AnsonT
AnsonT / CustomerPresenterRow.swift
Created May 4, 2018 17:29
[Custom Eureka Push Row in Swift] Use a custom view controller for a 'push row' #eureka #swift
//
// CustomPresenterRow.swift
// LinkedNow
//
// Created by Anson Tsao on 5/3/18.
// Copyright © 2018 Anson Tsao. All rights reserved.
//
import Foundation
import Eureka
@AnsonT
AnsonT / index.js
Last active September 18, 2023 17:48
Using Node-Jose to for RSA jwt with key store
import { JWE, JWK, JWS } from 'node-jose'
import fs from 'fs'
import { join } from 'path'
import jwkToPem from 'jwk-to-pem'
import jwt from 'jsonwebtoken'
const certDir = '.cert'
const keystoreFile = join(certDir, 'keystore.json')
const raw = {
iss: 'test',
@AnsonT
AnsonT / basicjwt.js
Last active March 8, 2024 22:53
Simplest Passport/JWT implementation with cookie and bearer authentication support
import express from 'express'
import bodyParser from 'body-parser'
import cookieParser from 'cookie-parser'
import passport from 'passport'
import passportJWT, { ExtractJwt, Strategy as JwtStrategy } from 'passport-jwt'
import bcrypt from 'bcrypt'
import jwt from 'jsonwebtoken'
const { fromExtractors, fromAuthHeaderWithScheme, fromAuthHeaderAsBearerToken } = ExtractJwt
@AnsonT
AnsonT / frame.html
Created September 11, 2014 03:48
HTML5 MessageChannel
<!DOCTYPE html>
<html>
<script type="text/javascript">
function click1() {
console.log("click");
window.parentPort.postMessage("Click Message from Frame");
}
function onParentMessage(e) {
console.log("In Frame");
console.log(e);
@AnsonT
AnsonT / gist:1115264
Created July 30, 2011 06:32
CoffeeScript debugging with node-inspector
node-inspector &
coffee --nodejs --debug app.coffee &
google-chrome http://127.0.0.1:8080/debug?port=5858 &
google-chrome http://127.0.0.1:3000 &
@AnsonT
AnsonT / coffee-jquery.jade
Created July 29, 2011 18:04
Client-side Coffeescript with Jade and JQuery
!!! 5
html(lang='en')
head
title Title
script(type='text/javascript', src='javascripts/jquery.js')
script(type='text/javascript', src='http://jashkenas.github.com/coffee-script/extras/coffee-script.js')
:coffeescript
$(document).ready -> alert 'Hello World'
@AnsonT
AnsonT / gist:1094451
Created July 20, 2011 06:26 — forked from shripadk/gist:652819
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require ('connect-redis')(connect)