This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding : utf-8 | |
# 使い方 | |
# $ ./deps.rb > deps.dot | |
# Graphvizで出力 | |
# $ dot -Tpng deps.dot -o deps.png | |
# deps.pngを開く | |
# 図の見方として |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/gosh | |
(define (collatz-next n) | |
(cond | |
((even? n) (/ n 2)) | |
((odd? n) (+ (* n 3) 1))) | |
) | |
(define (collatz n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# これは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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |> \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
OlderNewer