Skip to content

Instantly share code, notes, and snippets.

View MachinesAreUs's full-sized avatar

Agustín Ramos MachinesAreUs

View GitHub Profile
@MachinesAreUs
MachinesAreUs / Metro_CDMX.kml
Last active July 10, 2022 13:47
A challenge I came up with some time ago.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Metro de la Ciudad de México</name>
<description>Mapa del Sistema de Transporte Colectivo | Red del Metro de la Ciudad de México. Cortesía de www.defe.mx</description>
<Style id="icon-1445-normal">
<IconStyle>
<scale>1.1</scale>
<Icon>
<href>http://www.gstatic.com/mapspro/images/stock/1445-trans-metro.png</href>
@MachinesAreUs
MachinesAreUs / turing_laureates.js
Last active May 14, 2021 07:22
Script to retrieve Nobel Laureate names from Wikipedia
// 1. Go to https://en.wikipedia.org/wiki/Turing_Award
// 2. Open a JS console and...
// Number of laureates
$('.wikitable').children('tbody').children('tr:not(:first-child)').size()
// Their names
$('.wikitable').children('tbody').children('tr:not(:first-child)').each(function() {
console.log( $(this).children('td').first().text() );
})
@MachinesAreUs
MachinesAreUs / elixir_dist.md
Created November 5, 2018 19:55
Primeros pasos para hacer un sistema distribuido con Elixir

Sistemas distribuidos con Elixir, primeros pasos

Crear un nodo llamado 'node1'

$ iex —sname node1

Dentro de iex, crear el módulo para el server

Problem 1 - Pragmatic Bookshelf

Pragmatic Bookshelf has offices in Texas (TX) and North Carolina (NC), so we have to charge sales tax on orders shipped to these states. The rates can be expressed as a keyword list

tax_rates = [ NC: 0.075, TX: 0.08 ]
#!/bin/bash
NEO4J_HOME=/Users/agus/Development/workz/bunsan/bussi/neo4j-community-3.2.8
SPATIAL_RELEASE=0.24-neo4j-3.1.1
SPATIAL_RELEASES_URL=https://github.com/neo4j-contrib/m2/blob/master/releases/org/neo4j/neo4j-spatial
SPATIAL_PLUGIN_JAR=neo4j-spatial-${SPATIAL_RELEASE}-server-plugin.jar
SPATIAL_PLUGIN_URL=${SPATIAL_RELEASES_URL}/${SPATIAL_RELEASE}/${SPATIAL_PLUGIN_JAR}
@MachinesAreUs
MachinesAreUs / queens.ex
Last active September 13, 2017 12:59
n-queens in elixir
defmodule Queens do
def solve(0, _m), do: [[]]
def solve(n, m) do
for done_queens <- solve(n-1, m),
avail_pos <- (Enum.to_list(1..m) -- done_queens),
safe_pos(avail_pos, done_queens, 1),
do: [avail_pos | done_queens]
end
defp safe_pos(_, [], _), do: true
0x17E59a96ca21f6E9eB6B2dE15716e000Fd29281D
@MachinesAreUs
MachinesAreUs / git_summary_1_month.sh
Created December 19, 2016 04:16
Summary of commits in a repo for 1 month
git log --pretty=format:"%ad:%an:%H:%s" --date=short --all --since=1.months.ago
@MachinesAreUs
MachinesAreUs / git_stats.sh
Created February 12, 2016 18:37
Github stats
git log --since=2015-12-01 --no-merges --pretty="%H,%ad,%an" --date=short --shortstat | sed '/^$/d' | awk -F ',' '
function toStats(line) {
files = 0; insertions = 0; deletions = 0;
split(line, tokens, ",");
for (i=0; i < length(tokens); i ++) {
split(tokens[i], items, " ");
if(match(tokens[i], "file")) {
files = items[1];
}
else if(match(tokens[i], "insertion")) {
@MachinesAreUs
MachinesAreUs / example run
Last active February 24, 2024 02:59
Demonstration of trapping exits in Elixir
iex(2)> pid = spawn Traps, :init, []
waiting to die...
#PID<0.92.0>
Nobody tried to kill me! ^_^
waiting to die...
Nobody tried to kill me! ^_^
waiting to die...
iex(3)> Process.exit pid, :normal
true
(⊙_⊙') somebody tried to kill me! {:EXIT, #PID<0.88.0>, :normal}