Skip to content

Instantly share code, notes, and snippets.

View sunnycmf's full-sized avatar
🎯
Focusing

Sunny Chan sunnycmf

🎯
Focusing
  • Carousell
  • Hong Kong
View GitHub Profile
@sunnycmf
sunnycmf / apache-useful-online.md
Last active August 29, 2015 13:57
apache useful online tool
@sunnycmf
sunnycmf / escape.js
Last active August 29, 2015 13:56
trying to escape all chars from an input file
var fs = require('fs');
fs.readFile('testing.txt', {encoding:'utf8'}, function (err, data) {
if (err) throw err;
console.log('orig:\n' + data);
console.log('\n\n\nafter JSON.stringify:\n' + JSON.stringify(data));
console.log('\n\n\nafter JSON.stringify escapeSpecialChars() :\n' + JSON.stringify(data).escapeSpecialChars());
});
String.prototype.escapeSpecialChars = function() {
return this.replace(/\\n/g, "\\n").replace(/\\'/g, "\\'").replace(/\\"/g, '\\"').replace(/\\&/g, "\\&").replace(/\\r/g, "\\r").replace(/\\t/g, "\\t").replace(/\\b/g, "\\b").replace(/\\f/g, "\\f");
<?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> }
#

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.

zipstream = require "zipstream"
fs = require "fs"
async = require "async"
class StreamingResponse
filename: ""
files: []
streaming: true
###
@sunnycmf
sunnycmf / calc_file_checksum
Created February 18, 2014 02:25 — forked from guybrush/gist:721762
calculate a file sha1 checksum
#!/usr/bin/env node
require('fs').readFile('image.png',function(err, data){
console.log(require('crypto').createHash('sha1').update(data).digest('hex'))
})
@sunnycmf
sunnycmf / node_image_resize_to_s3.js
Created February 17, 2014 16:29 — forked from simenbrekken/uploader.js
nodejs - image resize using magick to AWS S3
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 / img2data.js
Created February 17, 2014 15:50 — forked from jfsiii/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 / export defining stategrey.js
Last active March 17, 2016 09:04
whats' the different between module.export VS exports.<method_name>
var ErrorLog = common.mongoose.model('ErrorLog', schema);
// differences of line 4 vs 5?
exports = module.exports = ErrorLog;
exports.ErrorLog = ErrorLog;

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.