Skip to content

Instantly share code, notes, and snippets.

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

Joseph cheng indiejoseph

🏠
Working from home
View GitHub Profile
ffmpeg -i /Users/josephcheng/Downloads/background.webm -g 1 -vf scale=-1:1080 /Users/josephcheng/Downloads/background-1080.mp4
api:product currSessionID: 31b6a286-fdfb-41bd-8046-c690aeb360e7c1afee23-f160- +0ms
api:product currSessionID: 6142c5bc-3b9f-4af3-88cf-c4d01065efee995ebea8-b8e8- +12ms
api:product currSessionID: 2dc8921c-414a-409a-a111-7663a8cd98bf53a5133f-5ec2- +10ms
api:product isNewProduct true +524ms
(node:2474865) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
api:product isNewProduct true +22ms
api:product isNewProduct true +151ms
api:product shopifyProduct: {
api:product id: 7412675412142,
api:product title: 'Ralph Lauren Long Sleeve Polo 5T',
@indiejoseph
indiejoseph / extensions.json
Last active September 5, 2021 08:18
VSCode extension recommendations
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker"
]
}
@indiejoseph
indiejoseph / update_ip.sh
Created August 19, 2021 03:15
auto whitelist local ip into AWS security group
#!/bin/bash
# script to pull my current public IP address
# and add a rule to my EC2 security group allowing me SSH access
curl v4.ifconfig.co/ip > ip.txt
awk '{ print $0 "/32" }' < ip.txt > ipnew.txt
export stuff=$(cat ipnew.txt)
aws ec2 authorize-security-group-ingress --group-name NewGroup \
--protocol tcp --port 22 --cidr $stuff
const usePrevious = <T extends Record<string, any>>(value: T, initialValue: T) => {
const ref = useRef(initialValue);
useEffect(() => {
ref.current = value;
});
return ref.current;
};
#!/usr/bin/env bash
function git {
docker run -it --rm \
-v ~/.ssh:/root/.ssh \
-v /`pwd`:/root/work \
-w /root/work \
bryandollery/alpine-git git \
-c "user.email=$(grep email ~/.gitconfig | cut -d '=' -f2 | xargs)" \
-c "user.name=$(grep name ~/.gitconfig | cut -d '=' -f2 | xargs)" \
<!-- Begin Mailchimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
/* Add your own Mailchimp form style overrides in your site stylesheet or in this style block.
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
<form action="https://legal.us6.list-manage.com/subscribe/post?u=1a8d923a091bd6071c599223d&amp;id=9039fb33fb" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
@indiejoseph
indiejoseph / machine.js
Last active September 15, 2020 09:50
Generated by XState Viz: https://xstate.js.org/viz
const taskMachine = Machine({
id: 'task',
initial: 'open',
context: {
applied: 0,
},
states: {
open: {
on: {
CREATE_APPLICATION: 'application',
@indiejoseph
indiejoseph / fullstack_dev_test.md
Last active August 30, 2021 17:44
Fullstack Developer Test

Fullstack Developer Test

The goal of this test is to evaluate your ability to architecture a small full-stack NodeJS app.

Instruction

The app you need to build is a small admin page. The initial dataset is dummy user profiles on dummyapi.io.

The app is comprised of 2 parts:

The node backend, responsible for handle API request:

@indiejoseph
indiejoseph / getYearByMonthDateAndWeekday.js
Created August 2, 2020 15:23
Find a possible years for the given month date and weekday
function getYearByMonthDateAndWeekday (month, date, weekday) {
const now = new Date();
const startYear = 2013;
const endYear = now.getFullYear();
const possibleYears = Array.from(new Array((endYear - startYear) + 1)).map((_, i) => startYear + i).sort((a, b) => b - a);
const validYears = possibleYears.filter((year) => {
const thisYear = new Date(year, month - 1, date);
return thisYear.getDay() === weekday;