Skip to content

Instantly share code, notes, and snippets.

@seeliang
seeliang / storybook-main.js
Created January 19, 2022 23:05
add ts node module support for storybook
module.exports = {
...settings
webpackFinal: async (config) => {
const update = config
update.module.rules.push({
test: /\.(ts|tsx)$/,
loader: 'ts-loader',
include: /node_modules/,
options: {
@seeliang
seeliang / convert-ejs-to-html.js
Last active September 1, 2023 16:09
use node to generate html from ejs file
const ejs = require('ejs');
const fs = require('fs');
module.exports = ({template, config}) => {
fs.readFile(template, 'utf8', (err, data) => {
if (err) { console.log(err); return false; }
var ejs_string = data,
template = ejs.compile(ejs_string),
html = template(config);
fs.writeFile(template.replace('.ejs', '') + '.html', html, (err) => {
if(err) { console.log(err); return false }
@seeliang
seeliang / runScriptBasedOnGitChange.sh
Created July 20, 2020 07:46
Run script based on git diff and path
if ! git diff-index --quiet --relative=src HEAD^; # with compare git diff target (HEAD^) and path (src)
then
echo has change;
# run
else
echo no change
fi
@seeliang
seeliang / Checkout-files-from-different-repo.MD
Created July 9, 2020 23:52
checkout files from different repo

add remote

git add remote-name remote-git-url

fetch

git fetch remote-name

checkout files

git checkout remote-name/branch-name -- path-to-folder-or-file

@seeliang
seeliang / lint-only-changed-files.MD
Last active April 10, 2024 09:44
How to lint only changed files?

find out the differences

use git diff to generate file list

git diff --name-only master

limited to certain file types

add ext filter

@seeliang
seeliang / write-more-readable-code-in-angular-1.md
Last active January 27, 2019 22:58
Write more readable code in angular 1 with state, controllerAs, and presentational and container structure

Write more readable code in angular 1

For the last few years, I have been working with Angular frame work for different products. Here are some solutions that benefit me in my maintaining progress Angular 1 code.

Use controllerAs instead of $scope for directives

By default, all the functions in directive are hooking with $scope. As long as the functions are inside the directive scope in HTML, the app would be functional.

// sample.js
var sample = () => {
@seeliang
seeliang / flat-structure-with-bem-smaccs.md
Last active September 18, 2020 01:13
Scalable styling with flat structure and bem/smacss

Scalable styling with flat structure and BEM/SMACSS

Scalability of the code has become a major requirement for web development recently. In css development, scalability could be achieve with flat structure and BEM/SMACSS on top of Atom design and Style composition.

The concept of flat structure and BEM/SMACCS maybe alien to developers are working with inheritance styling code. but with overwhelming benefit, this scalable solution has be adopted by some advanced developers.

Flat structure

Here is a quick explanation why flat structure is a better solution for managing scalable development. To implement flat structure, component styling shall be equally treaded by two factors:

  • Selector: by class and class only
  • Level of selector: only base level selector, which means some css selecting rules like nesting and sibling shall be avoid.
@seeliang
seeliang / implementation-of-atmoic-design.md
Last active January 6, 2019 09:54
Implementation of atomic design

Implementation of Atomic design

After spending a little more than a decade, and had worked with vast variety products and projects, personally, I think atomic design be a prefect fit for scalable / long-term development.

To avoid wast your time, I would to address that atomic design implementation could be a overkill for known short term projects (less than 6 months), as I mentioned before frameworks like bootstrap and foundation would do just fine

Implementation

Great, you are still reading.

In short, the implementation is a sorting process: Sorting components based on its atomic category.

@seeliang
seeliang / Style-composition.md
Last active July 16, 2021 00:42
Style composition, the better way to organise your styling

Find me on medium

https://seeliang.medium.com

Style composition

Back in the good old days, when I started my career, styling was easy. You put framework on, modify a bit, all done. For short term projects, not a problem.

When I switched to building product / service, this approach led to large amount of technical debits in many cases