Skip to content

Instantly share code, notes, and snippets.

View kvendrik's full-sized avatar

Koen Vendrik kvendrik

View GitHub Profile
@kvendrik
kvendrik / .gitignore
Last active March 10, 2023 13:10
Scaffold Scripts
.scaffold_last_fetch_date
.scaffold_last_project_path
@kvendrik
kvendrik / or.bash
Last active June 29, 2019 18:11
Medium Article: or
function __git_is_repository() {
git -C "$1" rev-parse --is-inside-work-tree &> /dev/null
}
function __git_get_remote_url() {
local remote_name remote_url repository_path
remote_name=$([ -n "$1" ] && echo "$1" || echo origin)
repository_path="$2"
if [ -n "$repository_path" ]; then
remote_url="$(git -C "$repository_path" config --get remote."${remote_name}".url)"
@kvendrik
kvendrik / yr.bash
Last active June 29, 2019 17:56
Medium article: Yarn Run
autoload bashcompinit
bashcompinit
function __find_closest_npm_package {
if [ -f 'package.json' ]; then
echo 'package.json'
return
fi
current_relative_path=''
while [ ! -f "package.json" ]; do
@kvendrik
kvendrik / repositories.bash
Created June 20, 2019 21:58
Medium Article: repositories code from dotfiles
autoload bashcompinit
bashcompinit
$REPOSITORIES_DIRECTORY='~/repos'
function re() {
[ -z "$1" ] && echo "$REPOSITORIES_DIRECTORY" || echo "$REPOSITORIES_DIRECTORY/$1"
}
function r() {
  • Better link between Invision and Github
  • Click on translations to see their definition
@kvendrik
kvendrik / Search-memoized.jsx
Created April 9, 2019 13:48
Medium Article <Search />
class Search extends React.Component {
render() {
  return <input onChange={this.handleChange} />;
  }
 
  handleChange({target: {value}}) {
  this.doSearch(value);
  }
 
  @memoize
@kvendrik
kvendrik / Search.jsx
Created April 9, 2019 13:47
Medium Article <Search />
class Search extends React.Component {
render() {
  return <input onChange={this.handleChange} />;
  }
 
  handleChange({target: {value}}) {
  this.doSearch(value);
  }
 
  @debounce(200)
@kvendrik
kvendrik / bind.js
Created April 9, 2019 11:54
Bind decorator Medium article
function bind(classContex) {
return method.bind(classContex);
}
@kvendrik
kvendrik / Button.jsx
Last active April 9, 2019 11:55
Medium <Button /> Example
class Button extends React.PureComponent {
  render() {
  return <button onClick={this.handleClick} />;
  }
 
  @bind
  handleClick() {
// do things
}
}
@kvendrik
kvendrik / debounce.ts
Created April 3, 2019 19:19
Debounce fun
function debounce(method, timing) {
let canExecute = true;
return (...args) => {
if (!canExecute) {
return;
}
method(...args);
canExecute = false;
setTimeout(() => {
canExecute = true;