Skip to content

Instantly share code, notes, and snippets.

Yang He abruzzihraig

Block or report user

Report or block abruzzihraig

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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"
@sukharevd
sukharevd / aws-s3-gzip-compression.py
Last active Sep 2, 2016
Synchronizes directory with gzipped content of Amazon S3 bucket with local one to avoid redundant synchronization requests when files were not changed, but MD5 sums of Gzipped files are different.
View aws-s3-gzip-compression.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
AWS S3 Gzip compression utility
Author: Dmitriy Sukharev
Modified: 2013-09-11
-------
Synchronizes directory with gzipped content of Amazon S3 bucket with local
View gist:583836
var express = require('express'),
request = require('request'),
BufferList = require('bufferlist').BufferList,
sys = require('sys');
var app = express.createServer(
express.logger(),
express.bodyDecoder()
);
@skarface
skarface / 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 { ... }
*
You can’t perform that action at this time.