Skip to content

Instantly share code, notes, and snippets.

View henrytseng's full-sized avatar

Henry Tseng henrytseng

View GitHub Profile
docker run -it --rm -p 8888:8888 -v "${pwd}":/home/jovyan/work jupyter/datascience-notebook:0fd03d9356de
#include <iostream>
#include <chrono>
#include <type_traits>
#include <future>
#include <thread>
struct stop_watch
{
using wall_clock = typename std::conditional< std::chrono::high_resolution_clock::is_steady,
std::chrono::high_resolution_clock,
@henrytseng
henrytseng / gist:eda731b5f868ff1ef730c3a49b400ab5
Created June 15, 2021 04:51
Spektrum SPM9645 DSMX remote receiver parser
#!/usr/bin/env python
# This script is capable of decoding a Spektrum DSMX remote receiver
# Inspired by http://diydrones.com/profiles/blog/show?id=705844%3ABlogPost%3A64228
# After satellite powerup first byte is 0, then it increases after TX interruptions
# to 45, 90, 135, 180, 225, 279, 324, 369 (it seems to loose 1 at 0xFF rollower)
# Code was written very fast. It is not yet stable and I'm not proud of it,
# but it works ;-)
; Ender 3 Custom Start G-code
M140 S{material_bed_temperature_layer_0} ; Set Heat Bed temperature
M190 S{material_bed_temperature_layer_0} ; Wait for Heat Bed temperature
M104 S160; start warming extruder to 160
G28 ; Home all axes
G29 ; Auto bed-level (BL-Touch)
G92 E0 ; Reset Extruder
M104 S{material_print_temperature_layer_0} ; Set Extruder temperature
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
M109 S{material_print_temperature_layer_0} ; Wait for Extruder temperature
@henrytseng
henrytseng / exportLabel
Created January 28, 2021 15:32
Google App Script to export gmail to spreadsheet
function exportLabel() {
var sheet = SpreadsheetApp.getActiveSheet();
var label = GmailApp.getUserLabelByName("Export.MyExport");
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
var message = messages[j];
@henrytseng
henrytseng / Brewfile
Created January 22, 2021 16:13
A brewfile with helm-kind
brew "git"
brew "python3"
brew "pyenv"
brew "helm"
brew "kind"
brew "gnu-sed"
@henrytseng
henrytseng / setup_kind.sh
Created January 22, 2021 16:10
Setup a Kind Kubernetes deployment with a image registry
#!/bin/sh
#
# Adapted from:
# https://github.com/kubernetes-sigs/kind/commits/master/site/static/examples/kind-with-registry.sh
#
# Copyright 2020 The Kubernetes Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@henrytseng
henrytseng / getCurrentPosition_canvas.html
Created April 21, 2020 16:26 — forked from strongwave/getCurrentPosition_canvas.html
A Demo Drawing Google Map on Canvas Tag for HTML5
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
jQuery(window).ready(function(){
g_initialize();
jQuery("#findLocationBtn").click(initiate_geolocation);
});
@henrytseng
henrytseng / .inputrc
Created January 14, 2020 01:54
Natural keybindings
"\033[1;5C": forward-word
"\033[1;5D": backward-word
@henrytseng
henrytseng / .pryrc
Created October 5, 2019 03:24
Ruby Pry configuration file
Pry.config.pager = false
Pry.config.history.file = "~/.pry_history"
if defined?(PryByebug)
Pry.commands.alias_command 'cc', 'continue'
Pry.commands.alias_command 'ss', 'step'
Pry.commands.alias_command 'nn', 'next'
Pry.commands.alias_command 'ff', 'finish'
Pry.commands.alias_command 'bb', 'break'