Skip to content

Instantly share code, notes, and snippets.

@brianyang
brianyang / createPolyComponent.js
Created December 1, 2017 13:56 — forked from andrewimm/createPolyComponent.js
Google Poly API + React VR
import React from 'react';
import {Model} from 'react-vr';
function getFormat(formats, format) {
for (let i = 0; i < formats.length; i++) {
if (formats[i].formatType === format) {
return formats[i];
}
}
}
@brianyang
brianyang / easy-console.js
Created December 15, 2016 01:43 — forked from nuxodin/easy-console.js
Like to write to the console like this "console = xyz" instead of "console.log(xyz)" ?
!(function(){
var original = console;
Object.defineProperty(window, 'console', {
get:function(){
return original;
},
set:function(value){
original.log(value)
}
})
@brianyang
brianyang / matching-braces.js
Created June 6, 2016 00:45 — forked from franvarney/matching-braces.js
Matching Braces (JavaScript)
var braces = '{()[()]}';
// var braces = '{()()]}';
// var braces = '(';
(function matchingBraces() {
if (braces.length === 1) return console.log(false);
if (!braces) return console.log(true);
var leftBraces = ['{', '(', '['];
var rightBraces = ['}', ')', ']'];
/* Extend the Underscore object with the following methods */
// Rate limit ensures a function is never called more than every [rate]ms
// Unlike underscore's _.throttle function, function calls are queued so that
// requests are never lost and simply deferred until some other time
//
// Parameters
// * func - function to rate limit
// * rate - minimum time to wait between function calls
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@brianyang
brianyang / twitter-oauth.js
Created November 21, 2012 15:11 — forked from santosh79/twitter-oauth.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('util');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = process.env['TWITTER_CONSUMER_KEY'];
var _twitterConsumerSecret = process.env['TWITTER_CONSUMER_SECRET'];
console.log("_twitterConsumerKey: %s and _twitterConsumerSecret %s", process.env['TWITTER_CONSUMER_KEY'], process.env['TWITTER_CONSUMER_SECRET']);
@brianyang
brianyang / Custom.css
Created November 1, 2012 16:04 — forked from drewwells/Custom.css
Solarized Dark Theme (with sidebar and view-source colors) for Google Chrome Dev Tools
/* curl -o ~/Library/Application\ Support/Google/Chrome/Default/User\ StyleSheets/Custom.css https://raw.github.com/gist/1317519/435c54845a4303a6e252c3c43ea72324b9f6d1b1/Custom.css */
/**********************************************/
/*
/* Solarized Dark Skin by Mark Osborne - 2011
/*
/* Based on IR_Black Skin by Ben Truyman:
/* https://gist.github.com/1245727
/*
/* and Todd Werth's IR_Black:
@brianyang
brianyang / Custom.css
Created October 31, 2012 15:38 — forked from bentruyman/Custom.css
Tomorrow Theme for Chrome Developer Tools
/**********************************************/
/* curl -o ~/Library/Application\ Support/Google/Chrome/Default/User\ StyleSheets/Custom.css https://raw.github.com/gist/1163300/afecfb4f9c7ac1e26ec64710b1ccf87e30b47704/Custom.css
/* Tomorrow Skin by Ben Truyman - 2011
/*
/* Based on Chris Kempson's Tomorrow Theme:
/* https://github.com/ChrisKempson/Tomorrow-Theme
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@brianyang
brianyang / jquery.pubsub-demo.js
Created October 28, 2012 15:36 — forked from icodejs/jquery.pubsub-demo.js
JS: jQuery pub sub
var pubsub = {
sendMessage: function() {
message = $("input").val();
$("body").trigger("messageReceived", { message: message});
return false;
},
displayMessage: function(data) {
$("body").trigger("messageDisplayed");
li = $("<li />").text(data.message).css("display", "none");
$("ul").append(li);