Skip to content

Instantly share code, notes, and snippets.

@hieulm
hieulm / chi.go
Created March 8, 2024 12:35 — forked from alexaandru/chi.go
Chi-like syntactic sugar layer on top of stdlib http.ServeMux
// Chi-like syntactic sugar layer on top of stdlib http.ServeMux.
package main
import (
"net/http"
"slices"
)
type (
middleware func(http.Handler) http.Handler
@hieulm
hieulm / hhvm.hdf
Created August 24, 2019 18:22 — forked from betawax/hhvm.hdf
Laravel HHVM config
Server {
Port = 8080
SourceRoot = /var/www/foobar/public/
}
VirtualHost {
* {
Pattern = .*
RewriteRules {
* {
@hieulm
hieulm / token-generator.js
Created June 13, 2019 04:19 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@hieulm
hieulm / babun-Hyper-Win.md
Created October 12, 2018 07:40 — forked from silo/babun-Hyper-Win.md
Babun + Hyper + Windows - Setup
@hieulm
hieulm / db.js
Created September 17, 2018 03:58 — forked from cpsubrian/db.js
Mock knex database for Jest
/* eslint-env jest */
import _ from 'lodash'
import path from 'path'
import fs from 'fs'
import callsites from 'callsites'
import knex from 'knex'
import hash from 'object-hash'
import conf from '<conf>'
// Get the db config.
@hieulm
hieulm / abstractions.md
Created July 13, 2018 08:32 — forked from arobson/abstractions.md
Rabbit.MQ + Node.js Notes

Abstraction Suggestions

Summary: use good/established messaging patterns like Enterprise Integration Patterns. Don't make up your own. Don't expose transport implementation details to your application.

Broker

As much as possible, I prefer to hide Rabbit's implementation details from my application. In .Net we have a Broker abstraction that can communicate through a lot of different transports (rabbit just happens to be our preferred one). The broker allows us to expose a very simple API which is basically:

  • publish
  • request
  • start/stop subscription
@hieulm
hieulm / MaterialReactSelect.js
Created April 23, 2018 10:05
react-select overrides for a material-ui@next feel
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { Async } from 'react-select';
// UI.
import { withStyles } from 'material-ui/styles';
import { FormControl } from 'material-ui/Form';
import { InputLabel } from 'material-ui/Input';
@hieulm
hieulm / Python-3-Django-El-Capitan.md
Created August 30, 2016 03:08 — forked from martincr/Python-3-Django-El-Capitan.md
Install Python 3 and Django on Mac OS X El Capitan (10.11.2) - and use virtualenv and virtualenvwrapper

Preamble

Background Reading