Skip to content

Instantly share code, notes, and snippets.

@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@jyotty
jyotty / gist:1270a236574592a2697f4b02a67a2dc6
Created June 2, 2016 17:33
tmux 2.1 vs 2.2 default socket path
jyotty@pleione:~$ tmux list-sessions
0: 1 windows (created Mon May 16 14:29:38 2016) [121x58] (attached)
2: 1 windows (created Thu Jun 2 10:26:19 2016) [100x29]
jyotty@pleione:~$ brew update && brew upgrade tmux
🍺 /usr/local/homebrew/Cellar/tmux/2.2: 9 files, 639.4K
jyotty@pleione:~$ tmux list-sessions
error connecting to /private/tmp/tmux-501/default (No such file or directory)
jyotty@pleione:~!$ ps aux|grep tmux
jyotty 2719 0.0 0.0 2461140 1168 ?? Ss 16May16 1:57.13 tmux
@Mika-
Mika- / google-analytics.amp.html
Created October 18, 2015 10:34
Use Google Analytics in AMP HTML
<amp-pixel src="https://ssl.google-analytics.com/collect?v=1&amp;tid=UA-12345678-1&amp;t=pageview&amp;cid=$RANDOM&amp;dt=$TITLE&amp;dl=$CANONICAL_URL&amp;z=$RANDOM"></amp-pixel>
/*
* Required parameters:
* v = API version number (currently 1)
* tid = Google Analytics property identifier (UA-12345678-1)
* t = hit type
* cid = client id (you should implement this via cookie etc.)
* z = random string to bypass caching (amphtml generates this to $RANDOM variable)
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active July 12, 2024 11:15
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active June 30, 2024 04:14
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@traviskaufman
traviskaufman / jasmine-this-vars.md
Last active September 19, 2022 14:35
Better Jasmine Tests With `this`

Better Jasmine Tests With this

On the Refinery29 Mobile Web Team, codenamed "Bicycle", all of our unit tests are written using Jasmine, an awesome BDD library written by Pivotal Labs. We recently switched how we set up data for tests from declaring and assigning to closures, to assigning properties to each test case's this object, and we've seen some awesome benefits from doing such.

The old way

Up until recently, a typical unit test for us looked something like this:

describe('views.Card', function() {
@jbenet
jbenet / simple-git-branching-model.md
Last active June 17, 2024 14:53
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@nhoizey
nhoizey / screenshots.js
Created November 12, 2012 17:07
Take screenshots at different viewport sizes using CasperJS
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js http://example.com
*/
var casper = require("casper").create();
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 23, 2024 19:59
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname