Skip to content

Instantly share code, notes, and snippets.

@lud
lud / day16.ex
Created December 16, 2021 22:33
defmodule Aoe.Y21.Day16 do
alias Aoe.Input, warn: false
@type input_path :: binary
@type file :: input_path | %Aoe.Input.FakeFile{}
@type part :: :part_one | :part_two
@type input :: binary | File.Stream.t()
@type problem :: any
require Record
@lud
lud / heat.exs
Last active November 16, 2022 10:21
Heat the computer
#!/usr/bin/env elixir
Mix.install([:jason])
defmodule Heater do
import Kernel, except: [spawn_link: 1]
def spawn_link() do
Kernel.spawn_link(fn -> init() end)
end
@lud
lud / heat.exs
Last active January 21, 2021 09:52
defmodule Heater do
import Kernel, except: [spawn_link: 1]
def spawn_link() do
Kernel.spawn_link(fn -> init() end)
end
defp init() do
send(self(), :heat)
loop_idle()
@lud
lud / demo.ex
Created July 29, 2020 07:12
Elixir uppercase constants with macros
defmodule Constants.Compiler do
@moduledoc false
defmacro __using__(_) do
quote do
Module.register_attribute(__MODULE__, :const_def, accumulate: true)
import unquote(__MODULE__), only: [const: 2]
@before_compile unquote(__MODULE__)
end
end
---
Disease-it:
url: "http://disease-it.jeuweb.org/"
image: "https://img.itch.zone/aW1nLzMxMTA5ODQucG5n/original/zO55Li.png"
description:
email: arnaud.degouy@hotmail.fr
id_thread: 12568
"L'ile du coeur":
url: http://www.ile-du-coeur.com/
defmodule Day4 do
def run(range_str) do
[from, to] =
range_str
|> String.split("-")
|> Enum.map(&String.to_integer/1)
Range.new(from, to)
|> Stream.map(&to_charlist/1)
|> Stream.filter(&has_increasing_digits/1)
@lud
lud / update-spatial-indexes.sql
Created June 19, 2014 15:18
Recreate Oracle Spatial indexes
DECLARE
TYPE curs IS REF CURSOR;
c curs;
q varchar2(200);
idx VARCHAR(200);
tab VARCHAR(200);
col VARCHAR(200);
BEGIN
q := 'select index_name,table_name,column_name from user_sdo_index_info';
OPEN c FOR q;
@lud
lud / README.md
Last active December 27, 2017 01:55
Change Serial / Integer postgres column type

Création/Suppression des auto-incrément sur PostgreSQL

Ce script contient deux fonctions permettant de changer le typage d'une colonne serial de Postgres en integer et vice-versa.

Le type serial est simplement un integer couplé à une séquence. Il s'agit donc simplement de créer/supprimer la séquence et de changer la valeur par défaut de la colonne.

Postgres n'empêche pas de spécifier la valeur d'un champ serial sur une requête insert mais des outils comme FME peuvent traiter les colonnes serial différemment. Il est donc utile de pouvoir les désactiver temporairement.

Le nom du champ est id par défaut ici. À changer si nécessaire.

@lud
lud / README.md
Last active November 13, 2016 22:54
Sublime Text 2 settings

Lud's Sublime Setup

Theese files describe my preferences on sublime text

Theme

I've included my own theme (a derivative from Eathsong) but most of the time i'm on Tomorrow. Actually the theme I like the most is Solarized Light but as I use f.lux, Solarized is too dark/yellow and Tomorrow is ok.

Font

@lud
lud / README.md
Last active December 30, 2015 18:49
D3 Shopping list

This is a simple application that manages a shopping list. It's made with D3js and Bootstrap. Here is a tutorial where I explain how the code works.