Skip to content

Instantly share code, notes, and snippets.

@7shi
7shi / kbfc.cpp
Last active September 5, 2015 18:15
#include <stdio.h>
#include <string>
#include <vector>
#include <stack>
#include <windows.h> // PE関連の構造体のため
int addr_putchar = 0x00405044;
int addr_getchar = addr_putchar + 4;
int addr_buf = 0x00406000;
open System
open System.Text
let bin (a:uint64) b =
new String(
[| for i in 1..b ->
if (a &&& (1UL <<< (b - i))) = 0UL then '0' else '1' |])
let reverse (u:uint32) =
let rec rev ret i =
// public domain
open System
open System.Text
let reverse (u:uint32) =
let rec rev ret i =
if i = 32 then ret else
rev (if (u &&& (1u <<< i)) = 0u then ret else
ret ||| (1u <<< (31 - i)))
@7shi
7shi / Zip.bas
Created September 10, 2010 12:50
' public domain
Option Explicit
Private Crc32Table&(255)
Private Type ZipHeader
ver As Integer
flags As Integer
compression As Integer
=> http://github.com/7shi/FSharpZip/blob/master/Zip/Zip.fs
@7shi
7shi / test.m
Created September 10, 2010 16:39
#import <AppKit/AppKit.h>
@implementation TestWin: NSObject
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification
{
id win, button, menu = [NSMenu new];
NSRect wf = { {100, 200}, {100, 50} };
NSRect bf = { { 20, 15}, { 60, 20} };
unsigned int style = NSTitledWindowMask | NSClosableWindowMask;
[menu addItemWithTitle:@"Quit"
@7shi
7shi / Hash3.fs
Created September 21, 2010 15:50
type Hash3() =
let list = Array.zeroCreate<List<int>> 65536
let data = new List<byte>()
let mutable pos = 0
let mutable prev2 = 0uy
let mutable prev1 = 0uy
let getList (b1:byte) (b2:byte) (b3:byte) =
let i = ((int b1) <<< 8) ^^^ ((int b2) <<< 4) ^^^ (int b3)
let ret = list.[i]
type ReadBuffer(sin:Stream) =
let mutable length = buflen
let mutable buf :byte[] = null
let mutable buf':byte[] = null
let mutable hash :List<int>[] = [| for _ in 0..4095 -> new List<int>() |]
let mutable hash':List<int>[] = [| for _ in 0..4095 -> new List<int>() |]
let read() =
let buf'', hash'' = buf', hash'
buf' <- buf
--- Download.cs.orig
+++ Download.cs
@@ -161,6 +161,13 @@
{
case "Edition":
Date = xr2["Date"];
+ try
+ {
+ var dt = DateTime.Parse(date);
+ var dir = Path.GetDirectoryName(BaseDir);
// 描画するとこ
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
// listに入ってるものすべてを描画
for (int i = 0; i < list.Count;i++)
{
// listの中身i番目の(X,Y)のXを3つ進めて、それをlistの中身i番目に戻す
var p = list[i];