Skip to content

Instantly share code, notes, and snippets.

View joe11051105's full-sized avatar

Joe Wang joe11051105

View GitHub Profile
@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)
@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
# 先安裝 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 / 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()
@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 / 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 / Ansible-Vault how-to.md
Created April 28, 2016 09:43 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@joe11051105
joe11051105 / migrate_postgresql_database.md
Created May 4, 2016 16:39 — forked from olivierlacan/migrate_postgresql_database.md
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important:

@joe11051105
joe11051105 / package.json
Created May 8, 2016 13:59 — forked from addyosmani/package.json
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js'",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",