Skip to content

Instantly share code, notes, and snippets.

Avatar
🎮

Chris Yip chrisyip

🎮
View GitHub Profile
View offscreen_preload.js
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
@chrisyip
chrisyip / fluid_gmail.js
Last active Jan 1, 2016 — forked from kirbysayshi/fluid_gmail.js
Gmail Unread Badge for Fluid
View fluid_gmail.js
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+)\)$/)
@chrisyip
chrisyip / encrypt-decrypt.js
Last active Jul 6, 2017 — forked from adrianbravo/encrypt-decrypt.js
Basic Node.js crypto cipher/decipher example.
View encrypt-decrypt.js
'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')