Skip to content

Instantly share code, notes, and snippets.

View chris-kobrzak's full-sized avatar

Chris Kobrzak chris-kobrzak

View GitHub Profile
@chris-kobrzak
chris-kobrzak / git-rebase-all-feature-branches.sh
Last active July 13, 2017 11:07
Capture all feature branches in Git, update base branch (default `master`), rebase forks on it and, optionally, force push to the central repository.
#/usr/bin/env bash
baseBranch=master
if [[ $# -eq 1 ]]; then
baseBranch=$1
fi
echo "Update the repository..."
git fetch -p
echo
@chris-kobrzak
chris-kobrzak / delay.js
Created May 4, 2017 13:30
Then-able JavaScript setTimeout incarnation
function delay(milliseconds) {
return new Promise(
resolve => setTimeout(resolve, milliseconds)
)
}
@chris-kobrzak
chris-kobrzak / README-Git-workflow.md
Last active February 2, 2017 22:42
Git source control workflow (draft)
@chris-kobrzak
chris-kobrzak / logic-in-jsx-improved.js
Last active September 23, 2016 22:07
Less logic in JSX resulting in code that's easier to read and transpiled to a simpler and more compact block of code
render () {
const { visible } = this.props
let visibleContent
if (visible) {
visibleContent = this.getVisibleContent()
}
return (
<div className={ visible ? 'expanded' : 'collapsed' }>
{ visibleContent } // No more logic here and useless "null"
@chris-kobrzak
chris-kobrzak / logic-in-jsx.js
Last active January 13, 2017 18:35
Demonstrate poor practice of JSX intertwined with logic, coupled with multi-line ternary operator statements
render () {
const { visible } = this.props
return (
<div className={ visible ? 'expanded' : 'collapsed' }>
{
visible ? <div>
// Dozens of lines of JSX code here
// Dozens of lines of JSX code here
// Dozens of lines of JSX code here
// Dozens of lines of JSX code here
@chris-kobrzak
chris-kobrzak / es6-module-only-babel-transpilation-example.js
Last active April 20, 2016 08:06
Code sample with only ES6 modules transpiled by Babel
class TextInputControl extends _react2.default.Component {
constructor(props) {
super(props);
this.bindInstanceMethods('handleBlurEvent', 'handleChangeEvent');
this.handleChangeEventDebounced = (0, _debounce2.default)(this.handleChangeEvent, props.inputChangeDebounceWait);
}
bindInstanceMethods(...methods) {
methods.forEach(method => this[method] = this[method].bind(this));
@chris-kobrzak
chris-kobrzak / .babelrc
Created April 19, 2016 22:16
Pure ES6/React development environment
{
"presets": ["react"],
"plugins": ["transform-es2015-modules-commonjs"]
}
@chris-kobrzak
chris-kobrzak / Create app symlinks.sh
Last active January 4, 2016 15:09
Use this script to create shortcuts to commonly used applications. Then drag the directories to the OS X Dock to enable the Downloads-like shortcut functionality.
@chris-kobrzak
chris-kobrzak / .babelrc
Created January 1, 2016 23:06
Minimal configuration for bundling React classes with ES6 and JSX syntaxes
{
"presets": ["es2015", "react"]
}
@chris-kobrzak
chris-kobrzak / Vim cheat sheet.md
Last active August 16, 2018 11:05
My Vim editor cheat sheet

Saving files

Save file even if it was opened without write permissions

:w !sudo tee %

Write/append lines from file to another file (optionally overwrite)

:5,25w [!] [>>] new_file