Skip to content

Instantly share code, notes, and snippets.

View mogproject's full-sized avatar

Yosuke Mizutani mogproject

View GitHub Profile
@mogproject
mogproject / FibonacciMatrix.scala
Created November 17, 2012 23:46
Find Fibonacci Numbers Using Matrix Multiplication
// 行列累乗を使ってフィボナッチ数列を求めてみる
// 参考
// http://blog.scala4java.com/2011/12/matrix-multiplication-in-scala-single.html
import annotation.tailrec
import scala.util.control.Exception._
object FibonacciMatrix {
type Matrix = Array[Array[BigInt]]
def mul(m1: Matrix, m2: Matrix) = {
@mogproject
mogproject / FizzBuzz.scala
Last active December 23, 2015 04:39
FizzBuzz in Scala
object FizzBuzz {
private val divs = List((3, "Fizz"), (5, "Buzz"))
def fizzBuzz(n: Int): String = {
val ret = (divs map {case (i, s) => if (n % i == 0) s else ""}).mkString
if (ret.isEmpty) n.toString else ret
}
def main(args: Array[String]) {
def printAll(n: Int) { (1 to n) foreach {n => println(fizzBuzz(n))} }
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import struct
from bitarray import bitarray
def double_to_bitstring(d):
b = bitarray()
b.frombytes(struct.pack('!d', d))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Combinatorial Optimization - B.Korte, J.Vygen
Algorithm 1.1
Path Enumeration Algorithm
"""
def back_track(n):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Combinatorial Optimization - B.Korte, J.Vygen
Algorithm 1.2
Merge-Sort Algorithm
"""
def merge_sort(a):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Check if the graph is bipartite.
"""
import collections
class Graph(object):
for(i<-1 to'd')println(Seq("Fizz"*(1-i%3)+"Buzz"*(1-i%5),""+i)max)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""""
Bipartite graph matching algorithm
"""
import collections
class Graph(object):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
print_histo.py
Visualize histogram as text.
"""
import sys
import numpy
----system---- ---load-avg--- ----total-cpu-usage---- -dsk/total- -net/total- ------memory-usage----- ---paging-- ---system-- -most-expensive- ----most-expensive---- ----most-expensive---- --most-expensive-
date/time | 1m 5m 15m |usr sys idl wai hiq siq| read writ| recv send| used buff cach free| in out | int csw | cpu process | i/o process | block i/o process | memory process
11-01 07:24:47|0.74 0.79 0.37| 0 0 99 0 0 0| 19k 110k| 0 0 | 409M 221M 1306M 1894M| 50B 125B| 141 166 |docker 0.1|docker 103k 93k|docker 100k 51k|docker 58.0M
11-01 07:24:48|0.74 0.79 0.37| 0 2 98 0 0 0| 0 124k| 60B 534B| 410M 221M 1306M 1893M| 0 0 | 135 68 | |sshd: vagra1773B 480B| |docker 58.0M
11-01 07:24:49|0.74 0.79 0.37| 1 1 99 0 0 0| 0 0 | 60B 198B| 410M 221M 1306M 1893M| 0 0 | 49 30 | |sshd: vagra 591B 144B|loop1 0 4096B|docker