Skip to content

Instantly share code, notes, and snippets.

@ty60
ty60 / Makefile
Last active July 6, 2023 15:02
Boring ssl client
# Requires an already built boringssl project as subdirectory
TGT := boringssl_client_example
OBJS := boringssl_client_example.o
CFLAGS := -g -I boringssl/include -pthread
LIBS := boringssl/build/ssl/libssl.a boringssl/build/crypto/libcrypto.a boringssl/build/libpki.a boringssl/build/decrepit/libdecrepit.a
${TGT}: ${OBJS}
gcc ${CFLAGS} -o $@ $^ ${LIBS}
@ty60
ty60 / install_mpls_coc_python.vim
Created May 14, 2020 06:44
Vim script to install mpls for coc-python
setfiletype python
CocCommand python.upgradePythonLanguageServer
q
@ty60
ty60 / mnist_cnn.py
Last active April 20, 2020 08:34
mnist tutorial with keras
# https://www.tensorflow.org/tutorials/images/cnn
from __future__ import absolute_import, division, print_function, unicode_literals
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Conv2D, MaxPooling2D, Flatten
from keras.optimizers import RMSprop
@ty60
ty60 / iris.py
Created December 24, 2017 05:40
Oreore implementation of naive bayes
import random
import sys
import json
import numpy as np
from vector import translate_vector
from naive_bayes import NaiveBayes
def gen_vector_counter(vec_len):
if vec_len <= 1:
return defaultdict(int)
else:
t = partial(gen_vector_counter, vec_len - 1)
return defaultdict(t)
@ty60
ty60 / animals.py
Last active November 25, 2017 04:23
Abstract factory pattern
class Dog(object):
def speak(self):
return "woof"
class Cat(object):
def speak(self):
return "meow"
@ty60
ty60 / test_udp.c
Last active July 20, 2024 23:45
C program to send raw UDP packet
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/if_ether.h>
#include <arpa/inet.h>