Skip to content

Instantly share code, notes, and snippets.

View samzeng's full-sized avatar

Sam Zeng samzeng

View GitHub Profile
@iridiumcao
iridiumcao / check_git_branch_exists.sh
Created March 22, 2020 13:57
How to check if a git branch exists in the local/remote repository?
# Local:
# https://stackoverflow.com/questions/21151178/shell-script-to-check-if-specified-git-branch-exists
# test if the branch is in the local repository.
# return 1 if the branch exists in the local, or 0 if not.
function is_in_local() {
local branch=${1}
local existed_in_local=$(git branch --list ${branch})
if [[ -z ${existed_in_local} ]]; then
echo 0
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
function dec2hex(dec, padding){
return parseInt(dec, 10).toString(16).padStart(padding, '0');
}
function utf8StringToUtf16String(str) {
var utf16 = [];
@ejlofgren
ejlofgren / snippet of package.json scripts
Last active December 14, 2021 11:43
Sample Split Vue Config Files
"scripts": {
"serve": "vue-cli-service serve",
"buildAdmin": "vue-cli-service build --dest dist/admin src/entries/admin_app_entry.js",
"buildMain": "vue-cli-service build --dest dist/public src/entries/main_app_entry.js",
"lint": "vue-cli-service lint"
},
@romainl
romainl / grep.md
Last active November 3, 2024 17:56
Instant grep + quickfix

FOREWORDS

I don't mean the snippet at the bottom of this gist to be a generic plug-n-play solution to your search needs. It is very likely to not work for you or even break things, and it certainly is not as extensively tested and genericised as your regular third-party plugin.

My goal, here and in most of my posts, is to show how Vim's features can be leveraged to build your own high-level, low-maintenance, workflows without systematically jumping on the plugins bandwagon or twisting Vim's arm.


Instant grep + quickfix

@roustem
roustem / Setting-up-Windows-WSL1.md
Last active February 25, 2024 07:12
Setting-up-Windows-WSL1
@ericbn
ericbn / .vimrc
Last active October 12, 2024 07:35
Vim Powerline-like status line without the need of any plugin
" Statusline (requires Powerline font)
set statusline=
set statusline+=%(%{&buflisted?bufnr('%'):''}\ \ %)
set statusline+=%< " Truncate line here
set statusline+=%f\ " File path, as typed or relative to current directory
set statusline+=%{&modified?'+\ ':''}
set statusline+=%{&readonly?'\ ':''}
set statusline+=%= " Separation point between left and right aligned items
set statusline+=\ %{&filetype!=#''?&filetype:'none'}
set statusline+=%(\ %{(&bomb\|\|&fileencoding!~#'^$\\\|utf-8'?'\ '.&fileencoding.(&bomb?'-bom':''):'')
@Hwangss
Hwangss / export.scss
Created October 15, 2015 08:15
Sass 'require' Solution
$imported-modules : () !default;
// The cache has been introduced to ensure that no duplicate references are guaranteed.
// @param {String} $name - Name of exported module.
// Recommended content and file name as same, if you want to import a file.
// for example : @inculde export('_reset') { @import '_reset'; }
@mixin export($name) {
@if (index($imported-modules, $name) == null) {
$imported-modules: append($imported-modules, $name) !global;
@jason5ng32
jason5ng32 / surge.conf
Last active November 6, 2024 06:39
Surge Configs ( for 2.x )
[General]
loglevel = notify
skip-proxy = 127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, localhost, *.local, ::ffff:0:0:0:0/1, ::ffff:128:0:0:0/1
bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12
# dns-server = 119.29.29.29,223.5.5.5,114.114.115.115
# external-controller-access = [email protected]:6155
# ipv6 = true
// REMEMBER TO CHANGE THE external-controller-access' PASSWORD
@paulirish
paulirish / what-forces-layout.md
Last active November 15, 2024 16:45
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a