Skip to content

Instantly share code, notes, and snippets.

View bobwei's full-sized avatar

Bob Wei bobwei

View GitHub Profile
@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>
#
@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() {
/* 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 / 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 \
'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] ])
(function(){
var newscript = document.createElement('script');
newscript.type = 'text/javascript';
newscript.async = true;
newscript.src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(newscript);
})();
window.redirectTo = function(){
// android redirect
if (window.navigator.userAgent.match(/Android/)){
setTimeout(function() {
if (!document.webkitHidden){
window.location = 'https://play.google.com/store/apps/details?id=com.linkwish.onepiece';
}
}, 1000);
window.location = 'fb1393011827627092://';
require.config({
paths: {
jquery: '../bower_components/jquery/jquery',
bootstrapAffix: '../bower_components/sass-bootstrap/js/affix',
bootstrapAlert: '../bower_components/sass-bootstrap/js/alert',
bootstrapButton: '../bower_components/sass-bootstrap/js/button',
bootstrapCarousel: '../bower_components/sass-bootstrap/js/carousel',
bootstrapCollapse: '../bower_components/sass-bootstrap/js/collapse',
bootstrapDropdown: '../bower_components/sass-bootstrap/js/dropdown',
bootstrapPopover: '../bower_components/sass-bootstrap/js/popover',
@bobwei
bobwei / bower.json
Created March 3, 2014 08:09
Bob's webapp packages
{
"name": "",
"version": "0.0.0",
"dependencies": {
"sass-bootstrap": "~3.0.0",
"requirejs": "~2.1.8",
"jquery": "~1.10.2",
"angular": "~1.2.6",
"angular-route": "~1.2.6",
"requirejs-text": "~2.0.10",