Skip to content

Instantly share code, notes, and snippets.

@stevenocchipinti
stevenocchipinti / promises.js
Created October 13, 2023 03:54
Sequential promises
// https://jrsinclair.com/articles/2019/how-to-run-async-js-in-parallel-or-sequential/
const job = (name, delay) =>
new Promise((res) => {
setTimeout(() => {
console.log(`Job(${name}) resolving after ${delay}`);
res();
}, delay);
});
@stevenocchipinti
stevenocchipinti / README.md
Last active September 27, 2022 05:31
Play a random song when a GPIO button is pressed

Play a random song when a GPIO button is pressed

Dependencies for python

sudo pip3 install python-vlc
sudo apt-get install python3-rpi.gpio

Or for python2

@stevenocchipinti
stevenocchipinti / hover.js
Created January 30, 2019 23:47
Generate a 20% brighter color for hover
// https://gist.github.com/mjackson/5311256
// http://xahlee.info/js/js_convert_decimal_hexadecimal.html
/**
* Converts an RGB color value to HSV. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSV_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and v in the set [0, 1].
*
* @param Number r The red color value
@stevenocchipinti
stevenocchipinti / README.md
Last active October 19, 2018 01:40
An interactive version of `yarn run` for fish shell

yarnrun

An interactive version of yarn run for fish shell

Dependencies

Requires my pecorb gem (or an alternative)

gem install pecorb
@stevenocchipinti
stevenocchipinti / readme.md
Created September 4, 2018 07:33
A `serve-live` command for fish

serve-live

A live reload server command for fish

Installation

yarn global add browser-sync
# https://www.youtube.com/watch?v=Ct6BUPvE2sM
def ouhh(left, right)
if left == "pen" && right == "apple"
"apple-pen"
elsif left == "pen" && right == "pineapple"
return "pineapple-pen"
elsif left == "apple-pen" && right == "pineapple-pen"
return "pen-pineapple-apple-pen"
end
@stevenocchipinti
stevenocchipinti / install.sh
Created May 3, 2017 03:56
Laptop bootstrap
# Homebrew
if ! hash brew 2> /dev/null; then
echo "You need brew, installing it now..."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Generic stuff
brew install cask wget tree nmap ctags git hub bash-completion
brew cask install iterm2 mattr-slate slack docker
@stevenocchipinti
stevenocchipinti / app.rb
Created May 3, 2017 03:55
Number guessing
require 'io/console'
print "Player 1, pick a number: "
number = STDIN.noecho(&:gets)
puts
puts "Player 2, try to guess the number!"
print "Guess: "
guess = gets
@stevenocchipinti
stevenocchipinti / regex.md
Last active February 1, 2018 17:51
Regex

Regular Expressions

  • Simple characters

    • abc
  • Quantifiers

    • * 0 or more
    • + 1 or more
  • ? 0 or 1

@stevenocchipinti
stevenocchipinti / JavaScriptFundamentals.md
Last active July 30, 2018 01:58
JavaScript Fundamentals

JavaScript Crash Course

A list of things to learn / talk about in order to learn the fundamentals of JavaScript and modern tools for dev

History