Skip to content

Instantly share code, notes, and snippets.

View poberwong's full-sized avatar
🎯
Focusing

PoberWong poberwong

🎯
Focusing
View GitHub Profile
@poberwong
poberwong / girlFriend.js
Last active July 22, 2016 07:08
Love letter by programmer to darling. I will complete all steps even if the distance between us is 1001 steps as long as you don't go backwards
let distance = 1001
let me = new Boy('Pober')
let you = new Girl(me.heart.getDarling())
while (distance > 0) {
you.waitingForMe()
me.goTowardYou()
distance--
}
me.kiss(you)
@poberwong
poberwong / update_gfwlist.sh
Created September 20, 2016 03:10 — forked from VincentSit/update_gfwlist.sh
Automatically update the PAC for ShadowsocksX. Only tested on OS X.
#!/bin/bash
# update_gfwlist.sh
# Author : VincentSit
# Copyright (c) http://xuexuefeng.com
#
# Example usage
#
# ./whatever-you-name-this.sh
#
# Task Scheduling (Optional)
@poberwong
poberwong / LoopAnimation.js
Last active February 28, 2023 12:24
a demo for loop animation in react-native
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@poberwong
poberwong / Animation.js
Last active November 15, 2016 10:45
Animation for changing width/height of component
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@poberwong
poberwong / uninstall_homebrew.sh
Created November 21, 2016 04:39 — forked from mxcl/uninstall_homebrew.sh
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@poberwong
poberwong / promiseTest.js
Last active January 16, 2018 07:16
use promise instead of callback
async function checkImage (file, pixels, onSuccess, onFailed) {
const {width, height} = pixels
return new Promise((resolve, reject) => {
try {
const img = await readImageFromFile(file)
if (img.width !== WIDTH || img.height !== HEIGHT) {
alert(`图标文件必须 ${pixels} 像素`)
} else {
resolve(img)
@poberwong
poberwong / easing.js
Created January 4, 2017 09:11 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
{
"parser" : "babel-eslint",
"extends" : [
"standard",
"standard-react"
],
"plugins": [
"react",
"promise",
"standard"
@poberwong
poberwong / highOrderComponent.js
Created January 17, 2017 03:01
a simple high order component
export default (Component) => (props) => {
return (
<YourWrapper ...>
<Component />
</YourWrapper>
)
}
// Usage:
// in your component, you can use it with
@poberwong
poberwong / applyMiddleware.js
Last active December 25, 2019 20:27
source code for applyMiddleware of redux
/* v3.5.2*/
export default function (...middlewares) {
return (createStore) => (reducers, initialState, enhancer) => {
const store = createStore(reducers, initialState, enhancer)
const dispatch = store.dispatch
const chain = []
const middleWareAPI = {
getState: store.getState,
dispatch: action => dispatch(action)
}