Skip to content

Instantly share code, notes, and snippets.

View joe11051105's full-sized avatar

Joe Wang joe11051105

View GitHub Profile
@joe11051105
joe11051105 / simple-capistrano-docker-deploy.rb
Created April 27, 2016 18:02 — forked from johnbintz/simple-capistrano-docker-deploy.rb
Simple Capistrano deploy for a Docker-managed app
# be sure to comment out the require 'capistrano/deploy' line in your Capfile!
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'my-cool-application'
# the base docker repo reference
set :name, "johns-stuff/#{fetch(:application)}"
@joe11051105
joe11051105 / better-nodejs-require-paths.md
Created April 22, 2016 10:47 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@joe11051105
joe11051105 / what-forces-layout.md
Created September 29, 2015 03:53 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
# 先安裝 gem
gem install httpclient
require "httpclient"
request = HTTPClient.new
request.set_basic_auth("https://api.github.com/user", "joe11051105", "password")
request.get "http://api.github.com/joe11051105/repos"
@joe11051105
joe11051105 / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@joe11051105
joe11051105 / 20140721 R Group
Created July 21, 2014 15:13
20140721 R Group ans
rm(list = ls())
iter = 10000
p = runif(iter)
coord = matrix(c(0, 0), ncol = 1)
df = rbind(data.frame(), t(coord))
for (i in 1:iter) {
indicator = runif(1, 0, 1)
if (indicator <= 0.05) {
m = matrix(c(0, 0, 0, 0.16), nrow = 2, ncol = 2)
const = matrix(c(0, 0), ncol = 1)