Skip to content

Instantly share code, notes, and snippets.

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

Beau beaucharman

💭
🦄 Hackin'
View GitHub Profile

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

Terminal Notes and Snippets

Configuration

Show full path in finder

defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES

@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/"
@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 / 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 / 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 / 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 / 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 / reactLifecycleMethods.notes.md
Last active March 15, 2019 16:09
Notes: A cheat sheet for the React Component Lifecycle Methods

Mounting

componentWillMount
componentWillMount()
  • setState() can be called here and won't cause a rerender

@beaucharman
beaucharman / pureSplice.js
Last active February 22, 2019 21:34
An ES6 / pure function implementation of the JS splice method that returns an object of the new array and the removed elements
function safeSplice(array, start, deleteCount, ...replace) {
const removed = array.splice(start, deleteCount, ...replace)
return {
array: array,
removed: removed,
}
}
/** usage
const array = [1, 2, 3, 4, 5, 6]