Skip to content

Instantly share code, notes, and snippets.

View tamamu's full-sized avatar
😇
living

Eddie tamamu

😇
living
View GitHub Profile
@tamamu
tamamu / tmpl.ros
Created October 18, 2021 14:25
Simple project template manager for Common Lisp.
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
(ros:ensure-asdf)
#+quicklisp(ql:quickload '(:djula :cl-ppcre :cl-fad) :silent t))
use std::ffi::CString;
use std::mem::zeroed;
use std::os::raw::{c_char, c_int, c_uint};
use std::ptr;
use x11::xlib;
fn main() {
let display = unsafe { xlib::XOpenDisplay(CString::default().as_ptr()) };
let mut attr: xlib::XWindowAttributes = unsafe { zeroed() };
let mut start: xlib::XButtonEvent = unsafe { zeroed() };
@tamamu
tamamu / dispatch_performance.cpp
Created March 10, 2021 14:36
Performance comparison between dynamic-dispatch of virtual function and static function calling in switch clause
#include <iostream>
#include <string>
#include <vector>
#include <chrono>
class Performance
{
private:
std::chrono::system_clock::time_point now;
public:
@tamamu
tamamu / gendockerfile.py
Created January 26, 2021 08:02
Generate Dockerfile from current Python environment
import imp
import os.path
import sys
import types
import platform
__dockerfile_template__ = """
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
@tamamu
tamamu / chat.rs
Created August 24, 2020 11:12
Rustでチャットサーバ(TCP)を書く
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use std::{thread, time};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
const HOST: &'static str = "127.0.0.1:80";
struct Server {
connections: HashMap<String, Arc<Mutex<TcpStream>>>,
@tamamu
tamamu / vkffi.lisp
Created August 19, 2020 02:43
Show Vulkan instance extension properties with handwritten Common Lisp binding by CFFI
(ql:quickload :cffi)
(defpackage vkffi
(:use :cl :cffi))
(in-package vkffi)
(define-foreign-library vulkan
(:windows "vulkan-1.dll"))
@tamamu
tamamu / main.rs
Created August 3, 2020 12:28
HTMLパーサーを書く
/**
* HTMLパーサーを書くぞ
* 宣言: <!DECLARE>
* 開始タグ: <TAGNAME ATTRNAME=ATTRVAR>
* テキスト: TEXT
* 終了タグ: </TAGNAME>
*
*
*
*/
@tamamu
tamamu / Makefile
Last active July 6, 2020 10:10
SDL2で作る簡略ゲームエンジン(Linuxで動作確認済み)
#OBJS specifies which files to compile as part of the project
OBJS = main.cpp
#CC specifies which compiler we're using
CC = g++
#COMPILER_FLAGS specifies the additional compilation options we're using
# -w suppresses all warnings
COMPILER_FLAGS = -w -std=c++17 -g
@tamamu
tamamu / main.py
Created June 17, 2020 09:55
Super Simplified Web Browser
import tkinter as tk
import urllib.request
import io
from PIL import Image, ImageTk
from urllib.parse import urljoin
from html.parser import HTMLParser
from tkx import VerticalScrolledFrame
class MyHTMLParser(HTMLParser):
def __init__(self, parent):
@tamamu
tamamu / dango.js
Created May 2, 2020 11:39
Draw 団子es with p5.js
let dangoes = [];
class Dango {
constructor(x, y, num) {
this.x = x;
this.y = y;
this.num = num;
this.rad = 0;
this.colors =
new Array(num)