Skip to content

Instantly share code, notes, and snippets.

@pengjunp
pengjunp / HEY-YOU.md
Created September 12, 2017 22:26 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
@pengjunp
pengjunp / gulpfile.js
Created April 20, 2017 06:54 — forked from mlouro/gulpfile.js
gulpfile.js with browserify, jshint, libsass, browserSync for livereload, image optimization and system notifications on errors
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var exec = require('child_process').exec;
var notify = require('gulp-notify');
@pengjunp
pengjunp / notes.md
Created May 30, 2016 16:21 — forked from monicao/notes.md
Setting up your own Ruby Dev Environment on a Mac

Setting up the Ruby dev environment on a Mac

Tested on Yosemite. Should work on El Cap. Message me if it doesn't.

Why would I want to do that?

  • You are tired of using vagrant
  • You want to run guard
  • You want use Sublime plugins (like RSpec or Guard plugins)
  • You want your code to run faster in development

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@pengjunp
pengjunp / sort.rb
Last active April 27, 2016 05:51 — forked from davidvandusen/sort.rb
require 'benchmark'
# Sort the array from lowest to highest
def sort(arr)
swap = true
# Merge sort
while swap
swap = false
for i in 0..arr.length - 1
if i <= arr.length - 2 && arr[i] > arr[i + 1]
greater = arr[i]
@pengjunp
pengjunp / max.rb
Last active April 26, 2016 19:33 — forked from davidvandusen/max.rb
maximum value
# Find the maximum
def maximum(arr)
result = nil
if !arr.is_a? (Array)
result = "not an array"
else
arr.each { |i| result = i if result == nil || i > result}
return result
end
end