Skip to content

Instantly share code, notes, and snippets.

@zoten
zoten / fibdict.py
Created April 26, 2023 10:00
Forbidden Python
class Fib(dict):
def __init__(self):
self[0] = self[1] = 1
def __missing__(self, k):
fibk = self[k] = self[k - 1] + self[k - 2]
return fibk
fib = Fib()
print(fib[10])
@zoten
zoten / .iex.exs
Created April 24, 2023 10:48 — forked from DaniruKun/.iex.exs
My custom global IEx script file that is preloaded before each IEx session. Adds some convenience functions.
IO.puts("Using .iex.exs file loaded from #{__DIR__}/.iex.exs")
defmodule Util do
def atom_status do
limit = :erlang.system_info(:atom_limit)
count = :erlang.system_info(:atom_count)
IO.puts("Currently using #{count} / #{limit} atoms")
end
@zoten
zoten / gist:623d46d20f2ae4d3a48f46bd59d2ca1b
Last active July 29, 2022 07:04
Credo complaining public spec missing on a macro-generated function
# Save this file as example.exs in the root of a mix project with credo installed
# and [Credo.Check.Readability.Specs](https://hexdocs.pm/credo/Credo.Check.Readability.Specs.html) check enabled
# and run a
# ``` bash
# mix credo example.exs
# ```
# command to trigger the error
# or
# get a .credo.exs file with the check enabled and
# uncomment the last line and run this as an escript with
@zoten
zoten / jsonapi_oas.yml
Created November 25, 2021 11:36 — forked from naesean/jsonapi_oas.yml
OpenAPI 3.0 schemas that comply with the JSON:API 1.0 specification
JSONAPIObject:
description: Includes the current JSON:API version for this specification as well as optional meta information
type: object
required:
- version
properties:
version:
type: string
default: '1.0'
example: '1.0'
@zoten
zoten / bitethebot.user.js
Last active August 8, 2018 12:52 — forked from nappa85/bitethebot.user.js
BiteTheBot hack
// ==UserScript==
// @include https://web.telegram.org/*
// ==/UserScript==
var url = "https://web.telegram.org/#/im?p=@bitethebot";
const action_timeout = 6000;
const min_timeout = 60000;
const max_timeout = 300000;
const start_timeout = 5000;
const max_timeout_delta = max_timeout - min_timeout;