Skip to content

Instantly share code, notes, and snippets.

View bgoonz's full-sized avatar
🎯
learning

Bryan C Guner bgoonz

🎯
learning
View GitHub Profile
@ourmaninamsterdam
ourmaninamsterdam / LICENSE
Last active April 24, 2024 18:56
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@Sacristan
Sacristan / push_commits_by_chunks.sh
Last active April 6, 2024 15:14
Push commits by chunks
REMOTE=origin
BRANCH=$(git rev-parse --abbrev-ref HEAD)
BATCH_SIZE=10
# check if the branch exists on the remote
# if git show-ref --quiet --verify refs/remotes/$REMOTE/$BRANCH; then
# # if so, only push the commits that are not on the remote already
# range=$REMOTE/$BRANCH..HEAD
# else
# # else push all the commits
@bgoonz
bgoonz / vscode-settings-June2023.jsonc
Created June 27, 2023 21:51
vscode-settings-June2023.jsonc
{
//----------------beginning of editor settings--------------------\\
"editor.comments.ignoreEmptyLines": false,
"editor.trimAutoWhitespace": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.definitionLinkOpensInPeek": true,
"editor.fastScrollSensitivity": 9,
"editor.suggest.shareSuggestSelections": true,
"editor.fontSize": 12,
"editor.fontFamily": "Consolas, 'Courier New', monospace",
@bendc
bendc / nodelist-iteration.js
Created January 13, 2015 14:39
ES6: Iterating over a NodeList
var elements = document.querySelectorAll("div"),
callback = (el) => { console.log(el); };
// Spread operator
[...elements].forEach(callback);
// Array.from()
Array.from(elements).forEach(callback);
// for...of statement
@unders
unders / git commands.bash
Created October 20, 2012 15:22
Gist commands
Reference: http://gitimmersion.com/
# Pretty Git log
alias glog='git log --pretty="format:%C(yellow)%h %C(green)%s%C(blue)%d%C(white) - %ar - %an - %ad" --graph --date=short'
hist= log --pretty=format:\"%C(yellow)%h%Creset %ad | %C(green)%s%C(blue)%d%Creset [%an]\" --graph --date=short
# Reverting a Commit (safe in pushed to a remote branch)
git revert HEAD
# REMOVING COMMITS FROM A BRANCH
@Ambratolm
Ambratolm / money-raw-value.js
Last active February 23, 2022 19:09
Convert a formatted money string value (that may contain currencies, decimals, brackets ...etc) to a raw numeric value (to use it in calculations).
function moneyRawValue(value = 0, decimalSeparator = ",") {
if (typeof value === "number") return value;
const rawValue = parseFloat(
value
.replace(/\((?=\d+)(.*)\)/, "-$1")
.replace(new RegExp(`[^0-9-${decimalSeparator}]`, "g"), "")
.replace(decimalSeparator, ".")
);
return isNaN(rawValue) ? 0 : rawValue;
}
@sindresorhus
sindresorhus / get-latest-pic-facebook.js
Created October 28, 2013 13:16
Get latest picture from Facebook user using FQL
var endpoint = 'https://graph.facebook.com/fql';
var accessToken = '';
var userId = '';
var q = 'SELECT caption, src_big FROM photo WHERE aid IN(SELECT aid FROM album WHERE owner = ' + userId + ' ORDER BY modified DESC LIMIT 1) ORDER BY modified DESC LIMIT 1';
var url = endpoint + '?access_token=' + accessToken + '&q=' + q;
@sindresorhus
sindresorhus / instagram-recent-photos.js
Created October 21, 2013 09:33
Get recent photos from Instagram
function getRecentInstagramPhotos(userId, accessToken, count, cb) {
var url = 'https://api.instagram.com/v1/users/' + userId + '/media/recent?access_token=' + accessToken + '&count=' + count;
$.getJSON(url, function (response) {
cb(response.data);
});
}
var userId = '';
var accessToken = '';
getRecentInstagramPhotos(userId, accessToken, 20, function (photos) {
@sindresorhus
sindresorhus / git-pulley.sh
Created May 7, 2012 20:01
Git merge squash author commit and push - cheatsheet
git checkout master
git checkout -b bug123
git pull http://repourl.git branch
git log | grep "Author" | head -1 # get the author
git checkout master
git merge --squash bug123
git commit -a --author="Author" --message="Close #1: Title. Fixes #666"
git push origin master
@sindresorhus
sindresorhus / node-child-process-perf-sync-vs-async.md
Last active February 16, 2022 07:17
Results are as expected. Async comes with a slight overhead because of the event loop, but has many other benefits. So unless you know you won't need it, go for async.

Measuring sync vs async child processes in Node.js

  • macOS 10.12.3
  • Node.js 7.4.0

childProcess

const childProcess = require('child_process');