Skip to content

Instantly share code, notes, and snippets.

@siritori
siritori / error
Created July 8, 2012 13:25
http-server.c
http-server-fork.c: In function ‘http_receive_request’:
http-server-fork.c:241: warning: implicit declaration of function ‘strdup’
http-server-fork.c:241: warning: assignment makes pointer from integer without a cast
http-server-fork.c:243: warning: initialization makes pointer from integer without a cast
http-server-fork.c: In function ‘sockaddr_print’:
http-server-fork.c:375: warning: implicit declaration of function ‘getnameinfo’
http-server-fork.c:376: error: ‘NI_NUMERICHOST’ undeclared (first use in this function)
http-server-fork.c:376: error: (Each undeclared identifier is reported only once
http-server-fork.c:376: error: for each function it appears in.)
http-server-fork.c:376: error: ‘NI_NUMERICSERV’ undeclared (first use in this function)
let rec seq n_from n_to =
if n_from <= n_to then
let rec seq_ n acc = match n with
| n when n = n_from-1 -> acc
| _ -> seq_ (n-1) (n::acc)
in seq_ n_to []
else
[]
@siritori
siritori / client.ml
Created December 19, 2012 01:14
HTTP client
let bufsize = 1024;;
let port = 80;;
let http_get sock =
let rec http_get' sock acc =
let buf = String.create bufsize in
if Unix.read sock buf 0 (String.length buf) = 0 then acc
else http_get' sock acc ^ buf
in http_get' sock "";;
@siritori
siritori / hoge.cpp
Created January 29, 2013 23:15
なんでエラーでるんー
#include <iostream>
#include <list>
#include <memory>
class hoge;
typedef std::shared_ptr<hoge> hoge_ptr;
class hoge
{
public:
hoge(const int x):x_(x)
module memory(CLK, WR, addr, data);
// default parameters
parameter WORD = 32;
parameter LEN = 65535;
input CLK;
input WR; // 0:read 0:write
input [WORD-1:0]addr;
inout [WORD-1:0]data;
@siritori
siritori / gist:4967071
Created February 16, 2013 14:06
My first CPU which executes Whitespace!
// INSTRUCTIONS
`define PUSH 0
`define DUP 1
`define COPY 2
`define SWAP 3
`define POP 4
`define SLIDE 5
`define ADD 6
`define SUB 7
`define MUL 8
@siritori
siritori / expr.cpp
Last active January 1, 2016 09:09
comp2013 - arithmetic expression parser
#include <iostream>
#include <memory>
#include <cctype>
#include <cassert>
#include "expr.h"
namespace {
expr::ptr read_number(std::istream &is);
expr::ptr read_factor(std::istream &is);
@siritori
siritori / Area.java
Created May 9, 2014 01:44
情報科学I
public class Area
{
public static void main(String args[]) {
double width = Integer.parseInt(args[0]);
double height = Integer.parseInt(args[1]);
System.out.println("Input Width : " + width);
System.out.println("Input Height : " + height);
System.out.println("Triangle Area : " + width * height / 2.0);
System.out.println("Square Area : " + width * height);
System.out.println("Circle Area : " + width * width * 3.14);
@siritori
siritori / Letter.java
Created May 13, 2014 01:30
情報科学I
public class Letter
{
public static void main(String args[]) {
char ch = args[0].charAt(0);
System.out.println("Input a letter[A-E] : " + ch);
switch(ch) {
case 'A':
System.out.println("Excellent");
break;
case 'B':
@siritori
siritori / ArgsCheck.java
Created May 20, 2014 01:53
情報科学I
public class ArgsCheck
{
public static void main(String args[]) {
if(args.length != 1) {
System.err.println("Wrong arguments");
return;
}
int number = Integer.parseInt(args[0]);
if(check(number)) {
System.out.println(number + " is OK!");