Skip to content

Instantly share code, notes, and snippets.

View joshdcomp's full-sized avatar

Josh Compton joshdcomp

View GitHub Profile
@joshdcomp
joshdcomp / _icon.es16.jsx
Last active August 18, 2016 15:07
Generic icon React component for use with SVG glyphs
import React, { Component } from 'react';
// _icon is my namespacing choice for glyphs--it could easily be set
// as an env variable
export default class Icon extends Component {
fullName(href='') {
return `#${href}_icon-${this.props.glyph}`;
}
render() {
@joshdcomp
joshdcomp / video-hero.js
Last active June 21, 2016 19:41
real quick background video js class
function Video_Hero(opts) {
this.$container = opts.$container;
this.videoClasses = opts.videoClasses;
this.basePath = opts.basePath;
this.baseFileName = this.$container.data('base-filename');
}
Video_Hero.prototype.fullPath = function (ext) {
return [this.basePath, this.baseFileName, ext].join('');
};

Readme

  • dependencies: environment requirements (eg: sass, grunt, ruby v2.4.1)
  • hello world: steps to get up and running

Wiki

  • workflow notes: general notes on the order of tasks, gotchas, branching strategies, etc
  • populating an environment: where to get a database/data, where to put the data, notes on changes you need to make to this data
  • handoff notes: information we need to convey to the client, things we'll need to train the client on doing
  • launch checklist: tasks developers would need to do as part of launching a project (eg: clear seeded data, set up admin accounts for client, set up pages/environment configs)
@joshdcomp
joshdcomp / render-video-player.jsx
Last active March 29, 2016 01:16
way more robust
renderVideoPlayer: function () {
// Assume it's an http string, do this: https://gist.github.com/jlong/2428561
// if the link is a youtube or vimeo link, embed it, else do nothing
var reel_link = this.state.item.reel_link;
var link = document.createElement('a');
link.href = reel_link;
var embed_link;
switch (link.hostname) {
@joshdcomp
joshdcomp / Gruntfile.js
Created March 9, 2016 16:38
Gruntfile.js and corresponding package.json for setting up a browerify react dev environment through babel
// This was set up using the help of this tut:
//http://merrickchristensen.com/articles/gruntjs-workflow.html
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
autoprefixer: {
app: {
@joshdcomp
joshdcomp / .htaccess
Created March 9, 2016 16:36
.htaccess for one-page web apps: redirect everything except requests for filenames ending in `.png, .jpg, .gif, .jpeg, .bmp, .js, .css, or .svg` (you can add more to that list where you see those file endings)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.js|\.css|\.svg)$
RewriteRule ^(.*) /index.html [L]
</IfModule>
@joshdcomp
joshdcomp / reusable.js
Last active January 26, 2016 21:37
When writing event handlers, manipulate elements relative to the element was clicked to avoid unintended consequences.
/**
* The way this is written there are 2 major assumptions:
*
* 1) There will only ever be one `.email_subscribe` on the page (and if there’s more,
* they’re all going to open/close at the same time)
* 2) These elements will exist on document load…so if these things get built by js or are
* loaded after docload, these click events won’t do anything
*/
$('.subscribe-close').on('click', function(){
$('.email_subscribe').removeClass('email_subscribe--opened');
@joshdcomp
joshdcomp / reusable.js
Created January 26, 2016 21:20
When writing event handlers, manipulate elements relative to the element was clicked to avoid unintended concequences.
$('._ak-subscribe-close').on('click', function(){
$('._ak-email_subscribe').removeClass('_ak-email_subscribe--opened');
});
//becomes
$('._ak-subscribe-close').on('click', function(e){
var $wrapper = $(e.currentTarget).closest('._ak-email_subscribe')
$wrapper.removeClass('_ak-email_subscribe--opened');
});
// _AK is the global namespace convention we use for Attck-related stuff
var _AK = {
// array of hashes containing globalObject and callbacks for consumption in the _strobe method
strobeQueue: [],
// flag for publically checking to see if we're currently strobing
isStrobing = 0,
// **Internal method, don't use directly. Use `strobe`.** Recursive function that every 10ms evaluates
// an array of hashes for whether or not a callback can run based on certain globalObject.
_strobe: function() {
var cleanup = [];
alias ll='ls -la'
alias rm='rm -i'
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias sites='cd ~/Projects/sites'
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi