Skip to content

Instantly share code, notes, and snippets.

@haipeng
haipeng / README.md
Created November 25, 2021 08:45 — forked from qti3e/README.md
List of file signatures and mime types based on file extensions
@haipeng
haipeng / Common-Currency.json
Created March 12, 2021 03:13 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@haipeng
haipeng / extract-source-from-source-map.ts
Created December 17, 2020 08:51 — forked from banyudu/extract-source-from-source-map.ts
Extract source code from source map
#!/usr/bin/env ts-node
import * as fs from 'fs'
import * as path from 'path'
import { promisify } from 'util'
import { SourceMapConsumer } from 'source-map'
const writeFile = promisify(fs.writeFile)
const mapFile = process.argv[2]
@haipeng
haipeng / simple_args_parsing.sh
Created September 28, 2018 02:35 — forked from jehiah/simple_args_parsing.sh
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
#!/usr/bin/env bash
set -e
pcre_version="8.42"
zlib_version="1.2.11"
openssl_version="1.0.2n"
nginx_version="1.12.2"
source_path=/usr/local/src
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++
@haipeng
haipeng / capitalize.js
Last active April 8, 2018 03:16
capitalize
function capitalize (word) {
return (word || '').replace(/^([a-z])/, w => w.toUpperCase());
}
@haipeng
haipeng / makeMap.js
Created September 27, 2017 02:51
根据字符串、字符串数组创建map
/**
* 根据字符串、字符串数组创建map
* @param {String|Array<String>} items
* @param {String|RegExp} delimiter 默认值/\s+/
* @param {Object} [map]
* @returns {{*}}
*/
var makeMap = function (items, delimiter, map) {
items = items || [];
if (typeof items === 'string') {
@haipeng
haipeng / .gitignore
Last active September 18, 2017 07:10
git global ignore
# Node
npm-debug.log
node_modules
# Mac
.DS_Store
# Windows
Thumbs.db
@haipeng
haipeng / git-alias.sh
Created September 16, 2017 08:17
git alias
#!/bin/bash
git config --global alias.a add
git config --global alias.b branch
git config --global alias.br branch
git config --global alias.c commit
git config --global alias.ci commit
git config --global alias.d diff
git config --global alias.f fetch
git config --global alias.g grep
git config --global alias.l log
var updateUrlQuery = function(url, key, value) {
var query = key + '=' + value;
var search = '';
var hash = '';
var hashIndex = url.indexOf('#');
if (hashIndex > -1) {
hash = url.substring(hashIndex);
url = url.substring(0, hashIndex);
}