Skip to content

Instantly share code, notes, and snippets.

View feifanzhou's full-sized avatar

Feifan Zhou feifanzhou

View GitHub Profile
@feifanzhou
feifanzhou / lib-spork-test_framework-rspec.rb
Created June 14, 2014 23:30
Working Spork config for RSpec 3
require 'rspec/core/version'
class Spork::TestFramework::RSpec < Spork::TestFramework
DEFAULT_PORT = 8989
HELPER_FILE = File.join(Dir.pwd, "spec/spec_helper.rb")
def run_tests(argv, stderr, stdout)
if rspec1?
::Spec::Runner::CommandLine.run(
::Spec::Runner::OptionParser.parse(argv, stderr, stdout)
@feifanzhou
feifanzhou / ControllerBase.php
Last active August 29, 2015 14:02
RESTful routing with PHP
<?php
$bn = basename($_SERVER['SCRIPT_NAME'], '.php');
$p = explode('_', $bn);
$model_name = substr($p[0], 0, -1);
$model_path = "../models/$model_name.php";
include_once($model_path);
include_once('../../config/routes.php');
$controller_name = $p[0];
function loadRESTfulView($controllerName, $action, $_options) {
@feifanzhou
feifanzhou / layout-map
Created June 1, 2014 16:19
Show layout and structure of webpage: http://qr.ae/Kfxs6
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
@feifanzhou
feifanzhou / vendor prefix mixin
Last active August 29, 2015 14:01
Vendor prefix SASS mixin
@mixin vendor-prefix($name, $argument) {
#{$name}: #{ $argument };
-webkit-#{$name}: #{ $argument };
-ms-#{$name}: #{ $argument };
-moz-#{$name}: #{ $argument };
-o-#{$name}: #{ $argument };
}
// a is a Nodelist
// like document.getElementsByClassName('class')
[].forEach.call(a, function (e) { console.log(e.children[0].innerHTML) });