-
Income vs expenses this month?
$ ledger balance income expenses --period "this month"
-
What did my budget look like at a certain date?
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 calc_allocations(self, date, quantity, cap): | |
"""Figure out ideal allocations for a given date""" | |
# { | |
# coin_name: (percent_allocation, data) | |
# } | |
top_market = self.get_top_market(date, quantity) | |
total_cap = sum([coin.market_cap for coin in top_market]) | |
allocations = [{ |
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 AppWeb.AuthConnCase do | |
alias AppWeb.Router | |
use ExUnit.CaseTemplate | |
import Phoenix.ConnTest, only: [dispatch: 5, json_response: 2] | |
@doc """ | |
Allows you to call the same set of tests with the same describe block | |
Setups is an array of named setups, i.e. [first_setup: [:setup_conn, :thing], second_setup: [:different_setup, :neato_setup]] | |
## Examples |
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 WorkStep do | |
defstruct [:name, :in, :out, :mod, :fun, :arg] | |
require Logger | |
def add_to_graph(%Graph{} = graph, %__MODULE__{} = step) do | |
graph | |
|> Graph.add_vertex(step) | |
|> Graph.add_edges(step |> edges_in) | |
|> Graph.add_edges(step |> edges_out) | |
end |
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
# How to create a user authentication systems with email verification in phoenix framework. | |
Phoenix Framework is built with the powerful and resilient programming language called Elixir Lang. It is gaining momentunm by the day thanks to it's expressive sytanx which makes you productive and it's built upon the shoulders of the Erlang vm called BEAM which makes your code performant. | |
Here will build a user registration with Email verification and a login systems. Phoenix framework can be used to build normal html 5 crud apps, json api and real time backends. We'll be building a real time backend using Phoenix channels and an Elixir library Guardian jwt. | |
You can find installation instructions on the [Elixir site](http://elixir-lang.org) and [Phoenix framework](http://phoenixframework.org) . | |
We be using Phoenix 1.3 which is the current version. |
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 MyApp.Scheduler do | |
@moduledoc """ | |
Schedules a Mix task to be run at a given interval in milliseconds. | |
## Options | |
- `:task`: The name of the Mix task to run. | |
- `:args`: A list of arguments to pass to the Mix task's `run/1` function. | |
- `:interval`: The time interval in millisconds to rerun the task. |
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
#!/bin/bash | |
# This will write private.pem and public.pem in the current directory | |
# The default key strenght is 2048 bits | |
# usage: | |
# # ./gen-jwt-rsa-keys.sh mykey | |
# # ls | |
# gen-jwt-rsa-keys.sh mykey-private.key mykey-public.pem | |
# first time you have to give execution permission or use bash and the filename | |
# # chmod +x gen-jwt-rsa-keys.sh | |
KEYNAME=${1:-jwtrsa} |
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 ElasticSearchConnection < GraphQL::Relay::BaseConnection | |
def has_next_page | |
!nodes.last_page? | |
end | |
def has_previous_page | |
!nodes.first_page? | |
end | |
def cursor_from_node(node) |
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
#!/bin/bash | |
cartella="/var/myfolder" | |
# update the file | |
curl -i -X PUT -H 'Authorization: token 4d013330xxxxxxxxxxxxxx' -d "{\"path\": \"mattei.csv\", \ | |
\"message\": \"update\", \"content\": \"$(openssl base64 -A -in $cartella/mattei.csv)\", \"branch\": \"master\",\ | |
\"sha\": $(curl -X GET https://api.github.com/repos/username/repo/contents/mattei.csv | jq .sha)}" \ | |
https://api.github.com/repos/username/repo/contents/mattei.csv |