Skip to content

Instantly share code, notes, and snippets.

View benschac's full-sized avatar
🤓
doing beep boops

benjamin benschac

🤓
doing beep boops
View GitHub Profile
@pksunkara
pksunkara / config
Last active July 25, 2024 15:53
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta
@johnpolacek
johnpolacek / .gitconfig
Last active July 9, 2024 12:14
My current .gitconfig aliases
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
aa = add -A .
// Bonfire: Diff Two Arrays
// Author: @benschac
// Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays?solution=function%20diff(arr1%2C%20arr2)%20%7B%0A%20%20var%20check%20%3D%20arr1%3B%0A%20%20var%20checker%20%3D%20arr2%3B%0A%20%20%0A%20%20var%20filtered1%20%3D%20check.filter(function(el)%20%7B%0A%20%20%20%20%20%20%20if(checker.indexOf(el)%20%3D%3D%20-1)%20%7B%0A%20%20%20%20%20%20%20%20%20return%20el%3B%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D)%3B%0A%20%20%0A%20%20%20var%20filtered2%20%3D%20checker.filter(function(el)%20%7B%0A%20%20%20%20%20%20%20if(check.indexOf(el)%20%3D%3D%20-1)%20%7B%0A%20%20%20%20%20%20%20%20%20return%20el%3B%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D)%3B%0A%20%20%0A%20%20return%20filtered1.concat(filtered2)%3B%0A%7D%0A%0A%0A%0A%0Adiff(%5B1%2C%202%2C%203%2C%205%5D%2C%20%5B1%2C%202%2C%203%2C%204%2C%205%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function diff(arr1, arr2) {
var check = arr1;
var checker = arr2;
var filtered1 =
@datchley
datchley / react-redux-style-guide.md
Last active February 13, 2024 14:30
React + Redux Style Guide
@daftAnorak
daftAnorak / lint-on-changed-files-only.sh
Created February 15, 2017 23:55
Run eslint against a git commit (in this case, `HEAD`). Usually needed when migrating code that doesn't already have a lint.
# !/bin/bash
FILES=`{ git diff --name-only HEAD; \
git ls-files --others --exclude-standard; } \
| grep '\.js$' \
| grep -v '^.*exclude-folder.*$'`
node_modules/.bin/eslint $FILES -f table --color --quiet
@thchia
thchia / combineUseReducers.js
Last active March 27, 2023 10:15
Combining the useReducers Hook
// Main
function combineReducers(reducerDict) {
const _initialState = getInitialState(reducerDict);
return function(state = _initialState, action) {
return Object.keys(reducerDict).reduce((acc, curr) => {
let slice = reducerDict[curr](state[curr], action);
return { ...acc, [curr]: slice };
}, state);
};
}
@david-crespo
david-crespo / README.md
Last active February 15, 2023 21:30
Download FB tagged photos and videos

Download photos and videos you're tagged in on Facebook

Why

When you download an archive of your Facebook account, Facebook includes photos and videos you've uploaded, but not photos and videos you're tagged in that were uploaded by other people. This is a script to automatically download those.

Setup

This requires Python 3.

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active July 20, 2024 05:29
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@Beneboe
Beneboe / how-to-setup-verified-commits.md
Last active June 18, 2024 17:16
How to Setup Verified Commits on Github
@slikts
slikts / react-memo-children.md
Last active June 16, 2024 14:24
Why using the `children` prop makes `React.memo()` not work

nelabs.dev

Why using the children prop makes React.memo() not work

I've recently ran into a pitfall of [React.memo()][memo] that seems generally overlooked; skimming over the top results in Google just finds it mentioned in passing in a [React issue][regit], but not in the [FAQ] or API [overview][react-api], and not in the articles that set out to explain React.memo() (at least the ones I looked at). The issue is specifically that nesting children defeats memoization, unless the children are just plain text. To give a simplified code example:

const Memoized = React.memo(({ children }) => (<div>{children}</div>));
// Won't ever re-render
<Memoized>bar</Memoized>
// Will re-render every time; the memoization does nothing