View encrypt-decrypt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const crypto = require('crypto') | |
const key = 'salt_from_the_user_document' | |
const plaintext = '56d008a27c36552a0f97b291' | |
const cipher = crypto.createCipher('aes-256-cbc', key) | |
const decipher = crypto.createDecipher('aes-256-cbc', key) | |
let encryptedPassword = cipher.update(plaintext, 'utf8', 'base64') | |
encryptedPassword += cipher.final('base64') |
View .eslintrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"parserOptions": { | |
"ecmaVersion": 6 | |
}, | |
"env": { | |
"es6": true, | |
"node": true | |
}, |
View stack-loader.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const addtionalExts = [] | |
const fs = require('fs') | |
const path = require('path') | |
function find (root, p, re, recursive) { | |
if (root) { | |
p = path.resolve(root, p) | |
} |
View wechat-fluid-badge.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setInterval(updateDockBadge, 500) | |
function updateDockBadge() { | |
var dots = document.querySelectorAll('.nav_view .chat_item .avatar .web_wechat_reddot_middle') | |
var badge = [].reduce.call(dots, function(pv, cv) { | |
var badge = Math.floor(cv.textContent) | |
if (isNaN(badge)) { | |
return 0 |
View progress-bar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProgressBar { | |
constructor (viewSize) { | |
this.viewSize = viewSize | |
this.circleStrokeColor = '#249fff' | |
this.circleStrokeWidth = 5 | |
this.circleFillColor = 'transparent' | |
let svg = this.svg = this.createSVG() | |
svg.setAttribute('width', viewSize) |
View safeApply.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myApp', []) | |
.run(function ($rootScope, $exceptionHandler) { | |
$rootScope.$safeApply = function (exp) { | |
var phase = (this.$root || this).$$phase | |
if (phase !== '$apply' && phase !== '$digest') { | |
this.$apply(exp) | |
} else { | |
try { | |
this.$eval(exp) | |
} catch (ex) { |
View console.trace.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/6715571/how-to-get-result-of-console-trace-as-string-in-javascript-with-chrome-or-fire | |
function getStackTrace () { | |
var obj = {} | |
// Remove arguments.callee from trace list | |
Error.captureStackTrace(obj, getStackTrace) | |
return obj.stack | |
} | |
console.log(getStackTrace()) |
View tower
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -x "/Applications/Tower.app" ] || [ -x "$HOME/Applications/Tower.app" ]; then | |
tower="Tower" | |
else | |
echo "Tower not found!" | |
exit 2 | |
fi | |
if [ -z "$1" ]; then |
View iojs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
if [ -d "$(brew --prefix)/Cellar" ]; then | |
node=`find /usr/local/Cellar -name node | grep iojs/.*/bin/node` | |
if [ ! -z "$node" ]; then | |
$node $@ | |
else | |
echo "io.js not installed" | |
fi | |
else |
View who_uses_my_ports.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo lsof -i -P | grep -i "listen" |