Skip to content

Instantly share code, notes, and snippets.

View shhider's full-sized avatar

Shi Haohong shhider

  • Hangzhou / 杭州
View GitHub Profile
@shhider
shhider / browser-env.js
Created January 11, 2018 05:46
Browser environment sniffing
// source: https://github.com/vuejs/vue/blob/dev/src/core/util/env.js
export const inBrowser = typeof window !== 'undefined'
export const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform
export const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase()
export const UA = inBrowser && window.navigator.userAgent.toLowerCase()
export const isIE = UA && /msie|trident/.test(UA)
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0
export const isEdge = UA && UA.indexOf('edge/') > 0
export const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android')
export const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
aaa = u'你好'
result = ''
for i in range(len(aaa)):
item = hex(ord(aaa[i]))
item = str(item)[2:]
item = item.upper()
item = item.zfill(4)
result = result + item
print result

coffin

Jinja2 adapter for Django.

其主页表示:Please use django_jinja instead.

~#sudo apt-get install cmatrix
~# cmatrix

~# oneko

~# sl
PHANTOMJS_CDNURL=http://cnpmjs.org/downloads npm install phantomjs

understand await/async in ES7

// example
function readread (isReject) {
  return new Promise(function (resolve, reject) {
    setTimeout(() => {
      if (isReject) {
 reject('reject reject');
@shhider
shhider / disable-google-redirection.md
Last active June 28, 2022 06:39
[Tips about Google] #google

1、

@font-face {
  font-family: BASE;
  src: local('PingFang SC'),
       local("Microsoft Yahei");
}
@shhider
shhider / dirname-and-filename-in-nodejs-modules.js
Last active November 21, 2022 08:13
[paths in Node.js] #nodejs #path #__dirname #__filename
// https://stackoverflow.com/a/62892482/3676413
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);