Skip to content

Instantly share code, notes, and snippets.

View gmelodie's full-sized avatar
🤟
Computing stuff

Gabriel Cruz gmelodie

🤟
Computing stuff
View GitHub Profile
@stevewithington
stevewithington / find-replace-sed.md
Last active December 28, 2022 11:38
Find & Replace within an Entire Directory or Git Repo with sed

Find & Replace within an Entire Directory or Git Repo with sed

If replacing within a directory:

grep -rl 'apples' /dir_to_search_under | xargs sed -i 's/apples/oranges/g'

Or, within an entire git repository:

@nathan-cruz77
nathan-cruz77 / calculator.ex
Created August 26, 2018 18:25
Extract operation from string and executes it
# Sample usage:
#
# iex(1)> Calculator.calculate('123 + 27')
# 150
# iex(2)> Calculator.calculate('123 - 27')
# 96
# iex(3)> Calculator.calculate('123 * 27')
# 3321
# iex(4)> Calculator.calculate('123 / 27')
# 4.555555555555555
@nathan-cruz77
nathan-cruz77 / run_async.exs
Created July 27, 2018 17:31
Async execution in elixir
defmodule Run do
def in_parallel(n) do
1..n
|> Enum.map(fn(i) ->
Task.async(fn -> :timer.sleep(i * 1_000) end)
end)
|> Enum.map(&Task.await/1)
end
def serial(n) do