Skip to content

Instantly share code, notes, and snippets.

View Zodiase's full-sized avatar

Xingchen Hong Zodiase

View GitHub Profile
@Zodiase
Zodiase / isThisTestFileRunExplicitly.js
Created April 18, 2024 18:29
Skip test file unless explicitly targeted. This allows an "unfriendly" test file to live along other test files and not interfere "run all tests".
/**
* This test file should only be run explicitly. When that's the case, the command should look something like:
* npm run test ./some/test/folder/test-something.js
* which means the process arguments should be something like:
* [ "some/path/node", "some/path/mocha", "./some/test/folder/test-something.js" ]
* but we can not assume the third argument would always be a file path.
* So to evaluate this flag, the function should:
* 1. Check if argv[2] is likely a file path pointing at this file.
* 2. resolve argv[2] and compare with this file's absolute path.
*/
@Zodiase
Zodiase / reverse-singly-linked-list.ts
Created April 1, 2019 22:00
TypeScript: Reverse Singly-linked List
class SinglyLinkedListNode {
public data: any = null;
public next: SinglyLinkedListNode = null;
}
class SinglyLinkedList {
public static fromArray(items: any[]): SinglyLinkedList {
const list = new SinglyLinkedList();
list.head = items.reduceRight((acc, item) => {
@Zodiase
Zodiase / styled-sansProps.js
Created December 31, 2018 04:53
Allow some props to be only used in styling but not passed to DOM (or underlying components).
import React from 'react';
const wrapReactComponentToIgnoreSomeProps = (component, propsToOmit = {}) => {
const newComponent = (props) => {
const newProps = Object.entries(props).reduce(
(acc, [propName, propValue]) => {
if (propName in propsToOmit && propsToOmit[propName] === true) {
return acc;
}
@Zodiase
Zodiase / client__index.js
Last active June 17, 2018 05:53
Meteor App Template Files with React Setup
import '/imports/startup/client';
@Zodiase
Zodiase / 1 - Get paths and filenames from aliases.scpt
Last active February 26, 2024 09:57
Folder Action: Save Discover Statements to Evernote
# Expect input to be a list of file alias.
on run {aliasList, parameters}
set fileInfoList to {}
repeat with aliasItem in aliasList
set thePath to POSIX path of aliasItem
set theName to name of (info for aliasItem)
set end of fileInfoList to {thePath:thePath, theName:theName}
end repeat
@Zodiase
Zodiase / git-download.sh
Last active March 7, 2018 04:12
Download Git repo (clone without .git)
git-download() {
set -e
url="$1"
git_filename=$(basename "$url")
default_target=${git_filename%.git}
target=${2:-"$default_target"}
git clone --depth=1 "$url" "$target"
rm -rf "$target/.git"
@Zodiase
Zodiase / notes.md
Last active May 25, 2017 11:00
Fire Emblem Echoes: Shadows of Valentina Notes

Forging

Here are the requirements for forging new weapons.

Left side is the minimum (tested) forging levels and money required. Right side is the outcome (with level 0, of course).

(no options) means after forging to the max level, the item disappears from the list, meaning it's impossible to further forge it.

(no options as of lv.4) means so far I've tested forging this weapon to level 4 and haven't seen any options appearing for new weapons. Note that it is possible for options to appear when the weapon reaches maximum level.

@Zodiase
Zodiase / notes.md
Last active May 19, 2017 23:12
Zelda: Breath of the Wild Notes

Repairing cost of the legendary weapons:

Gerudo Town (Buliara)

Scimitar of the Seven: diamond Daybreaker(shield): diamond

Goron City (Rohan)

Boulder Breaker: Cobble Breaker + diamond + Flint * 5

@Zodiase
Zodiase / helpers.js
Last active February 10, 2017 23:06
Functional JavaScript with Ramda
/**
* Runs a sub composition that is invisible to its parent composition.
* @param {...Function} funcs
* @return {a -> Promise(a)}
*/
const spyPipeP = (...funcs) => (val) => R.partialRight(R.pipeP, [() => val])(...funcs)(val);
/**
* Runs a sub composition that is invisible to its parent composition.
* @param {...Function} funcs
@Zodiase
Zodiase / heroku-meteor-deploy-setup.sh
Last active July 20, 2018 09:36
Setup deploying Meteor app in existing Git repo to Heroku
#!/bin/bash
# Login to heroku CLI.
heroku login
# Create a new app project on heroku.
heroku create <appName> --stack cedar --region us --buildpack https://github.com/AdmitHub/meteor-buildpack-horse.git
# Add heroku remote to the git config file.
heroku git:remote -a meteor-mdc-demo