Skip to content

Instantly share code, notes, and snippets.

View regexyl's full-sized avatar

Regina Liu regexyl

View GitHub Profile
@regexyl
regexyl / hello_gist.py
Created June 2, 2021 02:12
Hello Gist
print("hello gist! This is my first time using this :)")
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe.skip("Greeter", function () {
it("Should return the new greeting once it's changed", async function () {
const Greeter = await ethers.getContractFactory("Greeter");
const greeter = await Greeter.deploy("Hello, world!");
await greeter.deployed();
console.log("greeter deployed to:", greeter.address);
@regexyl
regexyl / commands.sh
Last active April 8, 2022 01:35
Linux/MacOS commands I use a lot
# ***** FILE SYSTEM *****
# Find paths of all files beginning with a regex in the current directory
find . -regex '.*/learn.*' -maxdepth 1
# Move all files matching the regex to a folder ./learn
# Warning: An error will appear but it's ok, all files except for ./learn itself are moved
# mv: rename ./learn to learn/learn: Invalid argument
mv $(find . -regex '.*/learn.*' -maxdepth 1) learn
@regexyl
regexyl / .eslintrc.js
Created February 18, 2022 09:07 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@regexyl
regexyl / git.md
Last active March 31, 2022 01:42

Git Commands

Commit

git commit --allow-empty -m "trigger build" # Commit no new changes to trigger build
Amend to last commit

You should never amend public commits (i.e. already pushed to a public reop).

@regexyl
regexyl / regex.md
Last active February 25, 2022 13:43

Regex Cheatsheet

The JavaScript version.

Frequent Examples

Search for: [^moz-eg]

  1. "/example/": /\/example\/[a-z]+/i
  2. Switch words in a string
let re = /(\w+)\s(\w+)/;
let str = 'John Smith';

Frontend Tools

  • Bundlephobia: Find out bundle size, download times and composition percentages of NPM packages.

VSCode Settings

Mac Keyboard Shortcuts

Not exclusive to VSCode.

  • opt + backspace: Deletes 1 word to the left of cursor
  • opt + fn2 + backspace: Deletes 1 word to the right of cursor

Navigate

  • ^⌘→: Shift focused editor into right group
@regexyl
regexyl / TIL-2022-03.md
Last active March 31, 2022 10:13
TIL snippets in point form. This is the very first TIL note! Planning to do 1 TIL.md per month.

TIL - March 2022

31 Mar 2022

  • re: Obsidian scheduled backups - Tried to get launchd to work via plist at ~/Library/LaunchAgents/com.gilite-notes.notes.plist, but it didn't have enough permissions to access the Node files at /usr/local/bin/node.
    • Originally preferred launchd over cron since it allows the job to run right after the computer wakes from sleeping, if the job was supposed to run but the computer was in sleep mode.
    • Also attempted moving the plist to ~/Library/LaunchDaemons/ so that the job can be executed even if I'm logged out, but the same error as above occurred.
    • cron worked after a few tries, incl. setting the git config to replace https://github.com/ with git@github.com: since one of the errors specified fatal: could not read Username for 'https://github.com': No such file or directory. (see this)
  • To get over the same error wit
@regexyl
regexyl / diceCombinations.py
Created March 28, 2023 12:09
Solving the leftover dice combinations problem
from functools import cache
"""
You are throwing a dice for a fixed number of times (`throwCount`), of which
you know the average of the total score. The total score is calculated by
adding up all the dice scores from each throw. You only know the score of a
few of the dice throws.
Find all possible combinations of the remaining dice that fulfill
the above information.