Skip to content

Instantly share code, notes, and snippets.

View MrOrz's full-sized avatar
💤
Sleepy everyday

Johnson Liang MrOrz

💤
Sleepy everyday
View GitHub Profile
@MrOrz
MrOrz / btn.sass
Created August 29, 2013 02:55
@extending a selector within the same @media directive still gives deprecation warning.
// A placeholder factory that generates a placeholder.
=btn-placeholder($border-color)
%btn
border: 1px solid $border-color
border-radius: 8px
// Generate a %btn placeholder here.
+btn-placeholder(#000)
// Use the %btn placeholder in the following two classes
@MrOrz
MrOrz / xdomainrequest.js.coffee
Created September 1, 2013 16:07
Patching `XMLHttpRequest` for AngularJS and Internet Explorer < 10. It replaces the original `window.XMLHttpRequest` with a thin interface that only implements the parts AngularJS core uses. Missing methods of `XDomainRequest` are fed with `angular.noop`.
# A XMLHttpRequest wrapper for IE < 10.
# When it comes to cross domain ajax requests, it uses XDomainRequest instead.
# ** Only supports GET and POST requests! **
# Targeting IE < 10
# https://github.com/amcintyre-cs/strophejs-plugins/commit/b0a6ff2571bb70dd2f6f65c46034f4e47d75d564
return unless window.XDomainRequest and !("withCredentials" in window.XMLHttpRequest)
OriginalXMLHttpRequest = window.XMLHttpRequest
window.location.origin ?= window.location.protocol + '//' + window.location.host
@MrOrz
MrOrz / fish.js
Created December 4, 2013 06:56
Mineflayer fishing bot.
var mineflayer = require('mineflayer'),
repl = require("repl");
var FISHING_ROD = 346, RAW_FISH = 349;
var FISHING_INTERVAL = 200;
var bot = mineflayer.createBot({
host: "<server>",
username: "<username>"
@MrOrz
MrOrz / snow.js
Created December 19, 2013 16:20
The script drive the bot to dig snow on start, and starts crafting snow bricks when the iron shovel is ran out, or when there is going to be full in the bot's inventory.
var mineflayer = require('mineflayer'),
repl = require("repl");
// [EDIT ME] Snow block coordinate
var SNOW_X = -516, SNOW_Y = 71, SNOW_Z = -245;
var SNOW_BRICK = 80, SNOW_BLOCK_COUNT = 4,
STONE_SHOVEL = 273, WOOD_SHOVEL = 269, IRON_SHOVEL = 256,
SNOW_POINT, SNOW_BLOCK; // Set after bot user spawns.
@MrOrz
MrOrz / gist:8717358
Created January 30, 2014 19:49
DIsable scrolling outside, scrapped from facebook's compressed JS.
__d("Scrollable", ["Event", "Parent", "UserAgent"], function(a, b, c, d, e, f) {
var g = b('Event'), h = b('Parent'), i = b('UserAgent'), j = function(event) {
var m = h.byClass(event.getTarget(), 'scrollable');
if (!m)
return;
if ((typeof event.axis !== 'undefined' && event.axis === event.HORIZONTAL_AXIS) ||
(event.wheelDeltaX && !event.wheelDeltaY) || (event.deltaX && !event.deltaY))
return;
var n = event.wheelDelta || -event.deltaY || -event.detail,
o = m.scrollHeight, p = m.clientHeight;
@MrOrz
MrOrz / Makefile
Created March 6, 2014 18:35
My makefile for latex
TARGET = uist172-liang
PDFLATEX = /usr/texbin/pdflatex
BIBTEX = /usr/texbin/bibtex
LATEX = /usr/texbin/pdflatex
all:
$(PDFLATEX) -synctex=1 -interaction=nonstopmode $(TARGET).tex
$(BIBTEX) $(TARGET).aux
$(PDFLATEX) -synctex=1 -interaction=nonstopmode $(TARGET).tex
@MrOrz
MrOrz / walk.js
Last active August 29, 2015 14:15 — forked from tomchentw/walk.js
walkAsync now does not assume `path` is a directory now.
/*
Recursively traverses the given dir and returns a promise that resolves to
a list of files.
The promise is resolved only after all sub-directories being traversed.
*/
var walkAsync = function(path) {
return statAsync(path).then(function(stat){
if(stat.isDirectory()){
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class BSTIterator:
# @param root, a binary search tree's root node
def __init__(self, root):
import unittest
import 你要測的東西
class XxxSpec(unittest.TestCase):
def setUp(self):
"""
每個 test 前都會執行的東西。你可以塞一些常用的東西進 self。
"""
pass
@MrOrz
MrOrz / webpack-dev-server.js
Created March 20, 2015 14:01
My webpack config
// Webpack development server with hot module replacement enabled
// Ref: http://webpack.github.io/docs/webpack-dev-server.html#combining-with-an-existing-server
//
var serverCfg = require('./config');
if(process.env.NODE_ENV !== 'production') {
var WebpackDevServer = require("webpack-dev-server"),
webpackCfg = require("../client/config/webpack"),
webpack = require("webpack");
(new WebpackDevServer(webpack(webpackCfg), {