Skip to content

Instantly share code, notes, and snippets.

View yssource's full-sized avatar

龍共每文 yssource

View GitHub Profile
@yssource
yssource / algebraic.cpp
Created November 26, 2024 09:04 — forked from bzar/algebraic.cpp
Algebraic datatype emulation in C++ (and the same in Rust)
#include <iostream>
#include <cassert>
#include <string>
// Algebraic type
enum ShapeType { CIRCLE, RECTANGLE, ZERO };
struct Circle { int cx, cy, r; static const ShapeType type = CIRCLE; };
struct Rectangle { int x, y, w, h; static const ShapeType type = RECTANGLE; };
struct Zero { static const ShapeType type = ZERO; };
@yssource
yssource / listener.py
Created January 12, 2024 14:38 — forked from westonpace/listener.py
Bare bones example of sending an arrow table from C++ to python via socket
#!/usr/bin/env python3
import socket
import pyarrow as pa
import pyarrow.ipc
listen = "127.0.0.1"
port = 56565
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
@yssource
yssource / main.cpp
Created November 7, 2023 15:42 — forked from brotchie/main.cpp
Minimal C++ implementation of Functor, Monad and Maybe using c++0x variadic templates and lambda expressions.
/*
* Minimal C++ implementation of Functor, Monad and Maybe.
*
* Requires c++0x variadic templates and lambda expressions:
*
* g++ -std=c++0x main.cpp -o main
*
* fmap, monadic bind and return implementations for std::vector
* and Maybe.
*
@yssource
yssource / clang-tidy-readability-identifier-naming-google.yml
Created April 18, 2022 05:41 — forked from airglow923/clang-tidy-readability-identifier-naming-google.yml
clang-tidy readability-identifier-naming for Google's naming convention
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.ClassMemberCase
value: lower_case
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariablePrefix
value: k
- key: readability-identifier-naming.EnumCase
@yssource
yssource / wsutils.py
Created December 3, 2021 14:24 — forked from pocc/wsutils.py
Wrapper for wireshark utils (like pyshark for tshark)
"""
Pcap class to more easily interact with pcaps
When in doubt, aim for simplicity of requests API
Like pyshark, but for the wireshark utilities
"""
import os
import subprocess as sp
import re
import pprint
import tempfile
// an example to create a new mapping `ctrl-y`
mapkey("<Ctrl-y>", "Show me the money", function () {
Front.showPopup(
"a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close)."
);
});
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map("gt", "T");
// an example to remove mapkey `Ctrl-i`
This file has been truncated, but you can view the full file.
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=clang
compiler.libcxx=libstdc++11
compiler.version=10
os=Linux
os_build=Linux
This file has been truncated, but you can view the full file.
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=clang
compiler.libcxx=libstdc++11
compiler.version=10
os=Linux
os_build=Linux
@yssource
yssource / gh-check
Created December 31, 2019 02:23 — forked from lilydjwg/gh-check
gh-check: speed test to known GitHub IPs
#!/usr/bin/python3
import asyncio
import time
import socket
import sys
import aiohttp
class MyConnector(aiohttp.TCPConnector):
@yssource
yssource / Makefile
Created October 31, 2019 09:46 — forked from dtoma/Makefile
makefile rules to check style using clang-format
style:
@for src in $(SOURCES) ; do \
echo "Formatting $$src..." ; \
clang-format -i "$(SRC_DIR)/$$src" ; \
clang-tidy -checks='-*,readability-identifier-naming' \
-config="{CheckOptions: [ \
{ key: readability-identifier-naming.NamespaceCase, value: lower_case },\
{ key: readability-identifier-naming.ClassCase, value: CamelCase },\
{ key: readability-identifier-naming.StructCase, value: CamelCase },\
{ key: readability-identifier-naming.FunctionCase, value: camelBack },\