Skip to content

Instantly share code, notes, and snippets.

View tasuten's full-sized avatar
🛏️
out sick for a few years

tasuten tasuten

🛏️
out sick for a few years
View GitHub Profile
@tasuten
tasuten / rpncalc.rb
Created July 1, 2012 12:42
Reverse Polish Notation Calc by Ruby
#!/usr/bin/env ruby
# encoding : utf-8
# Complexクラスは1.9.xでは組み込みクラスになった
# require 'complex'
include Math
ONE_ARG_FUNCS = %w(sin cos tan asin acos atan sinh cosh tanh asinh acosh atanh exp log log10 log2 sqrt)
stack = []
@tasuten
tasuten / hello.rb
Created September 20, 2013 18:37
挑戦者求む!【言語指定】Restricted Words by @cielavenir cielavenir│CodeIQ https://codeiq.jp/ace/cielavenir/q431 の私の回答です。
#!/usr/bin/env ruby
# encoding : utf-8
# Timeの現在時刻のUNIXタイムから、まず0と1を作る
time = Time.now.to_i
zero = time
one = time
if time.zero?
# zero = time
@tasuten
tasuten / fizzbuzz.scm
Last active January 1, 2016 20:49
書き初め@2014
#!/usr/local/bin/gosh
(define (main args)
(print (map fizzbuzz (iota 2014 1)))
0 )
(define (dividable x y)
(zero? (mod x y)))
(define (fizzbuzz x)
(cond
@tasuten
tasuten / deps.rb
Last active November 30, 2015 23:17
brewのパッケージの依存関係をDOT言語で出力
#!/usr/bin/env ruby
# encoding : utf-8
# 使い方
# $ ./deps.rb > deps.dot
# Graphvizで出力
# $ dot -Tpng deps.dot -o deps.png
# deps.pngを開く
# 図の見方として
@tasuten
tasuten / collatz.scm
Created January 1, 2015 15:10
書き初め@2015
#!/usr/local/bin/gosh
(define (collatz-next n)
(cond
((even? n) (/ n 2))
((odd? n) (+ (* n 3) 1)))
)
(define (collatz n)
@tasuten
tasuten / simple_http_version.rb
Created July 8, 2015 18:54
Metasploit Frameworkのモジュールを練習がてら書いたもの。~/.msf4/modules/auxiliary/scanner/http/simple_http_version.rbあたりに置くと良いと思います
#!/usr/bin/env ruby
# encoding : utf-8
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::Tcp
include Msf::Auxiliary::Scanner
def initialize
super(
'Name' => 'Simple HTTP server detector',
@tasuten
tasuten / history-statistics.zsh
Last active October 8, 2015 19:09
zshのコマンド履歴でよく使うコマンド順に上位10個表示
# これはzshのhistoryの設定に依存するかも
# zshのヒストリファイルを~/.zsh-historyとして
# かつzshのextended_historyをONにしている場合使える
cat $HOME/.zsh-history | awk 'FS=";" {print $2}' | awk '{print $1}'| LANG=C sort | LANG=C uniq -c | LANG=C sort -nr | head
@tasuten
tasuten / rsatool.rb
Last active November 24, 2015 21:50
Arranged https://github.com/ius/rsatool, written by Ruby
#!/usr/bin/env ruby
# encoding : utf-8
# LICENSE: Public Domain
# all of this libraries are Ruby's standard library
# no gem required
require 'base64'
require 'openssl'
require 'optparse'
@tasuten
tasuten / multiple_of_9.ex
Last active January 1, 2016 13:44
書き初め@2016
defmodule Kakizome do
def multiple_of_nine?(x) when not is_integer(x), do: false
# negative integer
def multiple_of_nine?(n) when n < 0, do: multiple_of_nine?(-n)
# 0, 1, 2, 3, 4, 5, 6, 7, 8 -> false
def multiple_of_nine?(n) when n <= 8 , do: false
def multiple_of_nine?(9), do: true
def multiple_of_nine?(n) do
# Is sum-of-digits-in-decimal multiple of 9 ?
n |> Integer.to_string |> String.codepoints |> \
@tasuten
tasuten / miller_rabin.rs
Last active January 1, 2017 13:34
書き初め@2017
fn is_prime(n: u64) -> bool {
return miller_rabin_test(n,
[2, 325, 9375, 28178, 450775, 9780504, 1795265022]);
}
fn miller_rabin_test(n: u64, bases: [u64; 7]) -> bool {
match n {
0 | 1 => return false,
2 | 3 => return true,
n if n & 1 == 0 => return false,