Skip to content

Instantly share code, notes, and snippets.

@benknight
benknight / gist:0a13088c4f152639ed97
Last active August 29, 2015 14:21
100vh workaround
var mediaQueryList = window.matchMedia('(orientation: portrait)');
function setMaxHeight (mediaQueryList) {
var vh = window.innerHeight;
var vw = window.innerWidth;
var header = document.querySelector('.site-header');
if (mediaQueryList.matches) {
header.style.height = Math.max(vh, vw);
} else {
@UsmanNaeem101
UsmanNaeem101 / Setup
Last active January 1, 2016 12:39
Setting up linux properly
sudo apt-get install curl zsh vim tmux git git-core
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev
\curl -sSL https://get.rvm.io | bash
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.0.0-p353
rvm use 2.0.0-p353 --default
ruby -v
rvm alias create default 2.0.0-p53
class Nav extends React.Component {
constructor() {
super();
this.onNav = this.onNav.bind(this);
}
onNav(idx) {
// do something with `this` and `idx`
}
render() {
return (
hg clone https://bitbucket.org/ZyX_I/vim
cd vim
hg update 24-bit-xterm
cd src && make autoconf && cd ..
./configure \
--enable-gui=no \
--without-x \
--enable-multibyte \
--with-tlib=ncurses \
@zalmoxisus
zalmoxisus / configureStore.dev.js
Last active August 25, 2016 15:14
Open Redux DevTools in a new window
import { createStore, applyMiddleware, compose } from 'redux';
// import { persistState } from 'redux-devtools';
import rootReducer from '../reducers';
import DevTools from '../containers/DevTools';
export default function configureStore(initialState) {
const finalCreateStore = compose(
DevTools.instrument(),
// persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore);
@cgmartin
cgmartin / gulpfile.js
Created February 8, 2015 21:03
Node ES6 istanbul, isparta, mocha-co gulpfile example
'use strict';
var gulp = require('gulp');
var del = require('del');
var mocha = require('gulp-mocha-co');
var istanbul = require('gulp-istanbul');
var isparta = require('isparta');
var coverageEnforcer = require('gulp-istanbul-enforcer');
var paths = {
server: {
function increment(props, state) {
return {
value: state.value + props.step,
};
}
function decrement(props, state) {
return {
value: state.value - props.step,
};
@jaredpalmer
jaredpalmer / EmailInput.jsx
Created November 29, 2017 18:06
Formik async email signup input
import React from 'react';
import debounce from 'utils/debounce';
class EmailInput extends React.Component {
checkEmail = value => {
// only check if the field passes Yup email validation first
if (
!this.props.form.errors[this.props.name].includes(
'invalid' /* or whatever your error message is*/
)
@ohanhi
ohanhi / joy-of-composition.md
Last active February 3, 2021 18:14
The Joy of Composition - Why stateless rendering is pure bliss

This is a proposal for a lightning talk at the Reactive 2015 conference.

NOTE: If you like this, star ⭐ the Gist - the amount of stars decides whether it makes the cut!

The Joy of Composition

Why stateless rendering is pure bliss

React just got stateless components, meaning that they are in essence pure functions for rendering. Pure functions make it dead simple - even fun - to refactor your views

@rodleviton
rodleviton / imagemagick-install-steps
Created May 26, 2014 07:37
Installing Image Magick on Ubuntu 14.04
sudo -i
cd
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y
wget http://www.imagemagick.org/download/ImageMagick-6.8.7-7.tar.gz
tar xzvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure --prefix=/opt/imagemagick-6.8 && make
checkinstall