Skip to content

Instantly share code, notes, and snippets.

View NoriSte's full-sized avatar

Stefano Magni NoriSte

View GitHub Profile
@NoriSte
NoriSte / README.md
Last active August 22, 2019 14:33
NPM as a project depenency

Running node index.js is the same of running npm run cy:run --record --key <YOUR_RECORDING_KEY>.

I used it here to make the npm run dynamic without changing the way I managed it.

@NoriSte
NoriSte / README.md
Created October 29, 2019 11:00
FileVault and user passphrases

To setup a different passphrase for FileVault and for the user (so to use your Mac two different passphrases are required):

  • create a new "Disk Decrypt" user with the passphrase used for FileVault
  • disable FileVault auto-login with $ sudo defaults write /Library/Preferences/com.apple.loginwindow DisableFDEAutoLogin -bool YES
  • remove the current user from the ones that could unlock FileVault with $ sudo fdesetup remove -user USER_NAME
  • make sure the "Disk Decrypt" can't administrate your Mac

That's all 🎉

@NoriSte
NoriSte / README.md
Created December 4, 2019 06:59
Git log beautified
$ cat .gitconfig
# This is Git's per-user configuration file.
[alias]
    gr = log --graph --full-history --all --color --tags --decorate --pretty=format:\"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s %x1b[33m%aN <%ae>%x1b[0m (%aI)\"
@NoriSte
NoriSte / typings.ts
Last active October 9, 2020 06:41
Re-implementing Recoil APIs / article gists
// @see https://github.com/NoriSte/recoil-apis
/*
* The internally stored Recoil values
*/
export type CoreRecoilValue<T> = {
key: string;
subscribers: Subscriber[];
} & (
| {
@NoriSte
NoriSte / typings.ts
Last active October 12, 2020 06:33
Re-implementing Recoil APIs / article gists
// @see https://github.com/NoriSte/recoil-apis
export type RecoilStores = Record<
string,
Record<string, CoreRecoilValue<unknown>>
>;
@NoriSte
NoriSte / typings.ts
Last active October 12, 2020 06:45
Re-implementing Recoil APIs / article gists
// @see https://github.com/NoriSte/recoil-apis
export type Atom<T> = { key: string; default: T };
export type Selector<T> = {
key: string;
get: ({ get }: { get: GetRecoilValue }) => T;
set?: (
{
get,
@NoriSte
NoriSte / core.ts
Last active October 15, 2020 06:51
Re-implementing Recoil APIs / article gists
// @see https://github.com/NoriSte/recoil-apis
/**
* Get the current Recoil Atom' value
*/
const coreGetAtomValue = <T>(recoilId: string, atom: Atom<T>): T => {
const coreRecoilValue = getRecoilStore(recoilId)[atom.key];
// type-safety
if (coreRecoilValue.type !== "atom") {
@NoriSte
NoriSte / hoc.ts
Created October 15, 2020 06:35
Re-implementing Recoil APIs / article gists
// @see https://github.com/NoriSte/recoil-apis
// core function, it requires the id
function logId(id: string) {
console.log(id);
}
// create a new function that accesses the id thanks to its closure
function createLogid(id: string) {
@NoriSte
NoriSte / core.ts
Last active October 19, 2020 06:15
Re-implementing Recoil APIs / article gists
// @see https://github.com/NoriSte/recoil-apis
/**
* Provide a Recoil Value setter
* @private
*/
const coreSetRecoilValue = <T>(
recoilId: string,
recoilValue: RecoilValue<T>,
nextValue: T
@NoriSte
NoriSte / core.ts
Created October 19, 2020 06:21
Re-implementing Recoil APIs / article gists
// @see https://github.com/NoriSte/recoil-apis
/**
* Register a new Recoil Value idempotently.
* @private
*/
export const registerRecoilValue = <T>(
recoilId: string,
recoilValue: RecoilValue<T>
) => {