Skip to content

Instantly share code, notes, and snippets.

View yuchen's full-sized avatar
🌴
On vacation

clark yuchen

🌴
On vacation
  • china, shanghai
  • 16:14 (UTC +08:00)
View GitHub Profile
@yuchen
yuchen / app.js
Created August 20, 2014 01:07 — forked from branneman/app.js
#!/usr/bin/env node
'use strict';
var spawn = require('child_process').spawn;
var args = [
'--harmony',
'app/bootstrap.js'
];
//
// SVG — hasClass, addClass, removeClass, toggleClass
// Source:
// https://gist.github.com/branneman/8436956
// Taken and adapted from:
// http://toddmotto.com/hacking-svg-traversing-with-ease-addclass-removeclass-toggleclass-functions/
//
if (SVGElement && SVGElement.prototype) {
//
// Articles controller
// Optional module description line.
//
'use strict';
var fs = require('fs');
var path = require('path');
/**
* Strict mode
* Opt in to a restricted variant of JavaScript.
*/
'use strict';
(function() { 'use strict'; });
/**
* Array.prototype.forEach()
* Executes a provided function once per array element.
@yuchen
yuchen / dump.php
Created August 20, 2014 01:08 — forked from branneman/dump.php
function dump($var) {
ob_start();
var_dump($var);
$output = ob_get_clean();
echo preg_replace("/=>(\s+)/m", ' => ', $output);
}
@yuchen
yuchen / event.js
Created August 20, 2014 01:08 — forked from branneman/event.js
$(function() {
var resizeEnd;
$(window).on('resize', function() {
clearTimeout(resizeEnd);
resizeEnd = setTimeout(function() {
$(window).trigger('resizeEnd');
@yuchen
yuchen / server.js
Created August 20, 2014 01:08 — forked from branneman/server.js
var fs = require('fs'),
exec = require('child_process').exec,
express = require('express'),
app = express();
app.get('/static/img/*.svg.*.png', function(req, res) {
var pngFile = 'src' + req.url,
svgFile = pngFile.substring(0, pngFile.indexOf('.svg') + 4);
if (!fs.existsSync(svgFile)) {
return res.render('404', {
//
// asyncParallel(tasks, [callback])
//
// Run an array of functions in parallel, without waiting until the previous
// function has completed. Once the tasks have completed, final callback is called.
//
// Source:
// https://gist.github.com/branneman/4541190
// Inspired by:
// https://github.com/caolan/async#parallel
@echo off
@echo This batchfile changes your password 30 times into a temporary password, and finally into your given password.
@echo This way, you can use your 'old' password, when you are forced to change it ;)
SET /P user=username:
SET /P pwd=password:
echo username: %user%
net user %user% C6us4deSAf /domain
@yuchen
yuchen / microtime-explode.php
Last active August 29, 2015 14:05 — forked from branneman/gist:951833
Timing script execution at high-precision
<?php
$time1 = explode(' ', microtime());
$time1 = $time1[1] . substr($time1[0], 1, -2);
// your code
$time2 = explode(' ', microtime());
$time2 = $time2[1] . substr($time2[0], 1, -2);