This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def insert(pair: (Char, Int), xs: List[(Char, Int)]): List[(Char, Int)] = xs match { | |
case List() => List(pair) | |
case y :: ys => { | |
if (pair._1 == y._1) (pair._1, y._2 + 1) :: ys | |
else if (pair._1 < y._1) pair :: xs | |
else y :: insert(pair, ys) | |
} | |
} | |
def insert2(x: (Char, Int), xs: List[Leaf]): List[Leaf] = xs match { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jQuery from 'jquery' | |
import Turbolinks from 'turbolinks' | |
export default function () { | |
const { defer, dispatch } = Turbolinks | |
const handleEvent = function handleEvent(eventName, handler) { | |
document.addEventListener(eventName, handler, false) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// foobar.js | |
import _ from 'lodash' | |
console.log(_.map([1, 2, 3], x => x + 1)) | |
// webpack.config.js | |
// ...snip... | |
entry: { | |
common: ['lodash'], | |
'foobar': './foobar.js', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare var __DEV__: boolean; | |
declare module 'react-native' { | |
declare export var View: any; | |
declare export var Button: any; | |
declare export var StyleSheet: any; | |
declare export var Text: any; | |
declare export var Platform: any; | |
declare export var TouchableOpacity: any; | |
declare export var Image: any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const minimumSwaps = (arr) => { | |
const shift = Math.min(...arr) | |
let swaps = 0 | |
const visited = [...Array(arr.length)].map(() => false) | |
arr.forEach((val, i) => { | |
if (val - shift === i || visited[i]) return | |
let loopLength = 0 | |
let x = i | |
while (!visited[x]) { | |
visited[x] = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ERN_LOG_LEVEL=trace ern create-miniapp fooMiniApp | |
___ _ _ _ _ _ _ _ | |
| __| |___ __| |_ _ _ ___ __| |___ | \| |__ _| |_(_)_ _____ | |
| _|| / -_) _| _| '_/ _ \/ _` / -_) | .` / _` | _| \ V / -_) | |
|___|_\___\__|\__|_| \___/\__,_\___| |_|\_\__,_|\__|_|\_/\___| | |
[v0.38.7] [Cauldron: -NONE-] | |
pwd | |
pwd | |
[ Ensuring that Electrode Native module name is valid (Started) ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('remote JS from GitHub') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ******************* | |
// This setup will allow you to synchronize personal events from one calendar (the "secondary calendar") | |
// to another calendar, e.g. work (the "primary calendar"), but obfuscate the details. Then your coworkers | |
// know when you're busy but don't get to see the personal details. | |
// | |
// Follow these steps: | |
// 1. Go to https://script.google.com/home and click [+ New project] | |
// 2. Make sure the two calendars you want to sync can be edited by the Google account you're currently under | |
// (or switch accounts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# custom aliases for fzf | |
# ====================== | |
# open up a visual finder with git branches to switch to them, including fuzzy-finding | |
# demo: https://i.imgur.com/xR5ILE5.jpg | |
alias gf='git checkout $(_gb)' | |
# opens visual fzf finder for git branches to delete them | |
alias gbd='git bd $(_gb)' | |
# fzf | |
[ -f ~/.fzf.bash ] && source ~/.fzf.bash |