Skip to content

Instantly share code, notes, and snippets.

@sambaiz
sambaiz / file0.txt
Created December 24, 2013 09:19
SpriteKitで横画面の左下を(0,0)にする ref: http://qiita.com/sambaiz/items/681ff4c0db90613b9312
SKSpriteNode *ground = [SKSpriteNode spriteNodeWithColor:[SKColor yellowColor]
size:CGSizeMake(self.frame.size.width, self.frame.size.height*0.2)];
ground.anchorPoint = CGPointMake(0, 0);
ground.position = CGPointMake(CGRectGetMinX(self.frame), 0);
@sambaiz
sambaiz / ai.pl
Last active August 29, 2015 13:55
perlではない
%?- talk(hello, X). で会話できる
talk(hello, hello).
talk(こんにちは, こんにちは).
talk(ばか, あほ).
talk(今日はいい天気ですね, そうですね).
talk(あなたはだれ?, 人工知能です).
#シーザー暗号
#ruby caesar.rb piyopiyo -2
#ngwmngwm
def caesar_cipher(str, shift)
str.split(//).each {|c| print (c.ord + shift.to_i).chr}
end
caesar_cipher(ARGV[0], ARGV[1])
@sambaiz
sambaiz / angou.scala
Created February 13, 2014 19:02
abcdefghijklm <-> nopqrstuvwxyzで文字を置換しただけの暗号@CodeIQ
scala> val angou = "fhaal naq jvaql"
angou: String = fhaal naq jvaql
scala> angou.map({s => if(s < 'a' || s > 'z') s else if(s <= 'm') (s + 'n' - 'a').toChar else (s - 'n' + 'a').toChar})
res43: String = sunny and windy
# -*- coding: utf-8 -*-
import numpy as np
import pylab as plt
import copy
def jacobi_or_seidel(x, a, b, use_jacobi = True):
cpx = copy.copy(x) if use_jacobi else x
for i in range(x.size):
cpx[i] = b[i]
@sambaiz
sambaiz / lettercount.rb
Last active August 29, 2015 13:56
英文テキストファイルの各アルファベットの数を出力して割合をグラフで表示する
require "gnuplot"
# (gem install gnuplot)
# (brew install gnuplot)
INPUT_DATA = ARGV[0] || raise("input file name is not given")
OUTPUT_DATA = ARGV[1] || "output.txt"
OUTPUT_GRAPH = ARGV[2] || "output.eps"
n = 0
@sambaiz
sambaiz / hakuhoudou1.rb
Created February 21, 2014 11:23
URLデコード(utf-8)@某ES-1
require 'uri'
buf = ""
File::open(ARGV[0]) {|file|
file.each {|line|
line = buf + line.strip
while line.length >= 9 do
print URI.decode(line[0..8])
line = line[9..line.length-1]
end
buf = line
@sambaiz
sambaiz / hakuhoudou2.rb
Created February 23, 2014 15:37
RSA暗号方式の復号@某ES-2
require 'uri'
require 'prime'
# RSA暗号
# 公開鍵(E, N)
E = 47 #適当な正整数
N = 323 #素数p * 素数q
D_RANGE = 1000 #秘密鍵の推定最大値(一応ループ回避)
def decryption(x, d)
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
/**
* Created by sambaiz on 2014/03/06.
*/
@sambaiz
sambaiz / setup.py
Created March 19, 2014 07:54
cocos2d-xのsetup.py fish対応版
#!/usr/bin/python
#coding=utf-8
"""****************************************************************************
Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights