Skip to content

Instantly share code, notes, and snippets.

View chrisforrette's full-sized avatar
🙃
Codesplodin'

Chris Forrette chrisforrette

🙃
Codesplodin'
View GitHub Profile
@chrisforrette
chrisforrette / config.js
Created January 19, 2018 00:24
.storybook/config.js
import { configure } from '@kadira/storybook'
import './addons'
// Get all files under `/src/components` that end with '.stories.js'
const req = require.context('../src/components', true, /\.stories\.js$/)
function loadStories () {
req.keys().forEach((filename) => req(filename))
}

aws-cli bash helper functions

The official AWS command line tools, have support for configuration profiles. See Configuring the AWS Command Line Interface - Named Profiles.

Managing multiple profiles with the AWS CLI itself is relatively straight forward, switching between them with --profile flag on the command line or the AWS_PROFILE environment variable.

These helpers extend that functionality for convenience with other tools in the ecosystem.

aws-profile

@chrisforrette
chrisforrette / reduce.js
Created December 17, 2016 00:52
Change object value to object
Object
.keys(obj)
.reduce((accumulator, key) => {
accumulator[key] = {
'newkey': obj[key]
};
return accumulator;
}, {})
{
"name": "",
"version": "0.1.0",
"description": "",
"main": "",
"scripts": {
"build:breakpoints": "json-sass -i ./static/breakpoints.json -o ./static/scss/base/_breakpoints.scss -p '$breakpoints: '"
}
}
@chrisforrette
chrisforrette / webpack.config.js
Created November 15, 2016 01:31
Remo webpack config
var webpack = require('webpack');
var env = process.env.NODE_ENV;
var production = env === 'production';
var staging = env === 'staging';
var optimize = production || staging;
// Plugins
var plugins = [];
import csv
from django.http import HttpResponse
def serve_report(filename, fieldnames, data):
"""
Generate a CSV with the passed in `fieldnames` and `data`
and return a response with it as an attachment as `filename` + .csv
"""
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
]
}
@chrisforrette
chrisforrette / package.json
Created November 3, 2015 22:52
Build/watch scripts for node-sass
{
"scripts": {
"watch:css": "nodemon --watch static/scss --ext scss,json --exec \"npm run build:css\"",
"build:css": "node-sass ./static/scss/app.scss --precision 7 --stdout --source-map-embed --include-path ./node_modules/ | postcss -u autoprefixer -o ./static/build/css/app.css",
}
}
@chrisforrette
chrisforrette / circle.yml
Last active September 27, 2016 21:41
CircleCI Libsass Configuration
dependencies:
cache_directories:
- sassc
- libsass
post:
- if [[ ! -e sassc ]]; then git clone git@github.com:sass/sassc.git sassc; fi
- if [[ ! -e libsass ]]; then git clone --recursive git@github.com:sass/libsass.git && cd sassc && export SASS_LIBSASS_PATH=$(readlink -f ../libsass) && make && cd ..; fi
- ln -s sassc/bin/sassc ~/bin/sassc
@chrisforrette
chrisforrette / gist:808bcce870837d21494e
Created February 12, 2015 00:13
Modernizr retina detection
Modernizr.addTest('retina', function() {
// starts with default value for modern browsers
var dpr = window.devicePixelRatio ||
// fallback for IE
(window.screen.deviceXDPI / window.screen.logicalXDPI) ||
// default value
1;