Skip to content

Instantly share code, notes, and snippets.

View Awlexus's full-sized avatar
🙃

Awlexus

🙃
  • Keep In Mind GmbH, Srl
  • Italy
View GitHub Profile
@Awlexus
Awlexus / bandcamp_unzipper.py
Last active November 19, 2020 22:17
A small script that will search for bandicamp zip files in the search directory and extract them in the given extract them in the extract directory under <artist>/<album>
#!/bin/python3
import sys
import os
import zipfile
import re
search_dir = os.path.expanduser(sys.argv[1])
extract_dir = os.path.expanduser(sys.argv[2])
regex = re.compile('(.+) - (.+)\.zip$')
@Awlexus
Awlexus / bencode.ex
Last active November 3, 2020 22:24
A simple implementation of a bencode decoder.
# There exists a library called "Bento", which is more sophisticated,
# but feel free to use this as a reference or just drop it into your code, if you don't care about errors
defmodule Bencode do
@spec parse_dictionary(binary()) :: {map(), binary()}
def parse_dictionary("d" <> rest), do: do_parse_dictionary(rest, %{})
@spec parse_list(binary()) :: {list(), binary()}
def parse_list("l" <> data), do: do_parse_list(data, [])
@spec parse_integer(binary()) :: {integer(), binary()}
@Awlexus
Awlexus / Sum_of_divided.ex
Created July 18, 2020 20:45
Solution to slow for kata 54d496788776e49e6b00052f
defmodule Sumofdivided do
def sum_of_divided(lst) do
table = :ets.new(:results, [{:write_concurrency, true}, :public, :ordered_set])
lst
|> Task.async_stream(&insert_divs(&1, table), timeout: :infinity, ordered: false)
|> Stream.run()
:ets.tab2list(table)
@Awlexus
Awlexus / pop_by benchmark.exs
Created November 28, 2019 23:36
A small benchmark comparing different implementations of a possible pop_by functionality
# Keyboard mashing
tags = ~w(faoshd foasidf oasidfh oaidsf aosifhasodi faosdfaosdfasodfjasldfd noasdfn 1234234 oasdinf oasnfoasdifnoisdfnof)
defmodule Popper do
def pop_by(list, fun, default \\ nil) do
result = Enum.find(list, default, fun)
{result, List.delete(list, result)}
end
@Awlexus
Awlexus / .vimrc
Created July 4, 2019 19:10
my (neo)vimrc
let mapleader =","
call plug#begin('~/.config/nvim/plugged')
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdtree'
Plug 'junegunn/goyo.vim'
Plug 'PotatoesMaster/i3-vim-syntax'
Plug 'jreybert/vimagit'
" Plug 'LukeSmithxyz/vimling'
Plug 'kien/ctrlp.vim'
@Awlexus
Awlexus / commander.ex
Created June 5, 2019 18:58
A very heavy macro based commander module for Nosturm
defmodule Nostrum.Commander do
@params [
:arguments,
:channel,
:channel_permissions,
:dm_channel,
:guild,
:me,
:message,
:permissions,
This file has been truncated, but you can view the full file.
ERROR: ld.so: object '/home/awlex/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
ERROR: ld.so: object '/home/awlex/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/awlex/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/home/awlex/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
15979.458:0008:0009:trace:module:load_builtin_callback loaded ntdll.dll 0x1106f0 0x7bc10000
15979.458:0008:0009:trace:module:load_builtin_dll Trying built-in L"kernel32.dll"
15979.458:0008:0009:trace:module:load_dll looking for L"ntdll.dll" in L""
15979.458:0008:0009:trace:module:load_dll Found L"C:\\windows\\system32\\ntdll.dll" for L"ntdll.dll" at 0x7bc10000,
@Awlexus
Awlexus / minimalistic_megumin.theme.css
Last active January 30, 2021 11:42
transparent betterdiscord theme with a nice megumin background
#app-mount {
/* Shinobu */
/* background-image: url("https://www.walldevil.com/wallpapers/a91/shinobu-oshino-bakemonogatari.jpg"); */
/* Megumin */
background-image: url('https://images3.alphacoders.com/704/704387.png');
background-size: cover;
}
@Awlexus
Awlexus / reverser.py
Created July 11, 2018 13:48
Basic Python script to reverse a beatmap
import sys
import os.path
from multiprocessing import Pool
def wline(file_, text=""):
file_.write("%s\n" % text)
def _read_till_next_tag(file_, tag="", ignore_empty=True):
lines = []