This file contains 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
import macros | |
proc replaceIdents(node: NimNode, name, to: string): NimNode = | |
result = node | |
for i in 0 ..< len(result): | |
if result[i].kind == nnkIdent and eqIdent(result[i], name): | |
result[i] = ident(to) | |
else: | |
result[i] = result[i].replaceIdents(name, to) |
This file contains 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
import std / asyncdispatch | |
type TimeoutError* = ref object of CatchableError | |
timeout*: int | |
proc timeoutFuture*[T](future: Future[T], timeout: int): Future[T] {.async.} = | |
let timeoutFuture = sleepAsync(timeout * 1000) | |
timeoutFuture.callback = proc = | |
if not future.finished: | |
future.fail(TimeoutError(msg: "The future didn't complete in time", timeout: timeout)) |
This file contains 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
# Credits to: | |
# https://stackoverflow.com/questions/16710040/arp-request-and-reply-using-c-socket-programming | |
# https://stackoverflow.com/questions/55203086/how-to-use-raw-socket-send-and-receive-arp-package-in-python | |
# https://www.howtogeek.com/70374/how-to-geek-explains-what-is-wake-on-lan-and-how-do-i-enable-it/ | |
# https://datatracker.ietf.org/doc/html/rfc826 | |
import std/[net, nativesockets, strutils, streams, strformat] | |
import posix | |
var |
This file contains 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
import os | |
from typing import BinaryIO | |
from pyrogram import Client, filters | |
from pyrogram.types import Message | |
bot = Client( | |
"stream", | |
api_id=int(os.getenv("API_ID")), | |
api_hash=os.getenv("API_HASH"), |
This file contains 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
import sys | |
import gzip | |
import json | |
from collections import defaultdict | |
if len(sys.argv) < 3: | |
print("Wrong args. Usage: python combine.py file1.tgs file2.tgs ...") | |
files = map(lambda f: open(f, "rb"), sys.argv[1:]) |
This file contains 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
// https://stackoverflow.com/a/838413 | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#define CAP 10000 | |
#define Dict(keyT, valueT) struct { \ | |
int set[CAP]; \ |
This file contains 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
import std / [os, unicode] | |
import pkg / pixie | |
const Root = currentSourcePath().parentDir | |
var im = readImage(Root / "bird512.png") | |
im = im.resize(80, 80) | |
im = im.resize(im.width - (im.width mod 2), im.height - (im.height mod 4)) | |
const start = 0x2800 # "⠀" base braille char codepoint |
This file contains 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
#define SEQ_H_IMPLEMENTATION | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define Seq(T) \ | |
struct { \ | |
T *data; \ | |
T temp; \ | |
size_t size; \ |
This file contains 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
import sys | |
import gzip | |
import json | |
if len(sys.argv) < 3: | |
print("Wrong args. Usage: python speed.py file.tgs 150%") | |
sticker = json.load(gzip.open(sys.argv[1])) | |
stretch = 100 / float(sys.argv[2].strip(" %")) |
This file contains 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
debug: | |
gcc -o main --std=c99 -Wall -Wextra -Werror -pedantic -g main.c && gdb ./main | |
run: | |
gcc -o main --std=c99 -Wall -Wextra -Werror -pedantic main.c && ./main |
OlderNewer