Skip to content

Instantly share code, notes, and snippets.

View ArvinH's full-sized avatar
🏠
Working from home

Huang Shuo-Han ArvinH

🏠
Working from home
View GitHub Profile
@ArvinH
ArvinH / javascript-proxy-as-rest-client.js
Created February 19, 2022 02:45 — forked from DavidWells/javascript-proxy-as-rest-client.js
Using a javascript proxy as low code REST client
/* Using a JavaScript proxy for a super low code REST client */
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3
// also see https://github.com/fastify/manifetch
// also see https://github.com/flash-oss/allserver
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const createApi = (url) => {
return new Proxy({}, {
get(target, key) {
@ArvinH
ArvinH / react-rollup-typescript.md
Created October 23, 2021 13:54 — forked from bcherny/react-rollup-typescript.md
react + rollup + typescript boilerplate

terminal:

npm i --save-dev rollup rollup-watch rollup-plugin-typescript typescript typings
npm i -S react react-dom
./node_modules/.bin/typings install react react-dom --save
mkdir src dist
touch src/index.tsx
@ArvinH
ArvinH / geonames_cities_100k.geojson
Created September 8, 2019 15:12
geojson file geonames_cities_100k
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ArvinH
ArvinH / curl.js
Created January 20, 2019 05:09 — forked from schamane/curl.js
Curl vs http module for nodejs
var exec = require('child_process').exec,
url = "http://google.com/",
timeout = "3",
data="?q=test";
var time = process.hrtime();
exec('curl --max-time ' + timeout + ' -d \'' + data + '\' ' + url, function (error, stdout, stderr) {
var diff = process.hrtime(time);
//console.log('stdout: ' + stdout);
//console.log('stderr: ' + stderr);
@ArvinH
ArvinH / fetchCalendarData.js
Created December 15, 2018 15:44
2018-12-15 fetch calendar data through google api v3
const fs = require('fs');
const readline = require('readline');
const { google } = require('googleapis');
// If modifying these scopes, delete token.json.
const SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
// The file token.json stores the user's access and refresh tokens, and is
// created automatically when the authorization flow completes for the first
// time.
const TOKEN_PATH = 'token.json';
@ArvinH
ArvinH / vimeo-python-serversample.py
Created April 14, 2018 08:04
Sample code for handling vimeo api in python server
from flask import Flask, Blueprint, request, current_app, jsonify
import requests
import json
video_blueprint = Blueprint(
'video',
__name__
)
@ArvinH
ArvinH / READ.md
Last active March 27, 2018 16:19
titanic
chrome.runtime.onMessage.addListener(gotMessage)
function gotMessage(message, sender, sendResponse){
let direction = 0;
if(message.direction == 'up'){
direction = -500;
} else if(message.direction == 'down'){
direction = +500;
} else if (message.direction == 'turn off') {
const mask = document.getElementById('body-maskDiv');
if (mask) {
console.log('popup ready!');
let startPredicting = false;
let times = 0;
let y = 0;
document.addEventListener('DOMContentLoaded', function() {
let video = document.getElementById('video');
let still = document.getElementById('still');
@ArvinH
ArvinH / googleCalendar_nodejs_parser.js
Last active December 12, 2017 17:10
googleCalendar nodejs parser
var fs = require('fs');
var readline = require('readline');
var google = require('googleapis');
var googleAuth = require('google-auth-library');
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/calendar-nodejs-quickstart.json
var SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
var TOKEN_DIR = (process.env.HOME || process.env.HOMEPATH ||
process.env.USERPROFILE) + '/.credentials/';