Skip to content

Instantly share code, notes, and snippets.

View mogproject's full-sized avatar

Yosuke Mizutani mogproject

View GitHub Profile
@mogproject
mogproject / SSHCheatSheet.md
Last active August 31, 2015 06:34
SSH Cheat Sheet

SSH キーペアの作成

ssh-keygen -t rsa -f ~/.ssh/your_key_name -C 'yourname@example.com'
  • パスフレーズはプロンプトから入力

これで

@mogproject
mogproject / ImageConversionCheatSheet.md
Created September 17, 2015 15:27
Image Conversion Cheat Sheet

svg -> png

/Applications/Inkscape.app/Contents/Resources/bin/inkscape \
--without-gui --export-width={{ WIDTH }} \
--file {{ INPUT }}.svg --export-png={{ OUTPUT }}.png
@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):