Skip to content

Instantly share code, notes, and snippets.

View RichardLitt's full-sized avatar

Richard Littauer RichardLitt

View GitHub Profile
14:18 ~/src/beaglelabs/beagle $ grep react node_modules/react*/package.json
node_modules/react-async/package.json: "name": "react-async",
node_modules/react-async/package.json: "react": "~0.11.0"
node_modules/react-async/package.json: "react": "~0.11.0",
node_modules/react-async/package.json: "url": "git://github.com/andreypopp/react-async"
node_modules/react-async/package.json: "react-component",
node_modules/react-async/package.json: "react"
node_modules/react-async/package.json: "url": "https://github.com/andreypopp/react-async/issues"
node_modules/react-async/package.json: "homepage": "https://github.com/andreypopp/react-async",
node_modules/react-async/package.json: "_id": "react-async@1.0.2",
var iterator = 10;
iLoop: for (var i = 0; i < iterator; i++) {
yLoop: for (var y = 0; y < iterator; y++ ) {
console.log('i and y:', i, y)
testing: if (y==5) {
console.log('This will break the outside loop!');
break iLoop;
console.log('This will never appear.');
}
@RichardLitt
RichardLitt / gist:d188954e5d3ee7fb0a93
Created December 19, 2014 00:37
How to show a radioactive icon if the current dir has a git stash
parse_git_stash() {
[[ $(git stash list 2> /dev/null | tail -n1) != "" ]] && echo ' \[\e[0;31m\]☣'
}
set_bash_prompt(){
PS1="\A \w$(parse_git_stash) \[\e[0m\]$ "
}
PROMPT_COMMAND=set_bash_prompt
@RichardLitt
RichardLitt / gist:d6513707efdb7926ab04
Created February 18, 2015 00:45
Broken test in static-module
// Works: https://github.com/substack/static-module/blob/master/test/brfs/attribute_vars.js
var x = 5, f = require('fs').readFileSync, y = 2;
var src = f(__dirname + '/x.txt', 'utf8');
console.log(src);
// Broken:
var x = 5, fs = require('fs'), y = 2;
var src = fs.readFileSync(__dirname + '/x.txt', 'utf8');
console.log(src);
// Initiation of browserify object
var b = browserify({
// Required watchify args
'cache': {},
'packageCache': {},
'fullPaths': true,
// Browserify options
'entries': [paths.jsPath + 'main.js'],
'noParse': ['react.js', 'jquery.js', 'pdf.combined.js'],
'transform': [reactify]
@RichardLitt
RichardLitt / gist:4e2f86e68b6b743a9ccf
Created April 10, 2015 02:17
db.put not returning response
db.get(documentId).then(function (value) {
// if (err && err.name !== 'not_found') {
// return console.log('Failed to get ' + documentId + 'from db', err)
// }
/* Instantiate the object if it doesn't exist yet */
value = value || {}
value._id = documentId
/* Add in the selection to the selections array */
# 2015 April 16th
What am I trying to do?
I have a Chrome extension and I want to implement OAuth in it so that users can be authenticated and have accounts.
So, first, I need users. The user objects shouldn’t be too hard to implement. Juan sent me a way to do it.
Then, I need to figure out how to use Google OAuth. Actually, this doesn’t require me hitting the API for the Google Contacts I need, I believe - I should be able to just use Google OAuth before I hit the API, as that is actually a separate concern.
@RichardLitt
RichardLitt / gist:d668e99f9566dcf386fb
Created April 30, 2015 14:58
Shell script for local node modules
cd ..
printf 'cd to' && pwd
echo 'Cloning BeagleLab/beagle-style'
git clone git@github.com:BeagleLab/beagle-style.git
cd beagle-style
echo 'Installing modules...'
npm install
cd ..
echo 'Cloning BeagleLab/beagle-pdf'
git clone git@github.com:BeagleLab/beagle-pdf.git
componentWillMount: function () {
let dummyImage = 'http://upload.wikimedia.org/wikipedia/en/4/42/Richard_Feynman_Nobel.jpg'
let userPromises = []
let clone = _.each(this.state.conversations.slice(), function (conversation) {
conversation.avatars = []
_.each(_.keys(conversation.participants), function (key) {
if (conversation.participants.hasOwnProperty(key)) {
// Suggestion: Only show avatars for participants who have actively contributed to conversation
let getAvatar = db.getUser(key).then(function (err, res) {
if (res.avatar) {
module.exports.getConversationsForUser = function (user, cb) {
db.query(function (doc) {
if (doc.author === user.userId) {
emit(doc)
}
}.bind(this), {include_docs: true}).then(function (response) {
console.log('response', response)
cb(null, response)
}).catch(function (err) {
cb(err)