Skip to content

Instantly share code, notes, and snippets.

@chrisyip
chrisyip / encrypt-decrypt.js
Last active July 6, 2017 12:29 — forked from adrianbravo/encrypt-decrypt.js
Basic Node.js crypto cipher/decipher example.
'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')
@chrisyip
chrisyip / fluid_gmail.js
Last active January 1, 2016 19:59 — forked from kirbysayshi/fluid_gmail.js
Gmail Unread Badge for Fluid
setTimeout(updateDockBadge, 1000)
setTimeout(updateDockBadge, 3000)
setInterval(updateDockBadge, 5000)
function updateDockBadge() {
var inboxLink = document.querySelector('a[href*="shva=1#inbox"]')
, badge = window.fluid.dockBadge
if (inboxLink && inboxLink.href && inboxLink.href.indexOf('mail.google.com') > -1) {
var match = inboxLink.title.match(/\((\d+)\)$/)
window.onload = function(){
var doc = document
, img = doc.createElement('img')
, div = doc.createElement('div')
, body = doc.getElementsByTagName('body')[0];
img.className = 'preload';
img.style.cssText = ';position:absolute;top:-999em;left:-999em;width:0;height:0;visibility:hidden;';
// ajax loaded or predefined img list
var arr = imgList
, str