Skip to content

Instantly share code, notes, and snippets.

View johnteee's full-sized avatar

John Lee johnteee

  • Taipei
View GitHub Profile
@johnteee
johnteee / timeout_and_tick.go
Created August 29, 2019 06:22 — forked from ngauthier/timeout_and_tick.go
Golang timeout and tick loop
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
@johnteee
johnteee / golang_job_queue.md
Created August 13, 2019 02:41 — forked from harlow/golang_job_queue.md
Job queues in Golang
@johnteee
johnteee / find-rls-preview.sh
Created June 16, 2019 15:50 — forked from MadratJerry/find-rls-preview.sh
Find the latest rust nightly version with rls-preview
#!/bin/bash
MAC=false
date -r "$now" +%Y-%m-%d &> /dev/null
if [ "$?" -ne "0" ]; then echo "LINUX"; MAC=false; else echo 'MAC'; MAC=true; fi
now=`date +%s`
while true
do
if [ "$MAC" == "true" ]; then data=`date -r "$now" +%Y-%m-%d`; else data=`date -d @"$now" +%Y-%m-%d`; fi
// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
swal({
title: "Session Expired",
text: "Your session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
@johnteee
johnteee / curl.md
Created April 16, 2019 03:42 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@johnteee
johnteee / PageViewController.swift
Created April 7, 2019 03:52 — forked from miguelfermin/PageViewController.swift
Demonstrates how to add a UIPageViewController to a UIViewController
//
// ViewController.swift
// PageViewController
//
// Created by Miguel Fermin on 5/8/17.
// Copyright © 2017 MAF Software LLC. All rights reserved.
//
import UIKit
@johnteee
johnteee / server.js
Created January 15, 2019 10:03 — forked from bencentra/server.js
An HTTPS server for static content (Node.js)
/*
This module creates an HTTPS web server and serves static content
from a specified directory on a specified port.
To generate a new cert:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
To remove the passphrase requirement:
@johnteee
johnteee / sampletokenSpec.rb
Created December 10, 2018 03:39 — forked from dallasjohnson/sampletokenSpec.rb
Unit Test for EOS.IO contracts using rspec
require 'rspec_command'
require "json"
# 1. A recent version of Ruby is required
# 2. Ensure the required gems are installed with `gem install rspec json rspec-command`
# 3. Run this from the command line with rspec sampletokenSpec.rb
# Optionally output the test results with -f [p|d|h] for required views of the test results.
# For debugging I added a clear action to the contract which clears everything in the tables
@johnteee
johnteee / nodeos_full_node_setup.txt
Created November 23, 2018 06:51 — forked from cc32d9/nodeos_full_node_setup.txt
nodeos installation with ZFS
apt-get update && apt-get install -y aptitude git lxc-utils zfsutils-linux netfilter-persistent sysstat
# find the partition ID that is linked to the storage serial number.
# This will prevent from losing the partition if disk mapping changes
ls -l /dev/disk/by-id/ | grep sda6
zpool create -f zdata /dev/disk/by-id/wwn-0x600507604092b628236df4851535cef5-part6
## Fixate internal IP address of the container
systemctl stop lxc-net
sed -i -e 's,^.*LXC_DHCP_CONFILE,LXC_DHCP_CONFILE,' /etc/default/lxc-net