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
| namespace CSharpFromPythonNamespace | |
| { | |
| public class CSharpFromPythonClass | |
| { | |
| public string Hi(string x) | |
| { | |
| return "Hi " + x; | |
| } | |
| public static string Hello(string x) |
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
| // gcc -shared -fPIC log_file_access_dynamic.c -o log_file_access_dynamic.so -ldl; LD_PRELOAD=$PWD/log_file_access_dynamic.so /usr/bin/cat log_file_access_dynamic.c | |
| #define _GNU_SOURCE | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <unistd.h> | |
| #include <errno.h> | |
| #include <dlfcn.h> | |
| #include <sys/stat.h> |
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
| # Usage: | |
| # gdbpython script.py my_script_arguments | |
| # gdbbacktrace ./my_program arg1 arg2 | |
| alias gdbpython="gdb -ex run --args python" | |
| alias gdbbacktrace="gdb -batch -ex run -ex bt --args" | |
| alias gdbbacktracequit="gdb -ex 'set pagination off' -ex 'set confirm off' -iex 'set debuginfod enabled on' -ex run -ex 'thread apply all bt' -ex quit --args" |
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
| alias cmdline='ps --no-headers -o comm,args -p' | |
| cmdline 1 | |
| # can produce JSON, but without process args | |
| alias notbrokenjson='ps --no-headers -o '\''{"pcpu": %C, "group": "%G", "PPID": %P, "user": "%U", "comm": "%c", "rgroup": "%g", "nice": "%n", "pid": %p, "pgid": %r, "etime": "%t", "ruser": "%u", "time": "%x", "tty": "%y", "vsz": %z}'\'' -p' | |
| notbrokenjson 1 > notbroken.json | |
| # does not remove escape sequences or quotes in args - this will break JSON format for some processes | |
| alias brokenjson='ps --no-headers -o '\''{"pcpu": %C, "group": "%G", "PPID": %P, "user": "%U", "args": "%a", "comm": "%c", "rgroup": "%g", "nice": "%n", "pid": %p, "pgid": %r, "etime": "%t", "ruser": "%u", "time": "%x", "tty": "%y", "vsz": %z}'\'' -p' | |
| brokenjson 1 > brokenjson.json |
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
| # git clone https://gist.github.com/vadimkantorov/fe63f8628ff6cad460e934e1d7ed650b | |
| # cd fe63f8628ff6cad460e934e1d7ed650b | |
| # uv venv | |
| # uv sync | |
| # https://github.com/vllm-project/vllm/pull/20358#issuecomment-3247178818 | |
| # https://github.com/vllm-project/vllm/issues/9244 | |
| # https://github.com/astral-sh/uv/issues/8082 | |
| # https://github.com/vllm-project/vllm/issues/24126 |
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
| # https://stackoverflow.com/questions/71944328/how-to-implement-json-format-logs-in-python | |
| import json | |
| import logging | |
| # https://docs.python.org/3/library/logging.html#logrecord-attributes | |
| formatter = type('JsonFormatter', (logging.Formatter, ), dict(format = lambda self, record: json.dumps(dict(time = self.formatTime(record), level = record.levelname, message = record.getMessage(), module = record.module, lineno = record.lineno)) ))() | |
| # simpler version below does not escape quotes in message and does not delete newlines in message | |
| # formatter = logging.Formatter('{\"time\": \"%(asctime)-s\", \"level\": \"%(levelname)-s\", \"message\": \"%(message)s\", \"module\": \"%(module)s\", \"lineno\": %(lineno)d}') |
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
| # Usage: | |
| # 1. Put in your email/SendGrid credentials or phone/Twilio credentials | |
| # 2. Run as: "bash rdv_naturalisation.sh nanterre" or "bash rdv_naturalisation.sh bobigny" or "bash rdv_naturalisation.sh cre" | |
| # 3. Get your RDV! The script will dump the HTML of the page and will continue execution even after the first RDV is found. | |
| SENDGRID_BEARER_TOKEN='' # should start with "SG." | |
| SENDGRID_EMAIL='' # put your e-mail here | |
| TWILIO_SID='' # should start with "AC" | |
| TWILIO_AUTH_TOKEN='' | |
| TWILIO_FROM_NUMBER='' # put your Twilio Trial Phone Number here, should start with + |
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
| echo '{"site": {"hello": "world"}}' > foo.json | |
| echo 'Hello {{ site.hello }}' > foo.txt.j2 | |
| bash j2.sh -t foo.txt.j2 -i foo.json -o foo.txt | |
| cat foo.txt | |
| source function.sh | |
| j2 -t foo.txt.j2 -i foo.json -o foo.txt | |
| cat foo.txt | |
| unset -f j2 |
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
| # supports only strings, dicts and lists | |
| # does not support multiline strings as the first list-item key `- run: |` | |
| # does not preserve whitespaces in " |" literal string blocks as described in : https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html | |
| def yaml_loads(content, convert_bool = True, convert_int = True, convert_dict = True, convert_none = True): | |
| def procval(val): | |
| read_until = lambda tail, chars: ([(tail[:i], tail[i+1:]) for i, c in enumerate(tail) if c in chars] or [(tail, '')])[0] | |
| val = val.strip() | |
| is_quoted_string = len(val) >= 2 and ((val[0] == val[-1] == '"') or (val[0] == val[-1] == "'")) |
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
| # https://en.wikipedia.org/wiki/Base64 | |
| # 00123456 00ABCDEF 00abcdef 00uvwxyz | |
| # 123456AB CDEFabcd efuvwxyz | |
| # this code does not support batches. adapting for e.g. concatenated varlen format is possible, but need to handle/preserve varlen information and paddings in some way | |
| import torch | |
| def base64_encode_padded(input_as_uint8_tensor): | |
| base64_alphabet, base64_pad = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', '=' | |
| device = input_as_uint8_tensor.device |
NewerOlder