Skip to content

Instantly share code, notes, and snippets.

@7shi
7shi / XmlParser.fsx
Last active August 29, 2015 14:03
[F#]簡易 XML Parser
open System
open System.IO
open System.Text
let fromEntity(s: string) =
s.Replace("&lt;", "<").
Replace("&gt;", ">").
Replace("&quot;", "\"").
Replace("&nbsp;", " ").
Replace("&amp;", "&")
@7shi
7shi / Serialize.fsx
Created July 10, 2014 08:57
[F#]シリアライズのテスト
#nowarn "9"
open System
open System.IO
open System.Runtime.InteropServices
[<StructLayout(LayoutKind.Sequential)>]
type Test = struct
val mutable Foo:int
val mutable Bar:uint16
@7shi
7shi / do.fsx
Created July 10, 2014 13:34
[F#]doのインデント
#r "System"
#r "System.Windows.Forms"
open System
open System.Windows.Forms
[<EntryPoint; STAThread>] do
let w = new Form(AllowDrop = true)
Application.Run w
@7shi
7shi / ConvGray8.fsx
Last active August 29, 2015 14:04
[F#]グレースケールJPEGに変換
// This file is in the public domain.
#r "System"
#r "System.Xaml"
#r "PresentationCore"
#r "PresentationFramework"
#r "WindowsBase"
open System
open System.IO
@7shi
7shi / Run_Python.js
Last active August 29, 2015 14:04
[JavaScript]KomodoのPython実行用マクロ
komodo.assertMacroVersion(3);
if (komodo.view) komodo.view.setFocus();
ko.commands.doCommand('cmd_save');
ko.run.runEncodedCommand(window, '%(python) \"%F\" {\'cwd\': u\'%D\'}');
@7shi
7shi / loop.bf
Created July 22, 2014 06:52
[Brainf*ck]約1億回ループ
++++++[>-[>-[>-[-]<-]<-]<-]
@7shi
7shi / test.js
Last active August 29, 2015 14:04
[JavaScript]Brainf*ckを手動トランスレート
// ++++++[>++++++<-]+[>.>,.<<]
var mem = new Uint8Array(30000);
var reg = 0;
var pc = [];
var buf = "";
function putchar() {
process.stdout.write(String.fromCharCode(mem[reg]));
}
@7shi
7shi / binary.hs
Last active August 29, 2015 14:04
[Haskell]バイナリ操作の取っ掛かり
{-# LANGUAGE CPP, TemplateHaskell #-}
-----------------------------------------------------------------------------
--
-- Module : Main
-- Copyright :
-- License : Public Domain
--
-- Maintainer :
-- Stability :
-- Portability :
var ref = require("ref");
var ffi = require("ffi");
var libc = ffi.Library("libc", {
"mmap": ["pointer", ["pointer", "size_t", "int", "int", "int", "int64"]],
"munmap": ["int", ["pointer", "size_t"]],
});
var PROT_READ = 1;
var PROT_WRITE = 2;
@7shi
7shi / 1mkbin.fsx
Last active August 29, 2015 14:04
ARM64の調査。移転しました → https://bitbucket.org/7shi/arm64
open System.IO
for i in 0..0xff do
let dir1 = sprintf "%02x" i
if not <| Directory.Exists dir1 then
ignore <| Directory.CreateDirectory dir1
for j in 0..0xff do
let path = Path.Combine(dir1, sprintf "%02x.bin" j)
printfn "%s" path
let b = (i <<< 24) ||| (j <<< 16)