Skip to content

Instantly share code, notes, and snippets.

View rscarrera27's full-sized avatar
👊
Keep Going

Sunghyun Kim rscarrera27

👊
Keep Going
View GitHub Profile
@rscarrera27
rscarrera27 / fatptr.c
Created April 26, 2021 15:08
Fat pointer of pascal string
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Pstr {
int size;
char* str;
};
char** pstr_new()
@rscarrera27
rscarrera27 / pyenv_install.sh
Created January 10, 2021 08:53
How to pyenv install in Big Sur
export PYVER=3.7.7
CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch $PYVER < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
import asyncio
async def factorial(name, number):
f = 1
for i in range(2, number + 1):
print(f"Task {name}: Compute factorial({i})...")
await asyncio.sleep(1)
f *= i
from dataclasses import dataclass
@dataclass
class Dto:
foo: str
clas DtoMapper:
def build(foo: str) -> Dto:
return Dto(foo)
import asyncio
from functools import reduce
from typing import Any, Callable, Generic, TypeVar, Union
T = TypeVar("T")
R = TypeVar("R")
class Ok(Generic[T]):
def __init__(self, value: T) -> None:
@rscarrera27
rscarrera27 / match.py
Last active February 12, 2020 06:10
Is this possible
@curry({"t", 12})
def do_x(v, t):
...
match(func, arg1, arg2) >> {
str: do_x,
int: lambda x: print x,
InternalException: handle,
...: handle_default,
}
@rscarrera27
rscarrera27 / go_http_handling.go
Created February 9, 2020 10:15
Golang HTTP handling example
package main
import (
"fmt"
"net/http"
)
type Hello struct{}
func (h Hello) ServeHTTP(w http.ResponseWriter, r *http.Request) {
<!DOCTYPE html>
<html>
<head>
<title>ReDoc</title>
<!-- needed for adaptive design -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--
ReDoc doesn't change outer page styles
from sanic import Sanic
from sanic.response import json
from sanic.request import Request
from sanic_jwt_extended import JWT
import uuid
app = Sanic(__name__)
CC AOF
AT 14
BE 13
CL 14
CZ 15
DK 13
EE 13
FI 13
FR 15
IT 14