Skip to content

Instantly share code, notes, and snippets.

View liaujianjie's full-sized avatar

Liau Jian Jie liaujianjie

View GitHub Profile
@liaujianjie
liaujianjie / useCalendar.ts
Created August 6, 2021 14:51
shiok shiok satay
import { add, getDay, getMonth, getYear, isLastDayOfMonth, sub } from "date-fns";
import { chunk } from "lodash";
import { Dispatch, SetStateAction, useState } from "react";
type CalendarView = "month";
type UseCalendarOptions = {
view: CalendarView;
/**
* Indicates if the week should start on Monday instead of Sunday. Defaults to starting on Sunday.
@liaujianjie
liaujianjie / git-prune-and-delete.sh
Created August 28, 2020 08:06
Prune branches on local and delete their local copy
g branch -D $(git remote prune origin | sed -e '1,2d' | sed -e 's/\ \* \[pruned\] origin\///' | paste -sd " " -)
import _ from "lodash";
/**
* jscodeshift codemod to rename Jest test files for classes from:
* ```
* describe(MyCat, () => {
* describe("meow", () => { ... });
* });
* ```
* to:

Hello. :-) I work on Mobbin.

@import "~@blueprintjs/core/lib/css/blueprint.css";
@import "~@blueprintjs/icons/lib/css/blueprint-icons.css";
/* just to make things neat and tidy */
html,
body {
width: 100%;
height: 100%;
background: #efefef;
padding: 3em;
@liaujianjie
liaujianjie / cs2030test.sh
Last active January 31, 2018 12:49
Runs the tests for your CS2030 lab0 test cases
echo Compiling... && javac LabZero.java && echo Compiled. && echo Running tests... && for i in $(seq 5); do java LabZero < TESTDATA$i.txt; done
@liaujianjie
liaujianjie / cs1010test.sh
Last active January 31, 2018 12:40
Runs the tests for your CS1010 test cases
echo "Running $2 test cases for $1...\n\n"
for i in $(seq $2);
do echo "========== TEST CASE $i"
./a.out < $1$i.in > $1$i.out.actual
diff $1$i.out $1$i.out.actual
rm $1$i.out.actual;
done
@liaujianjie
liaujianjie / Eureka+Firebase.swift
Last active July 3, 2018 10:51
Swift extension to bridge between Eureka datatypes and Firebase datatypes
import Foundation
import Eureka // https://github.com/xmartlabs/Eureka
public extension Form {
public func valuesForFirebase(includeHidden: Bool = false) -> [String: Any?] {
let rows = includeHidden ? self.allRows : self.rows
return rows.filter({ $0.tag != nil })
.reduce([:], { (dictionary, row) -> [String: Any?] in
var dictionary = dictionary
dictionary[row.tag!] = row.firebaseValue
@liaujianjie
liaujianjie / NSURL+mailTo.swift
Last active August 2, 2016 08:17
Swift convenience NSURL extension for composing mailto urls
import Foundation
extension NSURL {
/**
Convenience class method for composing an `NSURL` for creating mail links with the `mailto` scheme.
- parameter receipients: Email receipients
- parameter cc: Email carbon copy receipients. (optional)
- parameter bcc: Email blind carbon copy receipients (optional)
- parameter subject: Subject title of the email (optional)