Skip to content

Instantly share code, notes, and snippets.

View mariusbutuc's full-sized avatar
🌏

Marius Butuc mariusbutuc

🌏
  • Toronto, ON
  • 11:59 (UTC -04:00)
View GitHub Profile
@mariusbutuc
mariusbutuc / install-elm-test.sh
Created June 15, 2017 02:06
Wow, all those dependencies…
$ npm install -g elm-test
└─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
@mariusbutuc
mariusbutuc / PV.js
Created August 31, 2017 21:20 — forked from ghalimi/PV.js
PV Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function PV(rate, periods, payment, future, type) {
// Initialize type
var type = (typeof type === 'undefined') ? 0 : type;
// Evaluate rate and periods (TODO: replace with secure expression evaluator)
rate = eval(rate);
periods = eval(periods);
# .git/hooks/pre-push
#!/usr/bin/env bash
set -e
trap 'echo interrupted; exit' INT
cd $(git rev-parse --show-toplevel)
if [ -f "mix.exs" ]; then
mix compile --warnings-as-errors
@mariusbutuc
mariusbutuc / tasks.exs
Created September 28, 2017 19:20 — forked from zacid/tasks.exs
Comparison between parallel map in Elixir and map
# p_map is a parallel map which runs each and every process concurrently
> p_map = fn -> 1..5 |> Enum.map(fn(i) -> Task.async(fn -> :timer.sleep(200); i + 1 end) end) |> Enum.map(fn(tsk) -> Task.await(tsk) end) end
# slow_map runs each and every iteration one after the other
> slow_map = fn -> 1..5 |> Enum.map(fn(i) -> :timer.sleep(200); i + 1 end) end
> :timer.tc(fn -> p_map.() end, [])
{200830, [2, 3, 4, 5, 6]}
> :timer.tc(fn -> slow_map.() end, [])
@mariusbutuc
mariusbutuc / elixir_function_headers.sh
Created October 31, 2017 17:31
Elixir suggests using function headers when declaring default values.
** (CompileError) lib/spreadsheet/functions.ex:340: definitions with multiple clauses and default values require a header. Instead of:
def foo(:first_clause, b \\ :default) do ... end
def foo(:second_clause, b) do ... end
one should write:
def foo(a, b \\ :default)
def foo(:first_clause, b) do ... end
def foo(:second_clause, b) do ... end
@mariusbutuc
mariusbutuc / RecalculateSellectedCells.gs
Created November 29, 2017 13:46 — forked from katz/RecalculateSellectedCells.gs
Google Apps Script to re-calculate selected cells in Sheets
/**
* @OnlyCurrentDoc Limits the script to only accessing the current spreadsheet.
*/
/**
* Adds a custom menu with items to show the sidebar and dialog.
*
* @param {Object} e The event parameter for a simple onOpen trigger.
*/
@mariusbutuc
mariusbutuc / gist:5996261965430a3590865c930a53ab92
Created January 4, 2018 19:37 — forked from twosixcode/gist:1988097
Make "Paste and Indent" the default paste in Sublime Text 2
// swap the keybindings for paste and paste_and_indent
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" }
@mariusbutuc
mariusbutuc / slack-up.md
Created March 2, 2018 16:01
Template for daily slack-ups.

:slack:-up:

Yesterday

Today

@mariusbutuc
mariusbutuc / quote.txt
Created July 5, 2018 16:13 — forked from OnesimusUnbound/quote.txt
Programming Quotes
[T]he difference between a bad programmer and a
good one is whether he considers his code or his
data structures more important. Bad programmers
worry about the code. Good programmers worry about
data structures and their relationships.
-- Linus Torvalds
~~~
Clarity and brevity sometimes are at odds.
When they are, I choose clarity.
-- Jacob Kaplan-Moss
@mariusbutuc
mariusbutuc / 10-lessons-erlang.md
Last active July 17, 2020 06:54
10 Lessons from a Decade with Erlang

10 Lessons from a Decade with Erlang [↗][source]

  1. Higher-order Constructs

    Use higher-order constructs (libraries, frameworks, tools) instead of building everything from scratch. If there is no higher-order construct yet, build one.

  2. Opaque Data Structures

    Use Opaque Data Structures to represent your entities.