Skip to content

Instantly share code, notes, and snippets.

@leyanlo
leyanlo / LICENSE
Last active August 30, 2026 07:06
Download photos and videos from your authorized Procare parent gallery
MIT License
Copyright (c) 2026 Leyan Lo
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:
@leyanlo
leyanlo / 1core-download.py
Last active August 14, 2026 12:38
Download your own 1Core Family gallery from a private Charles session
#!/usr/bin/env python3
"""Download one 1Core Family gallery from a private Charles session.
This script uses only Python's standard library. It reads the most recent
successful GetChildIndividualGallery request from a Charles .chls file, keeps
the captured credentials in memory, and downloads the gallery page by page.
Usage:
python3 1core-download.py capture.chls "1Core Gallery"
// pancakes are sorted if they are ordered from 1 to N
function isSorted(pancakes) {
return pancakes.every((p, i) => p === i + 1);
}
function flip(pancakes) {
const instructions = [''];
while (!isSorted(pancakes)) {
const maxUnsorted = pancakes.findLastIndex((p, i) => p !== i + 1) + 1;
const flipCount = pancakes.indexOf(maxUnsorted) + 1;
const exampleSignals =
'acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab';
const charCount = {};
for (const char of exampleSignals
.split('')
.filter((char) => /[a-g]/.test(char))) {
charCount[char] = (charCount[char] ?? 0) + 1;
}
@leyanlo
leyanlo / arrayDiff.js
Created November 30, 2020 08:21
cassidoo 11/29/2020
function arrayDiff(arr, target) {
const seen = {};
return arr.reduce((numPairs, n) => {
const targetsFromN = { [n + target]: null, [n - target]: null };
numPairs += Object.keys(targetsFromN).reduce(
(seenFromN, targetFromN) => seenFromN + (seen[targetFromN] || 0),
0
);
seen[n] = (seen[n] || 0) + 1;
return numPairs;
@leyanlo
leyanlo / babyLisp.js
Last active October 13, 2020 12:31
cassidoo 10/11/2020 O(n) solution with validation
// cassidoo 10/11/2020 O(n) solution with validation
// https://buttondown.email/cassidoo/archive/4b882f72-2fc1-4b77-b574-0118a37f480c
function getValue(operator, a, b) {
switch (operator) {
case "add":
return a + b;
case "subtract":
return a - b;
case "multiply":
@leyanlo
leyanlo / webstorm-vs-vscode.md
Last active December 4, 2020 06:27
WebStorm vs VSCode

WebStorm vs VSCode

Tradeoffs

VSCode pros

  • Popular
  • MDX support
  • Can jump to files from console, e.g. when running eslint

VSCode cons

  • Cannot look at tab title and tell if file is new, modified, unstaged, or has errors
  • Cannot advance to next file in git view
@leyanlo
leyanlo / index.html
Last active February 17, 2020 05:59
momwordcloud.svg
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mom’s 70th</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
@leyanlo
leyanlo / camelCase_to_snake_case.sh
Last active August 30, 2018 00:08
Script to convert camelCase filenames to snake_case
#!/bin/bash
# Recurse through subdirectories and convert camelCase filenames to snake_case
for file in */**/*.* ; do
mv "$file" "$(echo $file|gsed -e 's/\([A-Z]\)/_\1/g' -e 's/^.\/_//'|awk '{print tolower($0)}')"
done
@leyanlo
leyanlo / README.md
Last active February 2, 2018 08:43 — forked from quagliero/README.md
Installing cpuminer-multi on macOS 10.13.2 (High Sierra)

Installing cpuminer-multi on macOS 10.13.2 (High Sierra)

This assumes you have brew installed and are comfortable using a terminal.

Following the guide on https://github.com/tpruvot/cpuminer-multi will likely lead to errors about invalid paths to OpenSSL, and neoscrypt errors to the tune of Undefined symbols for architecture x86_64 during the build. I managed to piece together different fixes into an installation that has worked for me. So I hope it works for you.

Requirements

Ensure a c compiler is installed. Type g++ in the terminal and continue with the xcode installation if necessary. If it prints clang: error: no input files, then you can proceed.