Skip to content

Instantly share code, notes, and snippets.

View parshap's full-sized avatar

Parsha Pourkhomami parshap

View GitHub Profile
import slack from `slack`
let token = process.env.SLACK_TOKEN
let bot = slack.rtm.client({token})
bot.on("hello", console.log)
bot.on("message", console.log)
@parshap
parshap / simple-passport.js
Last active October 22, 2015 22:54
Simple Passport-like interface compatible with passport strategies
"use strict";
var SimplePassport = {
authenticate: function(req, res, strategy, options, callback) {
strategy = Object.create(strategy);
Object.assign(strategy, {
success: callback.bind(null, null), // callback(null, user)
error: callback.bind(null), // callback(err)
fail: callback.bind(null, null, false), // callback(null, false)
pass: callback.bind(null, null, null), // callback(null, null)
@parshap
parshap / gist:ed918fb4a80ae5d271a0
Created October 16, 2015 19:15
Browserify Buffer.isBuffer inlining with full path
$ browserify --version
11.2.0
$ echo "Buffer.isBuffer(null)" > buffer-test.js
$ browserify buffer-test.js
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (Buffer){
Buffer.isBuffer(null)
}).call(this,{"isBuffer":require("/home/parshap/projects/node-browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js")})
},{"/home/parshap/projects/node-browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":2}],2:[function(require,module,exports){
@parshap
parshap / gist:0a0e6bbca3d3d2221b06
Created October 16, 2015 18:54
Browserify module path
}).call(this,{"isBuffer":require("/path/to/project/node_modules/browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js")})
},{"/path/to/project/node_modules/browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":553}],598:[function(require,module,exports){
SyntaxError: Unexpected token (115:27) while parsing file: /home/parshap/projects/aboutlife/web/lib/client/react/employee-card.js
at Parser.pp.raise (/home/parshap/projects/aboutlife/web/node_modules/acorn/dist/acorn.js:1745:13)
at Parser.pp.unexpected (/home/parshap/projects/aboutlife/web/node_modules/acorn/dist/acorn.js:2264:8)
at Parser.pp.expect (/home/parshap/projects/aboutlife/web/node_modules/acorn/dist/acorn.js:2258:26)
at Parser.pp.parseExprList (/home/parshap/projects/aboutlife/web/node_modules/acorn/dist/acorn.js:1443:12)
at Parser.pp.parseExprAtom (/home/parshap/projects/aboutlife/web/node_modules/acorn/dist/acorn.js:1120:28)
at Parser.pp.parseExprSubscripts (/home/parshap/projects/aboutlife/web/node_modules/acorn/dist/acorn.js:1023:19)
at Parser.pp.parseMaybeUnary (/home/parshap/projects/aboutlife/web/node_modules/acorn/dist/acorn.js:1004:19)
at Parser.pp.parseExprOps (/home/parshap/projects/aboutlife/web/node_modules/acorn/dist/acorn.js:948:19)
at Parser.pp.parseMaybeConditiona
@parshap
parshap / mylogger
Last active August 29, 2015 14:27
Log to file and handle SIGHUP
#!/bin/bash
logfile=$1
pidfile=$2
sighup() {
exec 0>>$logfile 2>&1
}
echo "$$" > $pidfile
"use strict";
// # Responsive Component
//
// A react component that will conditionally render children that correspond
// to the currently matching "named" media query.
//
// The predefined named media queries are: "small", "not-small", "medium", and
// "large". These correspond to CSS classes that end with "-ns", "-m", etc.
// suffixes.
@parshap
parshap / css-in-js.md
Last active August 29, 2015 14:16
CSS in JavaScript

CSS in JavaScript

Expressing styles in JavaScript isn't all that different than expressing them in css.

Plain Ol' HTML & CSS

Imagine you had the following css and html:

Styles
requiresafe@1.2.0 /usr/lib/node_modules/requiresafe
├── tryit@1.0.1
├── find-root@0.1.1
├── is-email@0.1.1
├── amp-is-object@1.0.1
├── amp-extend@1.0.1
├── minimist@1.1.0
├── marked@0.3.3
├── yetify@0.1.0 (colors@1.0.3)
├── chalk@0.5.1 (escape-string-regexp@1.0.2, ansi-styles@1.1.0, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
@parshap
parshap / -
Created February 17, 2015 19:41
Warning: distutils distribution has been initialized, it may be too late to add a library RWarning: distutils distribution has been initialized, it may be too late to add a library blasWarning: distutils distribution has been initialized, it may be too late to add an extension _earthTraceback (most recent call last):
File "setup.py", line 62, in <module>
'lifeline-admin=lifeline.admin.main:LifelineAdmin.main'
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/src/local/lib/python2.7/site-packages/setuptools/command/develop.py", line 27, in run