Skip to content

Instantly share code, notes, and snippets.

View le-doude's full-sized avatar

Ed Pelosi le-doude

View GitHub Profile
@le-doude
le-doude / private.xml
Created January 18, 2017 02:48
Jap PC USB keyboard to mac - fix forward slash/yen/|/underscore swap
<?xml version="1.0"?>
<root>
<item>
<name>Underscore and backlash settings FILCO jp layout</name>
<identifier>private.filco_jp_backslash_underscore</identifier>
<autogen>
__KeyToKey__
KeyCode::JIS_UNDERSCORE, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_SHIFT,
KeyCode::JIS_UNDERSCORE
</autogen>
const RESOLUTIONS = [
{text: 'year', short: 'y', get: (d) => d.getFullYear(), set: (d, v) => d.setFullYear(v) },
{text: 'month', short: 'm', get: (d) => d.getMonth(), set: (d, v) => d.setMonth(v) },
{text: 'day', short: 'd', get: (d) => d.getDate(), set: (d, v) => d.setDate(v) },
{text: 'hour', short: 'h', get: (d) => d.getHours(), set: (d, v) => d.setHours(v) },
{text: 'minute', short: 'mi', get: (d) => d.getMinutes(), set: (d, v) => d.setMinutes(v) }
];
class DateHelper {
timeAgoInWords(date1, {brief, skip, limit} = {}) {
// here is an example of bad implementation that breaks encapsulation AND is hard to extend
class MyService {
void doSomethingWith(MyInterface instance) {
if(instance instanceof FirstImpl) {
doSomething((FirstImpl) instance);
} else if (instance instanceof SecondImpl) {
doSomethingElse((SecondImpl) instance);
} else {
defaultBehaviour(instance);
}