View monoids.rb
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
[1] (pry) main: 0> 1.class | |
=> Fixnum | |
[2] (pry) main: 0> 1.method(:+) | |
=> #<Method: Fixnum#+> | |
[3] (pry) main: 0> 1 + 0 == 0 + 1 | |
=> true | |
[4] (pry) main: 0> 2.0.class | |
=> Float | |
[5] (pry) main: 0> 2.0.method(:*) |
View custom_monoid.rb
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
[1] (pry) main: 0> class AdditionMonoid | |
[1] (pry) main: 0* def identity | |
[1] (pry) main: 0* 0 | |
[1] (pry) main: 0* end | |
[1] (pry) main: 0* | |
[1] (pry) main: 0* def operation(a, b) | |
[1] (pry) main: 0* a + b | |
[1] (pry) main: 0* end | |
[1] (pry) main: 0* end | |
=> :operation |
View governmentify.sh
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
cat ./1-219.1.txt | convert \ | |
-font Courier \ | |
text:- \ | |
-rotate `convert null: -format '%[fx:rand()*15-7]' info:` \ | |
-attenuate 0.1247 +noise Gaussian \ | |
-colorspace Gray \ | |
1-219.1.pdf |
View percona-toolkit.rb
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
class PerconaToolkit < Formula | |
desc "Percona Toolkit for MySQL" | |
homepage "https://www.percona.com/software/percona-toolkit/" | |
url "https://www.percona.com/downloads/percona-toolkit/2.2.19/tarball/percona-toolkit-2.2.19.tar.gz" | |
mirror "https://www.mirrorservice.org/sites/ftp.netbsd.org/pub/pkgsrc/distfiles/percona-toolkit-2.2.19.tar.gz" | |
mirror "https://dl.bintray.com/homebrew/mirror/percona-toolkit-2.2.19.tar.gz" | |
sha256 "e9f4d4730265813fa7a39ed8799d12ca5775c8e5d6fa27ff48bae11db0f7e671" | |
revision 1 | |
head "lp:percona-toolkit", :using => :bzr |
View hello_world.swift
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 Kitura | |
import KituraNet | |
import KituraSys | |
let router = Router() | |
router.get("/") { | |
request, response, next in | |
response.send("Hello, World!") | |
next() |
View example.ex
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
defmodule MyMod do | |
defmodule Base do | |
def __using__(_) do | |
end | |
end | |
@mod Application.get_env(:my_app, :mod, MyMod.Base) | |
use @mod | |
end |
View contracts.ex
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
defmodule Contracts do | |
defmacro __using__(_opts) do | |
quote do | |
Module.register_attribute(__MODULE__, :requires, accumulate: true) | |
Module.register_attribute(__MODULE__, :ensures, accumulate: true) | |
@contracts %{} | |
import Kernel, except: [def: 2] | |
import Contracts, only: [def: 2] |
View gist:60aec6996bac67995a5b
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
% MIX_ENV=stag mix release | |
==> Building release with MIX_ENV=stag. | |
==> Generating relx configuration... | |
==> Merging custom relx configuration from rel/relx.config... | |
==> Generating sys.config... | |
==> Generating boot script... | |
==> Performing protocol consolidation... | |
==> Conform: Loading schema... | |
==> Conform: No schema found, conform will not be packaged in this release! | |
==> Generating release... |
View types.md
Make illegal states unrepresentable. Use the type system as a tool to enforce invariants on the code you write. Choose your data types such that states that are illegal don’t show up as legal states in the program. Take this code representing various connection information as an example. It keeps track of relevant information in a fairly readable manner:
type connection_state =
| Connecting
| Connected
| Disconnected
type connection_info = {
state: connection_state
NewerOlder