Skip to content

Instantly share code, notes, and snippets.

Avatar

Yang He abruzzihraig

View GitHub Profile
View gist:7fd60376d88c362b00bc
xhr = new XMLHttpRequest()
# 进度
xhr.upload.addEventListener "progress", uploadProgress, false
# 完成
xhr.addEventListener "load", uploadComplete, false
xhr.addEventListener "error", console.log, false
xhr.addEventListener "abort", console.log, false
@changtimwu
changtimwu / fluxpurejs.js
Last active Feb 4, 2016
gasolin demonstrates flux concept in only 50 lines of javascript
View fluxpurejs.js
/* original link http://blog.gasolin.idv.tw/2014/11/flux-javascript.html */
// Renderer.js
var ClickRenderer = {
init: function s_init(element, Store) {
this.element = element;
this.store = Store;
window.addEventListener('render_view1', this);
},
handleEvent: s_handleEvent(evt) {
@abruzzihraig
abruzzihraig / angular-amap.js
Last active Jul 5, 2016
AMap/高德地图 module wrapper with angular
View angular-amap.js
/*
* The module amap below is a simplest implementation, there is no any updated or proper libraries when I wrote it.
* Since there is a new full-feature library which wrote by another guy, so I just recommend it below.
* https://github.com/leftstick/angular-amap
*
* If you just want version with a few features like below, you could just build your version on top of it.
*/
angular.module('amap', [])
.constant('amapConstant', {
@billywhizz
billywhizz / script_test.js
Created Feb 6, 2011
testing vm script functionality in node.js
View script_test.js
var vm = require('vm'),
code = 'var square = n * n;',
fn = new Function('n', code),
script = vm.createScript(code),
sandbox;
n = 5;
sandbox = { n: n };
benchmark = function(title, funk) {
@PawelWitan
PawelWitan / racounter2dayone.sh
Created Sep 1, 2012
Import to Day One Journal app from Racounter Application Data Extract
View racounter2dayone.sh
#!/bin/bash
# Uses Day One cli [http://dayoneapp.com/tools/cli-man] and sqlite3
# Expects extract from iPhone backup made by JuicePhone [http://www.addpod.com/juicephone], folder with a device name should be passed as an argument
[ -z "$1" ] && echo "$0: Usage: $0 Device-Name-Exctracted-Folder" && exit 0
[ ! -d "$1" ] && echo "$0: $1 is not a directory" && exit 0
[ ! -e "$1/Application Data/Raconteur/Documents/Entries.sqlite" ] && echo "$0: $1 doesn't contain Racounter app extract." && exit 0
RT="$1"
@marco-martins
marco-martins / touch-tooltip-fix.js
Created Jun 26, 2012 — forked from slawekkolodziej/touch-tooltip-fix.js
Highcharts tracker now don't prevent default behavior (like scrolling on touch devices).
View touch-tooltip-fix.js
Highcharts.Chart.prototype.callbacks.push(function(chart) {
var hasTouch = hasTouch = document.documentElement.ontouchstart !== undefined,
mouseTracker = chart.tracker,
container = chart.container,
mouseMove;
mouseMove = function (e) {
// let the system handle multitouch operations like two finger scroll
// and pinching
if (e && e.touches && e.touches.length > 1) {
@yyx990803
yyx990803 / props.md
Last active Mar 28, 2017
关于应不应该把属性的默认值放在prototype里
View props.md

TL,DR: 务必总是在构建函数里定义实例属性。

在小胖的PoorPhy物理库里,有很多类似这样的代码:

function WorldA () {
  // ...
}

WorldA.prototype = {
@idiotWu
idiotWu / themr.js
Last active Mar 29, 2017
Another theme-able solution for react reusable components.
View themr.js
/*
* Usage:
*
* As a decorator:
*
* import defaultTheme from './style.scss';
*
* @themr(defaultTheme)
* class Comp extends React.Component { ... }
*
@idiotWu
idiotWu / attach-events.js
Last active Oct 6, 2017
attach-events decorator for react
View attach-events.js
/**
* @decorator
* Attach events to DOM element
*
* @param {Element|Function} elemOrFunc: DOM Element, or a function returns element
* @param {String} events: a list events separated with ','
*
* Usage:
* @attachEvents(window, 'click')
* handleWindowClick(evt) {
@bjhomer
bjhomer / instructions.md
Last active Dec 27, 2017
How to make the Day One command line tool automatically write to Day One 2
View instructions.md

Using the Day One CLI with Day One 2

The dayone command line tool was originally written to work with Day One Classic, and by default writes its entries to the default Day One Classic journal directory1. If you want to use the dayone tool to write entries in to Day One 2 instead, there are a couple options.




Option 1. Use this option if you don't use Day One Classic at all.