Skip to content

Instantly share code, notes, and snippets.

View bambooom's full-sized avatar
🎈
biu~

Bamboo bambooom

🎈
biu~
View GitHub Profile
@bambooom
bambooom / parallelQueries.js
Created July 1, 2016 02:39
async.parallel multiple sequelize queries
async.parallel({
card_count: function (cb) {
db
.Card
.findAll({
where: {course_id: 'some id'}
})
.then(function (results) {
var t = [];
results.forEach(function (result) {
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
@bambooom
bambooom / on-jsx.markdown
Created October 17, 2016 07:40 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'

@bambooom
bambooom / demo.js
Created November 9, 2016 02:59
merge two arrays and remove duplicate in es6
let arr1 = [3, 5, 2, 2, 5, 5];
let arr2 = [2, 1, 66, 5];
let unique = [...new Set([...arr1,...arr2])];
console.log(unique);
// [ 3, 5, 2, 1, 66 ]
@bambooom
bambooom / curl.md
Created November 10, 2016 09:58 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@bambooom
bambooom / dateCompare.js
Created April 13, 2017 02:22
when variable s is null or undefined, what is Date(s) ?
var s;
// s is undefined
new Date(s)
// -> Invalid date
new Date(s) < new Date()
// -> false
var s = null;
// s is null
new Date(s)
@bambooom
bambooom / Enhance.js
Created May 8, 2017 06:53 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@bambooom
bambooom / details.js
Created July 7, 2017 02:56 — forked from remy/details.js
Add <details> support - includes stylesheet
/**
* Note that this script is intended to be included at the *end* of the document, before </body>
*/
(function (window, document) {
if ('open' in document.createElement('details')) return;
// made global by myself to be reused elsewhere
var addEvent = (function () {
if (document.addEventListener) {
return function (el, type, fn) {
@bambooom
bambooom / puppeteer-select.js
Last active July 12, 2018 03:56
select option
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto('https://test-navlang-demo-vvkpjvrhym.now.sh');
await page.setViewport({ width: 1380, height: 900 });
await page.waitFor(1000);
// use elementHandle.type