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 / index.html
Created June 8, 2016 18:04
JS betting game
<!doctype html>
<head>
<title>JS Betting Game</title>
<script src="jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<canvas id="let-it-rain" style="width:100%; height:100%; display:none;"></canvas>
<h1>JS Betting Game</h1>
require 'colorize'
require 'pry'
@p1_name = @p2_name = ""
@p1_life = @p2_life = 3
@p1_score = @p2_score = 0
@operator = ""
@running = true
def generate_question
switch = false
@pengjunp
pengjunp / contact.rb
Created June 8, 2016 17:57
Contact list exercise in Ruby
require 'csv'
require 'pry'
require 'pry-byebug'
# Represents a person in an address book.
# The ContactList class will work with Contact objects instead of interacting with the CSV file directly
class Contact
attr_reader :id
attr_accessor :name, :email
@@all_contacts = CSV.read('contacts.csv')
@pengjunp
pengjunp / game.js
Created June 7, 2016 00:25
Node betting game
var prompt = require('prompt-sync')();
var colors = require('colors');
var isRunning = true;
//const bankDefault = 10; // for debugging
const bankDefault = 100;
var bankroll = bankDefault;
function run() {
console.log(isRunning);
@pengjunp
pengjunp / 01.js
Created June 6, 2016 23:40
Learnyounode
console.log("HELLO WORLD")
<!doctype html>
<html>
<head>
<title>Ajax Example</title>
</head>
<body>
<section>
<h1>Recent Posts</h1>
<article>
<h2>Post 1</h2>
function arrayOfLight(x) {
var arr = [];
for(var i = 0; i <= x; i++) {
arr[i] = i;
}
return arr;
}
console.log(arrayOfLight(5));
@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