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
| defmodule Between do | |
| @doc """ | |
| ## Examples | |
| iex> list = for x <- 1000..1031, rem(x, 5) != 0, do: x | |
| iex> chunks = Between.chunk_between(list, fn a, b -> b - a != 1 end) | |
| iex> IO.inspect | |
| [[1001, 1002, 1003, 1004], [1006, 1007, 1008, 1009], [1011, 1012, 1013, 1014], | |
| [1016, 1017, 1018, 1019], [1021, 1022, 1023, 1024], [1026, 1027, 1028, 1029], | |
| [1031]] |
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
| defmodule XStream do | |
| @doc """ | |
| Returns a stream of all permutations of the given collection. | |
| The count parameter will limit the number of elements, all are returned | |
| by default | |
| ## Examples |
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
| defmodule LazyPermutations do | |
| def permutations(list) do | |
| list | |
| |> Enum.sort | |
| |> Stream.unfold fn | |
| [] -> nil | |
| p -> {p, next_permutation(p)} | |
| end | |
| end |
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
| defmodule MatchAndAssign do | |
| defmacro __using__(_) do | |
| quote do | |
| require MatchAndAssign | |
| import MatchAndAssign, only: [match_and_assign: 2] | |
| end | |
| end | |
| defp unhygienize(pattern = {n, _meta, c}) when is_atom(n) and is_atom(c) do | |
| var! pattern |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| #!/usr/bin/env ruby | |
| require 'net/http' | |
| require 'json' | |
| def get_json(url) | |
| uri = URI(url) | |
| JSON.parse(Net::HTTP.get uri) | |
| end |
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
| #!/bin/sh | |
| # $ curl -s https://gist.githubusercontent.com/tallakt/7048c646b999faf17db98a49e6374324/raw/020b759c6f71d72efe67d2c7f8f7d6fcb87b8635/mining_fetch_git.sh -O mining_fetch_git.sh | |
| cd /home/tallakt | |
| if [ ! -e ~/mining/README.md ]; then | |
| rm -Rf mining | |
| git clone [email protected]:tallakt/mining.git | |
| fi; |
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
| @doc """ | |
| # Mud Sync | |
| Koden er basert på en modell hvor man har x pumper, hver med y stempel som går i | |
| (360 / y) graders fase på hverandre. Man får en puls per omdreining av kamakselen. Hver | |
| pumpe har sine egne pulser som brukes til synkronisering | |
| """ | |
| defmodule MudSync do |
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
| if empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) | |
| silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs | |
| \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
| autocmd VimEnter * PlugInstall --sync | source ~/.config/nvim/init.vim | |
| endif | |
| call plug#begin('~/.local/share/nvim/plugged') | |
| Plug 'andymass/vim-matchup' | |
| Plug 'frankier/neovim-colors-solarized-truecolor-only' |
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
| #!/usr/bin/env ruby | |
| require 'pty' | |
| loop do | |
| begin | |
| PTY.spawn( "/usr/bin/gpspipe -w" ) do |stdout, stdin, pid| | |
| stdout.each do |line| | |
| m = line.match /"time":"(2...-..-..T..:..:......Z)"/ |