Skip to content

Instantly share code, notes, and snippets.

'use strict';
class Abstract {
// A static abstract method.
static foo() {
if (this === Abstract) {
// Error Type 2. Abstract methods can not be called directly.
throw new TypeError("Can not call static abstract method foo.");
} else if (this.foo === Abstract.foo) {
// Error Type 3. The child has not implemented this method.
throw new TypeError("Please implement static abstract method foo.");
@liyu1981
liyu1981 / workchat-update.sh
Created March 12, 2019 00:11
update script for nativefier-workchat
#!/bin/bash
echo "create new version of nativefier-wrokchat"
nativefier -i ./workplace.png https://fb.workplace.com -n nativefier-workchat
if [ -d "/Applications/nativefier-workchat.app" ]; then
echo "backup..."
mv /Applications/nativefier-workchat.app ~/Desktop/nativefier-workchat-backup.app
echo "done => ~/Desktop"
fi
@liyu1981
liyu1981 / ttfb.sh
Created July 8, 2018 13:57 — forked from sandeepraju/ttfb.sh
curl command to check the time to first byte
#!/bin/bash
# file: ttfb.sh
# curl command to check the time to first byte
# ** usage **
# 1. ./ttfb.sh "https://google.com"
# 2. seq 10 | xargs -Iz ./ttfb.sh "https://google.com"
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@liyu1981
liyu1981 / fix_virtualenv
Created October 18, 2017 05:13 — forked from tevino/fix_virtualenv
Fix python virtualenv after python update
#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
echo "Ensure the root of current virtualenv:"
echo " $ENV_PATH"
read -p "‼️ Say no if you are not sure (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "♻️ Removing old symbolic links......"
@liyu1981
liyu1981 / scm-prompt.sh
Created August 9, 2017 01:12
a script to show scm-prompt in bash, support both git and hg
# Determines the "branch" of the current repo and emits it.
# For use in generating the prompt.
# This is portable to both zsh and bash and works in both
# git and mercurial repos and aims to avoid invoking the
# command line utilities for speed of prompt updates
# To use from zsh:
# NOTE! the single quotes are important; if you use double quotes
# then the prompt won't change when you chdir or checkout different
# branches!
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@liyu1981
liyu1981 / gulpfile.js
Created July 12, 2016 00:38 — forked from alkrauss48/gulpfile.js
Base gulpfile config for babel, browserify, and uglify - with sourcemaps and livereload
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var livereload = require('gulp-livereload');
@liyu1981
liyu1981 / compile.js
Last active March 18, 2016 00:32
compile script for compiling *.main.jsx into bundle of js
// usage: node compile.js src lib/Adminhtml watch
//
// following dev dependencies are needed
//
// {
// "devDependencies": {
// "babel-preset-es2015": "^6.3.13",
// "babel-preset-react": "^6.3.13",
// "babelify": "^7.2.0",
// "browserify": "^13.0.0",
@liyu1981
liyu1981 / magento-code-snippets.md
Created November 10, 2015 02:58 — forked from arosenhagen/magento-code-snippets.md
[magento] - code snippets

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name