This file contains hidden or 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
| @file:Suppress("PackageDirectoryMismatch") // root package looks great when importing, ie. `import exhaustive` | |
| /** | |
| * Allows requiring an exhaustive mapping in a `when` block when used with the [rangeTo] operator. | |
| * @sample [exhaustive_when_example] | |
| */ | |
| @Suppress("ClassName") // lowercase because it should look like a keyword | |
| object exhaustive { |
This file contains hidden or 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
| -- Note: There is a more complete explanation at https://github.com/hwayne/lets-prove-leftpad/tree/master/idris | |
| import Data.Vect | |
| -- `minus` is saturating subtraction, so this works like we want it to | |
| eq_max : (n, k : Nat) -> maximum k n = plus (n `minus` k) k | |
| eq_max n Z = rewrite minusZeroRight n in rewrite plusZeroRightNeutral n in Refl | |
| eq_max Z (S _) = Refl | |
| eq_max (S n) (S k) = rewrite sym $ plusSuccRightSucc (n `minus` k) k in rewrite eq_max n k in Refl | |
| -- The type here says "the result is" padded to (maximum k n), and is padding plus the original |
This file contains hidden or 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
| git rebase "$(git merge-base HEAD master)" -x 'git commit --amend -C HEAD --date="$(date -R)" && sleep 1.05' |
This file contains hidden or 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
| /** | |
| * ------------------------------------------ | |
| * MD5 function for GAS(GoogleAppsScript) | |
| * | |
| * You can get a MD5 hash value and even a 4digit short Hash value of a string. | |
| * ------------------------------------------ | |
| * Usage1: | |
| * `=MD5("YourStringToHash")` | |
| * or | |
| * `=MD5( A1 )` |
This file contains hidden or 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
| /** | |
| * Based on Ben Trengrove's example: https://gist.github.com/bentrengrove/9759a3fbb564d62e1e63f417c58a3895 | |
| */ | |
| package units | |
| import java.util.concurrent.TimeUnit | |
| abstract class Unit(val suffix: String, val ratio: Double) { | |
| internal fun convertToBaseUnit(amount: Double) = amount * ratio | |
| internal fun convertFromBaseUnit(amount: Double) = amount / ratio |
This file contains hidden or 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
| package main | |
| /* | |
| * A simple go program to download all the high resolution pictures from your facebook albums. | |
| * | |
| * To run this: | |
| * 1. Go to https://developers.facebook.com/tools/explorer/?method=GET&path=me&version=v2.8 | |
| * 2. Get an Access Token: Get Token > Get User Access Token > Check "user_photos" | |
| * 3. Paste in the app. | |
| */ |
This file contains hidden or 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
| // A reminder to myself on how to quickly create a throw away gui app on OSX (i.e. a single file, | |
| // w/o relying on XCode project templates | |
| //Notes: In general it is hard to know how to create a Cocoa based gui without using XCode. | |
| //This issue has existed for both Objective-C and now Swift | |
| //Furthermore, Swift<-->Cocoa syntax has changed dramatically over various Swift versions, | |
| //making stackoverflow posts unreliable | |
| //This file provides a template for creating a throw away gui app |
This file contains hidden or 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
| = Resources = | |
| * zsh - http://www.zsh.org/ | |
| * ZSH-LOVERS - http://grml.org/zsh/zsh-lovers.html | |
| * manual - http://zsh.sourceforge.net/Doc/Release/index.html | |
| * oh-my-zsh - https://github.com/robbyrussell/oh-my-zsh | |
| * prezo - https://github.com/sorin-ionescu/prezto | |
| * zsh-users - https://github.com/zsh-users | |
| = Functions = |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <!-- | |
| Copyright 2016 Google Inc. | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or 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 org.gradle.internal.os.OperatingSystem; | |
| String getJavaHome(String version) { | |
| def stdout = new ByteArrayOutputStream() | |
| exec { | |
| commandLine "/usr/libexec/java_home", "-v", version | |
| standardOutput = stdout; | |
| } | |
| return stdout.toString().trim() | |
| } |