Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Sunny Chan sunnycmf

🎯
Focusing
View GitHub Profile
@sunnycmf
sunnycmf / pass.js
Created Aug 21, 2013
node-passbook missing private key input.
View pass.js
// Signs a manifest and returns the signature.
function signManifest(template, manifest, callback) {
var identifier = template.passTypeIdentifier().replace(/^pass./, "");
var args = [
"smime",
"-sign", "-binary",
"-signer", Path.resolve(template.keysPath, identifier + ".pem"),
"-certfile", Path.resolve(template.keysPath, "wwdr.pem"),
"-inkey", Path.resolve(template.keysPath, "key.pem"),
"-passin", "pass:" + template.password
@sunnycmf
sunnycmf / gist:6291351
Created Aug 21, 2013
iOS passbook signing sh.
View gist:6291351
openssl pkcs12 -passin pass:"somepass" -in "mycert.p12" -clcerts -nokeys -out certificate.pem
openssl pkcs12 -passin pass:"somepass" -in "mycert.p12" -nocerts -out key.pem -passout pass:"somepass"
openssl smime -binary -sign -certfile WWDR.pem -signer certificate.pem -inkey key.pem -in manifest.json -out signature -outform DER -passin pass:"somepass"
View Responsive-Flat-UI-Kit.markdown

Responsive Flat UI Kit

A custom UI set built to work with and sit next to Bootstrap 3. Custom select boxes by @catalinred. 3D Scroll effects inspired by @chriscoyier's slide in when scroll down pen. The kit is also responsive!

Try clicking & hovering everything.

Feel free to fork, heart and share!

A Pen by Matt Litherland on CodePen.

@sunnycmf
sunnycmf / export defining stategrey.js
Last active Mar 17, 2016
whats' the different between module.export VS exports.<method_name>
View export defining stategrey.js
var ErrorLog = common.mongoose.model('ErrorLog', schema);
// differences of line 4 vs 5?
exports = module.exports = ErrorLog;
exports.ErrorLog = ErrorLog;
View img2data.js
/*
* Based on https://gist.github.com/583836 from http://stackoverflow.com/questions/3709391/node-js-base64-encode-a-downloaded-image-for-use-in-data-uri.
* Neither that gist nor this one work for me in 0.2.x or 0.3.x.
*/
var request = require('request'),
BufferList = require('bufferlist').BufferList,
sys = require('sys'),
bl = new BufferList(),
url = 'http://nodejs.org/logo.png'
;
@sunnycmf
sunnycmf / node_image_resize_to_s3.js
Created Feb 17, 2014 — forked from simenbrekken/uploader.js
nodejs - image resize using magick to AWS S3
View node_image_resize_to_s3.js
var spawn = require('child_process').spawn,
aws2js = require('aws2js'),
http = require('http'),
urlutil = require('url')
mime = require('mime'),
Buffers = require('buffers');
var settings = {
s3: {
key: 'key',
@sunnycmf
sunnycmf / calc_file_checksum
Created Feb 18, 2014 — forked from guybrush/gist:721762
calculate a file sha1 checksum
View calc_file_checksum
#!/usr/bin/env node
require('fs').readFile('image.png',function(err, data){
console.log(require('crypto').createHash('sha1').update(data).digest('hex'))
})
View StreamingResponse.coffee
zipstream = require "zipstream"
fs = require "fs"
async = require "async"
class StreamingResponse
filename: ""
files: []
streaming: true
###
View style_guide.md

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

View gist:9175797
<?php
class PassAPI extends Plugin
{
# Registration
# register a device to receive push notifications for a pass
#
# POST /v1/devices/<deviceID>/registrations/<typeID>/<serial#>
# Header: Authorization: ApplePass <authenticationToken>
# JSON payload: { "pushToken" : <push token, which the server needs to send push notifications to this device> }
#
You can’t perform that action at this time.