Skip to content

Instantly share code, notes, and snippets.

View acdlite's full-sized avatar

Andrew Clark acdlite

View GitHub Profile
@acdlite
acdlite / pureRenderMixin.js
Last active July 17, 2019 09:29
Pure Render Mixin in ES6
function pureRenderMixin(Component) {
Component.prototype.shouldComponentUpdate(nextProps, nextState) {
return !shallowEqual(this.props, nextProps) ||
!shallowEqual(this.state, nextState);
}
return Component;
}
class MyComponent extends React.Component {}
class Store {
constructor(state = {}) {
this.state = state;
}
getState() {
return this.state;
}
}
@acdlite
acdlite / convert-video-for-web.sh
Last active August 21, 2017 20:30
Convert videos for web
#!/bin/bash
# Based on http://asisolve.com/ffmpeg-encoding-settings-for-web-video/
for f in src/*.mov
do
name=$(basename $f .mov)
# Convert to mp4
ffmpeg -i $f -vcodec libx264 -preset slow -profile main -crf 25 -acodec libfdk_aac -ab 64k dist/$name.mp4
@acdlite
acdlite / SassMeister-input.scss
Created July 18, 2014 15:57
Generated by SassMeister.com.
// ----
// Sass (v3.3.10)
// Compass (v1.0.0.alpha.20)
// Base.Sass (v1.3.3)
// ----
@import "base.sass/*";
$anonymous-placeholders: ();
@acdlite
acdlite / SassMeister-input.scss
Created July 18, 2014 15:56
Generated by SassMeister.com.
// ----
// Sass (v3.3.10)
// Compass (v1.0.0.alpha.20)
// Base.Sass (v1.3.3)
// ----
@import "compass";
@import "base.sass/*";
@acdlite
acdlite / SassMeister-input.scss
Created March 10, 2014 14:37
Generated by SassMeister.com.
// ----
// Sass (v3.3.3)
// Compass (v1.0.0.alpha.18)
// Sassy Maps (v0.3.2)
// ----
@import "sassy-maps";
$__namespaces: ();
@acdlite
acdlite / gist:9168073
Last active August 29, 2015 13:56
Sass/Compass mixin for diagonal stripe pattern backgrounds
@mixin diagonal-stripe-pattern-background($color-1, $color-2, $ratio, $size) {
$ratio: percentage($ratio / 2);
@include background(linear-gradient(-45deg,
$color-1 (50% - $ratio),
$color-2 (50% - $ratio),
$color-2 50%, $color-1 50%,
$color-1 (100% - $ratio),
$color-2 (100% - $ratio)));
@include background-size($size $size);
}
@acdlite
acdlite / SassMeister-input.scss
Created November 4, 2013 20:40
More experimenting using maps to organize Susy grids (or any other kind of data). Essentially, this is just abstracting calls to map-set() and map-merge to make the syntax more friendly. Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
$_grids: ();
@mixin add-grid($g, $name) {
$_grids: map-merge($_grids, ($name: $g));
}
@acdlite
acdlite / SassMeister-input.scss
Created November 4, 2013 06:39
Experiment using Sass maps to organize Susy Next configuration. Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
$grid: (
small: 90% 8 1/4,
medium: 80% 8 1/4,
large: 80% 12 1/4,
);
@acdlite
acdlite / _color.scss
Last active December 27, 2015 08:28
Experiment using Sass maps to handle project-level configuration.
$brand-color: (
red: #cf383a,
blue: #1f98d4,
yellow: #e4cb14,
white-eggshell: #f2efe2,
white: #000000,
black: #ffffff
);
// Returns brand color