Skip to content

Instantly share code, notes, and snippets.

theptrk /
Last active Oct 4, 2020
bcrypt-nodejs bug - Invalid salt revision

Bug - Invalid salt revision

Whenever I ran compareSync(password, passwordHash) I would see the error

Invalid salt revision

What did it mean? Where did it come from?

This is the code in the library bcrypt-nodejs

minor = salt.charAt(2);
theptrk /
Last active Jun 23, 2020
pyenv - get available versions for installation

First check the python downloads page to view the current releases

$ open

This produces the list of ALL available pyenv versions

$ pyenv install --list

theptrk / openweather_api_example.html
Last active Jun 3, 2020
This uses the OpenWeather current weather data API:
View openweather_api_example.html
<!DOCTYPE html>
<title>Open Weather API</title>
<style type="text/css">
pre {
background-color: #f1f1f1;
padding: 5px;
margin: 5px;
border-radius: 5px;
theptrk / optional_chaining.js
Last active May 20, 2020
Optional Chaining in javascript - avoid crashing your app
View optional_chaining.js
// This is an example of Optional Chaining
const adventurer = {
name: 'Alice',
cat: {
name: 'Dinah'
const dogName =;
theptrk / app.js
Created May 18, 2020
This is a starter html snippet
View app.js
// js goes here
console.log("hello js")
theptrk / html_onsubmit.html
Created May 17, 2020
HTML onsubmit connected to javascript function using a todo list input example
View html_onsubmit.html
<!DOCTYPE html>
<title>Hello onsubmit</title>
<h1>Hello onsubmit</h1>
<form onsubmit="handleForm()">
<input type="text" name="todo" autocomplete="off">
<button type="submit">Create Todo</button>
theptrk /
Last active May 10, 2020
Sublime Text vim (vintage) remap `jj` to exit
  • Go to Sublime Text -> Preferences -> Key Bindings and add this to your Default (OSX).sublime-keymap
        "keys": ["j", "j"],
        "command": "_enter_normal_mode",
        "args": {
            "mode": "mode_insert"
        "context": [{"key": "vi_insert_mode_aware"}]
View recoverData.m
function X_rec = recoverData(Z, U, K)
% initialize recovered values
X_rec = zeros(size(Z, 1), size(U, 1));
for i = 1:size(X_rec,1)
% projected_x is (1, K)
projected_x = Z(i, :);
% initialize x
View projectData.m
function Z = projectData(X, U, K)
% Initalize
Z = zeros(size(X, 1), K);
% index to create Ureduce
Ureduce = U(:, 1:K)
for i=1:size(Z,1)