Skip to content

Instantly share code, notes, and snippets.

@h-hirai
h-hirai / gist:253bf06a65eb142dfc0fee0d14d26783
Last active May 11, 2018 08:06
I didn't know inttypes.h
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int main() {
uint8_t u8 = UINT8_MAX;
uint16_t u16 = UINT16_MAX;
uint32_t u32 = UINT32_MAX;
uint64_t u64 = UINT64_MAX;
@h-hirai
h-hirai / BV.cpp
Last active February 23, 2017 14:27
#include <cstddef>
#include <cstdint>
#include <cassert>
#include <iostream>
template <std::size_t W>
struct BV {
std::uint32_t const value;
explicit constexpr BV(std::uint32_t v) : value(v) {
module FF13_2_DialFacePuzzle where
import Control.Monad (MonadPlus, msum)
import Text.Printf (printf)
import System.Environment (getArgs)
import Debug.Trace (trace)
type Graph = ([Int], [(Int, Int)])
--
@h-hirai
h-hirai / gist:6648418
Created September 21, 2013 08:07
Hello World program without Chars, Strings, Numbers. https://codeiq.jp/ace/cielavenir/q431
module Main where
import Data.Char (chr)
import System.Exit
import Data.Word
-- numbers
num0 :: Int
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
data Hoge = A Int
| B Bool
| C Char
| D
| E String deriving Show
@h-hirai
h-hirai / README.md
Last active December 16, 2015 19:39
Ejecting CD-ROM by Verilog

This is non-sense DPI-C example of SystemVerilog.

This example can run on Windows and ModelSim-Altera 10.1b.

C code is able to be compiled by Mingw-gcc.

to compile:

$ vlib work
@h-hirai
h-hirai / README.md
Last active December 16, 2015 19:39
Ejecting CD-ROM by Haskell.

This is non-sense FFI example of Haskell.

to compile:

$ ghc --make eject.hs c_eject.c

can not choise drive, just run:

$ ./eject
@h-hirai
h-hirai / README.md
Last active December 16, 2015 19:39
Ejecting CD-ROM
#! /bin/bash
IFS_BAK=$IFS
IFS=':'
is_include () {
l=$1
e=$2
for p in $l; do
if [ "$p" == "$e" ]; then
module BitVector (BitVector, unsigned, signed, width, value, toHexStr) where
import Data.Bits
import Data.Monoid
import Text.Printf
data BitVector = BV Int Integer
width :: BitVector -> Int
width (BV w _) = w