Skip to content

Instantly share code, notes, and snippets.

@chomy
chomy / daytimed.hs
Created May 2, 2016 09:46
daytime server
import Control.Monad
import Network
import System.IO
import System.Time
main = withSocketsDo $ do
sock<-listenOn (PortNumber 8001)
forever (serve sock)
serve sock = do
@chomy
chomy / png_generation.cc
Created March 24, 2016 07:13
PNG image generation test using libpng++
#include <png++/png.hpp>
int main(void)
{
png::image<png::rgb_pixel> image(256,256);
for(size_t y=0; y<image.get_height(); ++y)
for(size_t x=0; x<image.get_width(); ++x)
image[y][x] = png::rgb_pixel(x,y,(x+y)/2);
image.write("test.png");
return 0;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chomy
chomy / wiringpi-intlpt.cc
Created November 11, 2015 08:09
wiringPi Interruption Test
#include <wiringPi.h>
#include <iostream>
using namespace std;
static const int PIN = 0;
void onInterrupt(void)
{
cout<< "onInterrupt"<< endl;
}
@chomy
chomy / tcpserver_test.cc
Created October 6, 2015 09:23
Test code of TCP Server with thread in C++11 on Winsock
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
#include <string>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <thread>
#include <chrono>
#include <list>
@chomy
chomy / ksj_railroad.py
Created August 12, 2015 08:54
JPGIS(2.1)フォーマットの国土数値情報(鉄道)をParseするスクリプト
#!/usr/bin/python
#-*- Coding:UTF-8 -*-
import xml.sax
import xml.sax.handler
class gml_handler(xml.sax.handler.ContentHandler):
def __init__(self):
self.curves = []
self.railroad_sections = []
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
@chomy
chomy / bcm2835.lisp
Created December 17, 2014 10:49
Common Lisp package for GPIO control of Raspberry Pi
(defpackage :BCM2835
(:use :FFI)
(:export :init
:close
:gpio-fsel
:gpio-write
:gpio-lev
:gpio-set
:gpio-clr
:delay
@chomy
chomy / tcp_client_sample.c
Created October 9, 2014 07:27
TCP client sample
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#define GNU_SOURCE
#include <signal.h>