Skip to content

Instantly share code, notes, and snippets.

@hiiamyes
hiiamyes / handler.js
Created December 30, 2020 15:58
image-resizer
"use strict";
const aws = require("aws-sdk");
const jimp = require("jimp");
const s3 = new aws.S3(
process.env.ENV === "production"
? {
apiVersion: "2006-03-01",
}
: {
apiVersion: "2006-03-01",
@hiiamyes
hiiamyes / national-park-captcha-tesseract.js
Created April 5, 2020 12:27
national-park-captcha-tesseract
const { createWorker } = require("tesseract.js");
const fs = require("fs");
const path = require("path");
const worker = createWorker();
const log = console.log;
(async () => {
await worker.load();
await worker.loadLanguage("eng");
@hiiamyes
hiiamyes / with-credentials.conf
Last active March 5, 2020 17:06
Nginx CORS proxy
server {
listen 3003;
server_name localhost;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, Cache-Control, Cookie, If-Modified-Since, Range, User-Agent, X-Requested-With';
@hiiamyes
hiiamyes / apply-yushan-front-peak.js
Created February 22, 2020 14:17
apply-yushan-front-peak
const chalk = require("chalk");
const readlineSync = require("readline-sync");
const puppeteer = require("puppeteer");
const log = console.log;
const itinerary = {
date: "109-02-28",
nodes: ["塔塔加登山口", "玉山前峰", "塔塔加登山口"],
};
const applicant = {
@hiiamyes
hiiamyes / hello.md
Last active July 29, 2024 08:37
Nice to meet you!
@hiiamyes
hiiamyes / f2e-interview-question.md
Last active June 17, 2019 04:58 — forked from duncan60/F2E interview question
F2E interview question

CSS

  1. What is CSS BEM?

Haven't used BEM before, but as I know, it's a class name naming convension, for better managing css code.

  1. What is the difference between em and rem units?
  • em: Representing relative font-size, relative to parent element.
  • rem: root em, representing relative font-size, but only relative to root element (``).
@hiiamyes
hiiamyes / getTimezoneNames.sh
Last active June 2, 2019 08:13
getTimezoneNames.sh
#!/bin/bash
# Install wget and jq if you don't have it.
# Mac: brew install jq wget
# Linux: TBD
mkdir tzdb
cd tzdb
wget https://www.iana.org/time-zones/repository/tzcode-latest.tar.gz
wget https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz
gzip -dc tzcode-latest.tar.gz | tar -xf -
gzip -dc tzdata-latest.tar.gz | tar -xf -
@hiiamyes
hiiamyes / getLatestTag.sh
Created May 18, 2019 09:39
Shell Script and Github API: Get Latest Tag on a Branch
token="my_personal_access_token"
base_url="https://api.github.com"
list_branches_url="/repos/hiiamyes/github-api-test/branches"
list_commites_url="/repos/hiiamyes/github-api-test/commits"
list_tags_url="/repos/emq-inc/emq-adminsite/tags"
headers="Authorization: token $token"
commit_sha=$(
curl \
--silent $base_url$list_branches_url/sprint \
-H "$headers" |
@hiiamyes
hiiamyes / getBuildNumber.sh
Created May 17, 2019 04:27
get build number
# brew install jq
#!/bin/sh
commit_sha=$(curl -s "https://api.github.com/repos/hiiamyes/repo/branches/develop" \
-H 'Authorization: token {token}' |
jq -r '.commit.sha')
tag_name=$(curl -s "https://api.github.com/repos/hiiamyes/repo/tags" \
-H 'Authorization: token {token}' |
jq -r --arg commit_sha $commit_sha '.[] | select(.commit.sha == $commit_sha) | .name')
build_number=${tag_name/build-/}
build_number=${build_number/.1/}
@hiiamyes
hiiamyes / jira-daily-standup.js
Last active April 26, 2019 10:04
jira-daily-standup.js
const axios = require("axios");
(async () => {
const assignee = "yes",
username = "",
password = "";
const res = await axios.request({
url: "https://emq-inc.atlassian.net/rest/api/3/search",
method: "post",