Skip to content

Instantly share code, notes, and snippets.

View beaucharman's full-sized avatar
💭
🦄 Hackin'

Beau beaucharman

💭
🦄 Hackin'
View GitHub Profile
@beaucharman
beaucharman / mixin.js
Last active May 25, 2016 06:37
Experimenting with React Higher Order Components as Mixins
// https://gist.github.com/sebmarkbage/ef0bf1f338a7182b6775#gistcomment-1770639
// "If your higher order component need state or lifecycle methods use this:""
const hoc = C => class _hoc extends React.Component {
render() {
return <C {...this.props}/>;
}
}
// "If you don´t need state or lifecycle methods on your HOC this snip is more functional:""
const hoc = C => _hoc(props) => {
return <C { ...props }/>;
@beaucharman
beaucharman / forEach.js
Last active May 23, 2016 03:56
A forEach for JavaScript objects
function forEach(obj, callback) {
Object.keys(obj).forEach((item) => {
return callback(obj, item)
})
}
// usage
let obj = { a: 1, b: 2, c: 3 }
let array = []
forEach(obj, function(obj, item) {
@beaucharman
beaucharman / recursiveFlatten.js
Last active May 23, 2016 23:27
Recursively flatten a JS array
function recursiveFlatten(array, ignoreObjects = false) {
let current = []
const arrayLength = array.length
function isType(obj, type = 'Object') {
return Object.prototype.toString.call(obj).indexOf(type) !== -1
}
for (let i = 0; i < arrayLength; i++) {
let result
@beaucharman
beaucharman / exercises.js
Last active May 13, 2016 12:53
Various exercises from eloquentjavascript.net
// Chapter two - exercise one
// c2e1();
function c2e1() {
var hashCount = 1;
var hashes = '#';
for (;hashCount <= 7; hashCount++) {
console.log(hashes);
hashes += '#';
}
}
@beaucharman
beaucharman / reclaim.txt
Created January 21, 2015 12:48
To reclaim ownership of the .npm directory execute `sudo chown -R $(whoami) ~/.npm`
// To reclaim ownership of the .npm directory execute
sudo chown -R $(whoami) ~/.npm
@beaucharman
beaucharman / gist:e13ecd69ae3ed4fe6510
Last active August 29, 2015 14:06
Terminal Awesomness
sudo nano ~/.bash_profile
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='\e[0;35m⌘\e[0;34m \w/\e[0m\e[0;32m$(parse_git_branch)\e[0m '
alias projectlt3="cd ~/Sites/lt3-development/"

Terminal Notes and Snippets

Configuration

Show full path in finder

defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES

Accessibilty Considerations

Images

  • Provide Alt attributes to describe what the subject of the image asset is.
  • Informative and descriptive file name (Great for SEO too :D).
  • For images that are for pure decoration, apply alt="null" and do not provide a title attribute to mark as safely ignore for Assistive Technology.

Anchors

@beaucharman
beaucharman / jquery.equalHeightColumns.js
Last active December 31, 2015 09:49
Responsive, Equal Height Columns
/**
*
* Equal Height Columns
*
* Horizontally Even Columns
*
* @param {object}
* @param {boolean} 'responsive'
* @param {integer} 'responsiveDelay'
* @param {string} 'bindTo'
/**
* accessibleDropDownMenu.js
*
* jquery.accessibleDropDownMenu.js
* @version 2.0 | 14th January 2014
* @author Beau Charman | @beaucharman | http://www.beaucharman.github.io
* @link https://gist.github.com/beaucharman/7348970 |
* http://jsfiddle.net/beaucharman/X2ArC/
* @license MIT license
*/