Skip to content

Instantly share code, notes, and snippets.

View winsonwq's full-sized avatar
🎯
Focusing

Wang Qiu winsonwq

🎯
Focusing
  • 可好玩乐
  • Chengdu China
View GitHub Profile
#include "cocotouch.h"
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN 8
#define NUMPIXELS 60
char index;
uint8_t idx;
#include "cocotouch.h"
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN 5
#define NUMPIXELS 60
CocoTouch touch;
uint8_t touchstates[12];
@winsonwq
winsonwq / index.js
Created October 10, 2015 16:51
functional practice - promise map
const R = require('ramda');
const Promise = require('es6-promise').Promise;
const pMap = require('./promise-map');
function get(method) {
return Promise[method]({
addresses: [
{ street: 'street a' },
{ street: 'street b' },
{ street: 'street c' }
@winsonwq
winsonwq / ListStore.js
Last active October 13, 2017 13:36 — forked from morlay/ListStore.js
import { createStore } from 'reflux'
// if you don't mind
import { pipe, of } from 'ramda'
import GalleryActions from '../actions/GalleryActions'
export default createStore({
init(){
this.galleryMap = {}
@winsonwq
winsonwq / symbol-iterator.js
Created January 4, 2015 02:17
Iterability [3] in ECMAScript 6 is one such customization. An object is iterable if it has a method whose key is the symbol (stored in) Symbol.iterator. In the following code, obj is iterable.
let obj = {
data: [ 'hello', 'world' ],
[Symbol.iterator]() {
const self = this;
let index = 0;
return {
next() {
if (index < self.data.length) {
return {
value: self.data[index++]
@winsonwq
winsonwq / run.js
Created December 29, 2014 05:50
demo: tranditional implementation of animation
function run(element, cssProperty, value, duration) {
var initalValue = parseFloat(window.getComputedStyle(element)[cssProperty]);
var start = new Date().getTime();
window.requestAnimationFrame(function step() {
var progress = new Date().getTime() - start;
var newValue = bounce(progress, initalValue, parseFloat(value) - initalValue, duration);
element.style[cssProperty] = newValue + 'px';
if (progress < duration) {
@winsonwq
winsonwq / .ctags
Created December 10, 2014 02:56
ctags for javascript
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])([A-Za-z0-9._$]+)[[:blank:]]*[:=][[:blank:]]*new[[:blank:]]+Object\(/\2/o,object/
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])([A-Za-z0-9._$]+)[[:blank:]]*[:=][[:blank:]]*\{/\2/o,object/
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])(^[^\?][[:blank:]]*)([A-Za-z0-9_]+)[[:blank:]]*[:][[:blank:]]*[A-Za-z0-9._$'"()]+/\3/m,member/
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])([A-Za-z0-9._$]+)[[:blank:]]*[:=][[:blank:]]*new[[:blank:]]+Array\(/\2/a,array/
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])([A-Za-z0-9._$]+)[[:blank:]]*[:=][[:blank:]]*\[/\2/a,array/
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])([^! ]+[^= ]+)[[:blank:]]*=[[:blank:]]*[^""]'[^'']*/\2/s,string/
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])([A-Za-z0-9._$()]+)[[:blank:]]*[:=][[:blank:]]*function[[:blank:]]*\(/\2/f,function/
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])this\.([A-Za-z0-9._$()]+)[[:blank:]]*[:=][[:blank:]]*function[[:blank:]]*\(/\2/f,function/
--regex-JavaScript=/(^|^[^\/*]+[[:blank:]])function[[:blank:]
@winsonwq
winsonwq / ghost_markdown_image_upload.js
Created December 3, 2014 03:02
Ghost Markdown 改吧改吧
(function($, ShowDown, CodeMirror) {
"use strict";
$(function() {
if (!document.getElementById('entry-markdown'))
return;
//var delay;
var converter = new ShowDown.converter(),
@winsonwq
winsonwq / .vimrc
Last active August 29, 2015 14:04
this is my vimrc
" don't bother with vi compatibility
set nocompatible
" vundle start
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
@winsonwq
winsonwq / parking-lot.js
Last active May 4, 2016 15:28
Parking Lot with inheritance
// Step 1
function Car () {}
function Ticket () {}
function ParkingLot(capacity) {
this.capacity = capacity;
this.cars = [];
}