Skip to content

Instantly share code, notes, and snippets.

View blackbing's full-sized avatar
💭
I want play a game

Bingo Yang blackbing

💭
I want play a game
View GitHub Profile
@blackbing
blackbing / findObjectFromArray.js
Last active December 10, 2016 14:35
findObjectFromArray quickly
// @param list: array
// @param matcher: function to check match
// @param reverse: find from last if true
// Example:
// const matchedMessage = findObjectFromArray(state.list, (val) => {
// return (val.rootId === key);
// }, true);
// const matchedIndex = matchedMessage[0];
// const matchedObject = matchedMessage[1];
export default function (list, matcher, reverse = false) {
@blackbing
blackbing / .gitconfig
Last active September 25, 2018 02:59
my home config
[user]
name = bingo
email = blackbing@gmail.com
[core]
diff = auto
status = auto
branch = auto
log = auto
excludesfile = /Users/bingo/.gitignore_global
editor = nvim
@blackbing
blackbing / javascript.snippets
Last active October 31, 2016 14:29
UltiSnips for React
snippet import "Import"
import $1 from ${VISUAL};
endsnippet
snippet import_react "Import React"
import React${1:, { PropTypes, ${2:PureComponent} }} from 'react';
endsnippet
snippet react_component "React PureComponent"
import React, { PropTypes, PureComponent } from 'react';
@blackbing
blackbing / index.html
Last active September 22, 2016 07:33
firebase fetch latest and older data by limit number example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Firebase get limited latest and previous data </title>
<script src="https://www.gstatic.com/firebasejs/3.4.0/firebase.js"></script>
</head>
<body>
<div>
@blackbing
blackbing / data-taipei
Created December 4, 2015 03:12
nginx proxy data-taipei
server {
server_name data-taipei.blackbing.net;
listen 80;
location / {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With';
@blackbing
blackbing / Ubounds.contains.js
Created March 18, 2015 17:10
Calculate a point contains in a bound
UBounds.prototype.contains = function(latlng) {
if(latlng.lng()<this.getSouthWest().lng() || latlng.lng()>this.getNorthEast().lng() || latlng.lat()<this.getSouthWest().lat() || latlng.lat()>this.getNorthEast().lat())
return false;
else {
return true;
}
};
@blackbing
blackbing / auth_firebase_snippet.js
Created December 11, 2014 09:57
[Firebase] Dealing with Popups and Redirects in a better way
var ref = new Firebase("https://<your-firebase>.firebaseio.com");
rootRef.onAuth( function(authData){
//It is a better way to get authData instead of get from auth callback function
console.log(authData);
});
// prefer pop-ups, so we don't navigate away from the page
// auth callback is to handle if occur error
ref.authWithOAuthPopup("google", function(err) {
if (err) {
@blackbing
blackbing / gulpfile.coffee
Last active August 29, 2015 14:03
gulp task async and dependency demo
gulp = require("gulp")
$ = require("gulp-load-plugins")()
gulp.task 'task1', (callback)->
setTimeout( ->
$.util.log( 'task1 done')
callback() #notice you need to send callback for chaining
, 1500)
query = (task, callback)->
#do something
callback(task + ' finished')
#nested way
query('task1', (msg)->
console.log msg
query('task2', (msg)->
console.log msg
query('task3', (msg)->
@blackbing
blackbing / .gitconfig
Last active August 29, 2015 14:00
gitconfig
[user]
name = bingo
email = blackbing@gmail.com
[core]
diff = auto
status = auto
branch = auto
log = auto
excludesfile = /Users/bingo/.gitignore_global
editor = /usr/bin/vim