Skip to content

Instantly share code, notes, and snippets.

@nullkal
nullkal / lifegame.kn
Created August 1, 2012 12:08
Life Game for Kuin
func Init(cfg : Kuin@CCfg)
do cfg.Title :: "Life Game for Kuin"
do cfg.FullScr :: false
do cfg.PadNum :: 1
do cfg.WaitTime :: 60
end func
func Main()
var WIDTH : int :: 168
var HEIGHT : int :: 96
┌───────────┐
│┏━━━━━━━━━┓│
│┃                  ┃│
│┃                  ┃│
│┃       ___     ┃│
│┃ _   /  _  `   ┃│
│┃│  \/ /   ││  ┃│
│┃│ \  / ─────┘\
│┗┷┷/ , \ k y u b u n s   >
└─┬ / /\ \_.───┐/
@nullkal
nullkal / lifegame.scm
Created September 27, 2012 12:26
ライフゲーム
(define (rot_l l)
(append (cdr l) (list (car l))))
(define (rot_r l)
(reverse (rot_l (reverse l))))
(define (forward_generation g)
(map (lambda (m n)
(map (lambda (m n)
(if (= n 1)
@nullkal
nullkal / gist:6306428
Created August 22, 2013 12:15
FreeBSD向けのMinecraft(bukkit)鯖 起動スクリプト。 必要なもの: Java, tmux, 鯖を配置した各ディレクトリに一つstart.sh(bukkit Wikiに書いてあるLinux用craftbukkit.shそのままでOK)
#!/bin/sh
# PROVIDE: mc-servers
# REQUIRE: LOGIN
. /etc/rc.subr
name="mc_servers"
rcval=mc_servers_enable
@nullkal
nullkal / solve.cpp
Last active December 22, 2015 03:19
クロッシング問題の回答。計測位置間違えてそうなことに提出後に気づいた。 普通にマージソートで転倒数求めてます。Rubyでやったら配列の確保とかに時間かかってるっぽかったので、修正も面倒だしC++で書き直しました。途中までin-placeなマージソートの実装追い求めてましたが、色々頭が混乱してきたので最終的に至って普通のマージソートになりました。
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <chrono>
#include <cstdint>
std::vector<int> buf;
std::uintmax_t answer = 0;
#include <stdio.h>
char buf[] = {
0x2A, 0x37, 0x74, 0x35, 0x7C, 0x2E, 0x67, 0x3E, 0x77, 0x3C, 0x62, 0x24, 0x3E, 0x2E,
0x2E, 0x66, 0x3D, 0x7D, 0x3E, 0x25, 0x2F, 0x31, 0x31, 0x35, 0x3F, 0x48, 0x2F, 0x53,
0x54, 0x55, 0x56, 0x54, 0x37, 0x5E, 0x5D, 0x33, 0x42, 0x1D, 0x64, 0x9 , 0x70, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF
};
char key[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@nullkal
nullkal / decrypt.c
Created January 1, 2015 13:11
年賀CTF
#include <stdio.h>
#include <stdlib.h>
unsigned int decode_shl(unsigned int var, unsigned int bit, unsigned int key);
unsigned int decode_shr(unsigned int var, unsigned int bit, unsigned int key);
int main(int argc, char *argv[])
{
unsigned int var;
FILE *src_fp, *dest_fp;
@nullkal
nullkal / gist:0b23ed80ebcb1319d83e
Created January 5, 2015 09:47
paizaのアレをRubyのワンライナーで解いてみた
# 01
p $<.drop(1).map(&:to_i).inject(&:+)
# 02
p $<.drop(1).inject(0){|m,n|t,s,p=n.split.map(&:to_i);m+=p.*t>s ?t-s :0}
# 03
t,m,*p=gets.to_i,c=0;$<.each{|n|c+=l=n.to_i;p<<l;p.size<t||(m>c||m=c)&&c-=p.shift};p m
@nullkal
nullkal / decode.rb
Created February 4, 2015 20:49
BASE六十四卦
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'base64'
table = Hash[*"䷀䷪䷍䷡䷈䷄䷙䷊䷉䷹䷥䷵䷼䷻䷨䷒䷌䷰䷝䷶䷤䷾䷕䷣䷘䷐䷔䷲䷩䷂䷚䷗䷫䷛䷱䷟䷸䷯䷑䷭䷅䷮䷿䷧䷺䷜䷃䷆䷠䷞䷷䷽䷴䷦䷳䷎䷋䷬䷢䷏䷓䷇䷖䷁".split("").zip("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("")).flatten]
puts Base64.decode64((gets.split("").map {|c| table[c]}).join)
From ead74bca51c4cccec09219a36dd316970f2eda1a Mon Sep 17 00:00:00 2001
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Tue, 14 Apr 2015 02:25:27 +0000
Subject: [PATCH] printf.c: uint_to_str
* ext/-test-/printf/printf.c (uint_to_str): renamed to get rid of
conflict on cygwin. [ruby-core:68877] [Bug #11065]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---