Skip to content

Instantly share code, notes, and snippets.

@ambar
ambar / about.md
Last active Jan 29, 2021
deep merge
View about.md

Comparison

name immutable concat dedupe clone multiple parameters recommended
merge-deep@3.0.2 true true true true yes yes
deepmerge@3.0.0 true true false false(option) no
lodash/mege false false false true yes
lodash/megeWith false false false true yes yes
View parseGBKQueryString.js
const iconv = require('iconv-lite')
const querystring = require('querystring')
const parseGBKQueryString = string => {
return querystring.parse(string, null, null, {
decodeURIComponent: v => {
return iconv.decode(Array.from(unescape(v)).map(c => c.codePointAt()), 'gbk')
}
})
}
@ambar
ambar / aes.js
Last active Feb 7, 2018
web crypto for AES-CBC
View aes.js
const atos = a =>
Array.from(a)
.map(c => String.fromCodePoint(c))
.join('')
const stoa = s => Array.from(s).map(c => c.codePointAt())
const createAes = (keyString, ivString) => {
const keyUtf8 = new TextEncoder().encode(keyString)
const ivUtf8 = new TextEncoder().encode(ivString)
@ambar
ambar / FractionalBorder.css
Last active Feb 6, 2017
fractional border
View FractionalBorder.css
:root {
/* 顶部极细边框(白色背景使用) */
--topLightFractionalBorder {
border-top: 1px solid #eee;
border-image-source: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1' height='1'><rect width='1' height='.5' fill='#eee'/></svg>");
border-image-slice: 1 0 0;
}
/* 底部极细边框(白色背景使用) */
--bottomLightFractionalBorder {
@ambar
ambar / babel.sh
Last active Nov 30, 2015
source map bug:`serve -p 3000`
View babel.sh
cp ./foo.es ./foo.js
babel ./foo.js --preset es2015 --source-maps inline -o ./foo.js
View mixin.scss
@mixin with-hash-padding($padding: 200px) {
&:before {
display: block;
content: " ";
margin-top: -$padding;
height: $padding;
visibility: hidden;
}
}
@ambar
ambar / schedules.json
Created Jun 1, 2014
2014 FIFA World Cup Schedule
View schedules.json
[
{
"date": "2014-06-12",
"matches": [
{
"localDatetime": "12 Jun 2014 - 17:00",
"matchnum": "Match 1",
"group": "Group A",
"location": {
"stadium": "Arena de Sao Paulo",
@ambar
ambar / nospm.user.js
Last active Jun 5, 2020
nospm 移除虾米、淘宝和天猫网址中的 spm 参数(包括地址栏和页面中的链接):https://chrome.google.com/webstore/detail/nospm/dlkfdpdjhnonlhjhelnfaninbdggnkgl
View nospm.user.js
// ==UserScript==
// @name nospm
// @version 1.1
// @description 移除虾米、淘宝和天猫网址中的 spm 参数(包括地址栏和页面中的链接)
// @include *://*.xiami.com/*
// @include *://*.taobao.com/*
// @include *://*.tmall.com/*
// ==/UserScript==
let forEach = Function.call.bind([].forEach)
@ambar
ambar / mac-arabic-fix.css
Last active Dec 22, 2015
Mac/iOS arabic crash bug
View mac-arabic-fix.css
@font-face {
font-family: 'Helvetica Neue';
unicode-range: U+0600—06FF, U+0750—077F, U+08A0—08FF, U+FB50—FDFF, U+FE70—FEFF, U+10E60—10E7F, U+1EE00—1EEFF;
src: local(Arial);
}
@font-face {
font-family: 'Helvetica Neue';
font-weight: bold;
unicode-range: U+0600—06FF, U+0750—077F, U+08A0—08FF, U+FB50—FDFF, U+FE70—FEFF, U+10E60—10E7F, U+1EE00—1EEFF;
src: local(Arial);
@ambar
ambar / openinapp.js
Created Apr 25, 2013
OpenInApp, from instagram
View openinapp.js
var exports = //
exports.protocal = 'zhihu://'
exports.applink = 'http://itunes.apple.com/cn/app/id432274380'
/**
* 尝试在 zhihu iPhone App 中打开链接
* @param {string} url
*/