Skip to content

Instantly share code, notes, and snippets.

View bobwei's full-sized avatar

Bob Wei bobwei

View GitHub Profile
'use strict';
/*
arr = [1, 2, 3]
for each element in arr, create subArr
for i = 1 => subArr = [2, 3]
for i = 2 => subArr = [1, 3]
for each subArr, get permutations
(ex: [2, 3] => [ [2, 3], [3, 2] ])
@bobwei
bobwei / generate_docker_cert.sh
Last active July 26, 2016 16:33 — forked from bradrydzewski/generate_docker_cert.sh
Generate trusted CA certificates for running Docker with HTTPS
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
# See http://docs.docker.com/articles/https/
#
# To start the Docker Daemon:
#
# sudo docker -d \
/* eslint-disable no-param-reassign, max-len */
const findItinerary = (tickets, debug) => {
const graph = tickets.reduce((s, v) => {
const [key, value] = v;
if (!s[key]) {
s[key] = [];
}
s[key].push(value);
return s;
}, {});
@bobwei
bobwei / ExpressJS rawBody
Created August 7, 2016 17:37 — forked from enreeco/ExpressJS rawBody
NodeJS ExpressJS Getting Raw Body on request object
app.configure(function() {
//. . .
app.use(express.bodyParser());
app.use(function(req, res, next) {
var data = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
data += chunk;
});
req.on('end', function() {
@bobwei
bobwei / ngrok_hostname.sh
Created April 11, 2017 02:41 — forked from rjz/ngrok_hostname.sh
Get ngrok hostname from command line
#!/bin/sh
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON
# string. We can hack out the forwarded hostname by extracting the next
# `*.ngrok.io` string from the JSON
#
# Brittle as all get out--YMMV. If you're still reading, usage is:
#
# $ ./ngrok_hostname.sh <proto> <addr>
#
curl -X POST \
-H "Content-Type: application/json" \
-d '{}' \
${BASE_API_URL}
import 'dotenv/config';
import { CronJob } from 'cron';
const { JOB1_CRON_TIME } = process.env;
new CronJob({
cronTime: JOB1_CRON_TIME,
onTick: () => {
console.log('do your job');
},
import React from 'react';
import compose from 'recompose/compose';
import withState from 'recompose/withState';
import withHandlers from 'recompose/withHandlers';
import flattenProp from 'recompose/flattenProp';
const Comp = ({ images, isOpen, currentImage, next, previous, toggleOpen }) =>
<Lightbox
images={images}
isOpen={isOpen}
@bobwei
bobwei / .drone.yml
Created December 15, 2017 17:13 — forked from learncodeacademy/.drone.yml
Rancher Drone CD Pipeline Setup
pipeline:
slack:
image: plugins/slack
webhook: <your slack webhook url>
channel: deployments
username: drone
template: "<{{build.link}}|Deployment #{{build.number}} started> on <http://github.com/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> by {{build.author}}"
when:
branch: [ master, staging ]
build: