Skip to content

Instantly share code, notes, and snippets.

View eddyw's full-sized avatar
🏠
Working from home

Eddy Wilson eddyw

🏠
Working from home
View GitHub Profile
@hurryabit
hurryabit / stack_safe.js
Last active June 14, 2022 09:34
Stack-safety for free?
// This gist contains the JavaScript version of the code from the blog post
// https://hurryabit.github.io/blog/stack-safety-for-free/
function triangular(n) {
if (n == 0) {
return 0;
} else {
return n + triangular(n - 1);
}
}
@danydev
danydev / zsh_history.sh
Created May 21, 2020 09:01
Store commands in history only if successful
# README: This allows you to store in your history file only commands
# with a successful status (or forced exited by you with signal 2).
# Put this content in your .zhsrc
# CREDITS: inspired by https://scarff.id.au/blog/2019/zsh-history-conditional-on-command-success/
# This function will be hooked to zshaddhistory.
# zshaddhistory is called before a history line is saved. See zshmisc(1).
function my_zshaddhistory() {
# Prevent the command from being written to history before it's
# executed; save it to LASTHIST instead. Write it to history
@iaincollins
iaincollins / Google Spreadsheet.js
Last active May 30, 2021 16:03
Example Node.js code to append to a Google Spreadsheet every hour
/**
* Append data to a Google Spreadsheet
*
* You will need a file called '.env' with the following values:
*
* - GOOGLE_ID (Google oAuth Client ID)
* - GOOGLE_SECRET (Google oAuth Client Secret)
* - GOOGLE_REFRESH_TOKEN (Google oAuth Refresh Token)
* - GOOGLE_SPREADSHEET_ID (Google Spreadsheet ID)
*
@jarshwah
jarshwah / launch.json
Created April 23, 2017 11:28
Webpack Source Maps with vscode debugging
// debug config for running project under vscode debugger
{
"version": "0.2.0",
"configurations": [
{
"trace": true,
"name": "Chrome Debug",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8000/",
@Daniel-Hug
Daniel-Hug / collision-detection.js
Last active March 3, 2024 04:02
JS functions: check if 2 rectangles intersect, are touching, or if one contains the other
// Check if rectangle a contains rectangle b
// Each object (a and b) should have 2 properties to represent the
// top-left corner (x1, y1) and 2 for the bottom-right corner (x2, y2).
function contains(a, b) {
return !(
b.x1 < a.x1 ||
b.y1 < a.y1 ||
b.x2 > a.x2 ||
b.y2 > a.y2
);
@Bhavdip
Bhavdip / sketch-never-ending.md
Created October 6, 2016 15:53
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

// @copyright
// © 2009-2012 Nicholas C. Zakas
// © 2012-2016 Jarosław Foksa
//
// @doc
// https://drafts.csswg.org/css-syntax
//
// @info
// CSS tokenizer based on TokenStream.js and Tokens.js from CSSLint.
@hsleonis
hsleonis / better-font-smoothing.css
Last active January 17, 2024 00:16
Better font smoothing in cross browser
html {
/* Adjust font size */
font-size: 100%;
-webkit-text-size-adjust: 100%;
/* Font varient */
font-variant-ligatures: none;
-webkit-font-variant-ligatures: none;
/* Smoothing */
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
@19h
19h / reset.js
Created February 19, 2013 22:51
Node.js — Clear Terminal / Console. Reset to initial state.
console.reset = function () {
return process.stdout.write('\033c');
}
@yeah
yeah / remove_diacritics.js
Created October 13, 2011 10:55
Remove diacritics (Umlauts, Accents, Special characters) in JavaScript
var diacriticsMap = [
{'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
{'base':'AA','letters':/[\uA732]/g},
{'base':'AE','letters':/[\u00C4\u00C6\u01FC\u01E2]/g},
{'base':'AO','letters':/[\uA734]/g},
{'base':'AU','letters':/[\uA736]/g},
{'base':'AV','letters':/[\uA738\uA73A]/g},
{'base':'AY','letters':/[\uA73C]/g},
{'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},
{'base':'C', 'letters':/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},