Skip to content

Instantly share code, notes, and snippets.

View tomchentw's full-sized avatar

Tom Chen tomchentw

View GitHub Profile
@tomchentw
tomchentw / cmd.sh
Last active December 26, 2022 05:58
ffmpeg + magic
# Save poster at 1s to out.heic
ffmpeg -ss 00:00:01 -i input.mp4 -frames:v 1 -q:v 5 -f image2pipe - | magick - out.heic
# to h265
ffmpeg -i input.mp4 -c:v libx265 out.mov
# to h264
ffmpeg -i input.mp4 -c:v libx264 out.mov
# Save to h265 with poster
module.exports = {
components: {
Button: {
// 1. We can update the base styles
baseStyle: {
fontWeight: "bold", // Normally, it is "semibold"
},
// 2. We can add a new button size or extend existing
sizes: {
xs: {
@tomchentw
tomchentw / main.css
Created July 17, 2020 08:17
@chakra-ui/core v0.8.0 <CSSReset /> in CSS
/* https://github.com/chakra-ui/chakra-ui/blob/%40chakra-ui/core%400.8.0/packages/chakra-ui/src/CSSReset/preflight.js */
html {
line-height: 1.15;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
@tomchentw
tomchentw / README.md
Last active March 2, 2022 07:42
Auto compress images with husky, lint-staged and imagemin

The flow

husky (setup git commit hooks) -> lint-stages (run specific commands by file type) -> imagemin (minify files)

git add -A
git commit # It will compress your images into git repo now

Since the images is now fully compressed, no extra steps is required by webpack/browserify……whatever.

@tomchentw
tomchentw / fib-y-comb.js
Last active May 23, 2016 01:57
YCombinator
const genFib = f => n => {
if (n <= 1) return 1;
return f(n - 1) + f(n - 2);
};
const fib = someFunc(genFib);
/*
* Above fib is the result we want. But we don't know HOW to implement someFunc
*/
// From Line 6, we know someFunc is a function that will return fib, with a parameter genFib passed in
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<base data-reacthtmlpack-inject-props="server.head.base" data-reacthtmlpack-inject-method="replaceWith">
<title data-reacthtmlpack-inject-props="server.head.title" data-reacthtmlpack-inject-method="replaceWith"></title>
<meta data-reacthtmlpack-inject-props="server.head.meta" data-reacthtmlpack-inject-method="replaceWith">
<link rel="stylesheet" data-reacthtmlpack-extract-text-from-module-name="./client.js">
npm set registry http://192.168.1.1:5080 # Use local-npm. See https://www.npmjs.com/package/local-npm
npm set progress=true
rm -rf node_modules
time npm install
> npm install 86.04s user 12.47s system 95% cpu 1:42.81 total
npm set progress=false
rm -rf node_modules
time npm install
@tomchentw
tomchentw / Preferences.sublime-settings
Created January 23, 2016 02:57
Preferences.sublime-settings
{
"font_size": 19,
"ignored_packages":
[
"Vintage"
],
"rulers":
[
80,
100
@tomchentw
tomchentw / lodash-flat.js
Created October 27, 2015 04:39
Benchmark fixtures with flat modules bundle. See https://github.com/tomchentw/babelpack#result-on-my-computer
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.lodash = f()}})(function(){var define,module,exports;
"use strict";
// ------
// ------
// ------BEGIN---/Users/tomchentw/repos/babelpack/node_modules/lodash-es/internal/baseSlice.js------
var __7e600992d2d71e95f9c6b584a58a1ef1483087df__module__baseSlice = {};
/**
* The base implementation of `_.slice` without an iteratee call guard.
*
* @private
@tomchentw
tomchentw / 7__ForumPostPageView.js
Last active August 29, 2015 14:27
Redux-Universal - Code Sections - 7
// http://git.io/v3OsP
render () {
// access forum and posts from this.props (it’s a dumb component!)
const {params, forum, posts} = this.props;
return (
<div>
<header className="forum__header">
<h2 className="forum__title">{forum.get("title")}</h2>
</header>