This gist is a companion to this blog post, you should start there!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://julien.danjou.info/p/the-hidden-cost-of-badly-typed-python | |
# Simple version (hardcoded types) | |
from collections.abc import Callable | |
from typing import Any, Concatenate, ParamSpec | |
P = ParamSpec("P") | |
def send_request(client: "HttpClient", method: str = "GET", timeout: int = 5) -> str: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- mini scheduler | |
local tasks = {} -- execution delays in ticks, indexed by the coroutine | |
local delay_mt = {} | |
local function is_delay(x) | |
return type(x) == "table" and getmetatable(x) == delay_mt | |
end | |
local function make_delay(t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== Python-3.12.2 === | |
github.com/AlDanial/cloc v 2.00 T=5.10 s (775.6 files/s, 446163.8 lines/s) | |
--------------------------------------------------------------------------------------- | |
Language files blank comment code | |
--------------------------------------------------------------------------------------- | |
Python 1946 136288 157620 635104 | |
C 365 60311 57289 411210 | |
C/C++ Header 492 21539 11893 206768 | |
reStructuredText 490 85145 106460 102226 | |
Text 133 2830 0 96064 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name summary | |
-------------------------------------------------- ------------------------------------------------------------------------------------------------------- | |
refiners[conversion,test,training] The simplest way to train and run adapters on top of foundational models | |
├── bitsandbytes<0.42.0,>=0.41.0 k-bit optimizers and matrix multiplication routines. | |
├── datasets<3.0.0,>=2.14.0 HuggingFace community-driven open-source library of datasets | |
│ ├── aiohttp Async http client/server framework (asyncio) | |
│ │ ├── aiosignal>=1.1.2 aiosignal: a list of registered asynchronous callbacks | |
│ │ │ └── frozenlist>=1.1.0 A list-like structure which implements collections.abc.MutableSequence | |
│ │ ├── attrs>=17.3.0 Classes Without Boilerplate | |
│ │ ├── frozenlist>=1.1.1 A list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[bearer_1.0.0_linux_amd64 14:43] ./bearer scan bear-publishing | |
Loading rules | |
fatal error: unexpected signal during runtime execution | |
[signal SIGSEGV: segmentation violation code=0x1 addr=0x1d93a0 pc=0x7fc16c092f16] | |
runtime stack: | |
runtime.throw({0x1520dac?, 0x352?}) | |
/opt/hostedtoolcache/go/1.19.6/x64/src/runtime/panic.go:1047 +0x5d fp=0x7fc16d518fc8 sp=0x7fc16d518f98 pc=0x43c55d | |
runtime.sigpanic() | |
/opt/hostedtoolcache/go/1.19.6/x64/src/runtime/signal_unix.go:819 +0x369 fp=0x7fc16d519018 sp=0x7fc16d518fc8 pc=0x452189 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Evil answer, don't try this at home 😈 | |
def serialize(node, inbuf = nil) | |
buf = inbuf || StringIO.new | |
buf.write('Node.new(') | |
buf.write(node.val.inspect) | |
if node.left | |
buf.write(', ') | |
serialize(node.left, buf) | |
if node.right |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def efficient_part2(input) | |
n = input.length | |
r = Array.new(n, 1) | |
p_up, p_down = 1, 1 | |
0.upto(n - 1) do |i| | |
j = n - i - 1 | |
r[i] *= p_up | |
r[j] *= p_down | |
p_up *= input[i] | |
p_down *= input[j] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- see https://github.com/catwell/lua-multipart-post/issues/8#issuecomment-1307934583 | |
-- fixed version (see diff) | |
local http = require("socket.http") | |
local ltn12 = require("ltn12") | |
local lfs = require "lfs" | |
http.TIMEOUT = 5 | |
local function upload_file ( url, filename ) | |
local fileHandle = io.open( filename,"rb") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local record plnutil | |
vec_zeros: function(integer): {number} | |
mat_zeros: function(integer, integer): {{number}} | |
mat_vec_mul: function({{number}}, {number}): {number} | |
mat_t_vec_mul: function({{number}}, {number}): {number} | |
vec_vec_2d_mul: function({number}, {number}): {{number}} | |
vec_pointwise_mul: function({number}, {number}): {number} | |
vec_add_inplace: function({number}, {number}, number) | |
mat_add_inplace: function({{number}}, {{number}}, number) | |
vec_clip_inplace: function({number},number, number) |
NewerOlder