Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kobayassiy
kobayassiy / nmf.ipynb
Last active July 7, 2023 08:33
NMFサンプル
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aphlysia
aphlysia / stfuawsc_itg_advent2014_4_conda.md
Last active June 16, 2023 01:05
conda で python の環境つくり

これは stfuawsc_itg Advent Calendar 2014 4日目の記事です。

プログラミングをしていると、いろいろなバージョンの環境を行ったり来たりしたくなることがあります。たとえば言語処理は python 2 へ nltk を入れてやりたい。シミュレーションは python 3 へ numpy 入れてやりたいとか。
そういうふうに言語やモジュールのバージョンをいろいろ組合せた環境を気軽に切り替えられると便利です。
実際そういうことを可能にするツールはたくさんあります。virtualenv, pyenv など。
ここで紹介する conda というツールもその1つです。
virtualenv などでは、モジュールを入れるときは通常の python の流儀でインストールするのですが、インストールがうまくいかないというのはよくあることです。conda ではあらかじめビルドされたものを入れるので、楽です。もちろん conda に用意されていないモジュールもありますが、そういうのは pip 等通常の方法で入れて共存できます。

ではさっそく conda で python の環境を作る方法です。

@breakbee
breakbee / gmm_mcmc.py
Created August 9, 2014 19:22
PyStan Code for GMM
import pystan
import numpy as np
import matplotlib.pyplot as plt
mean1 = 10
mean2 = -10
mean3 = 0
num1 = 200
num2 = 300
num3 = 500
@breakbee
breakbee / gmm_mcmc.stan
Created August 9, 2014 19:21
Gaussian Mixture Model for Stan
data {
int<lower=1> N;
int<lower=1> k;
real X[N];
}
parameters {
simplex[k] theta;
real mu[k];
}
model {
@aeg
aeg / EnclosedTest.groovy
Created February 17, 2013 13:17
SpockとJUnitが混在したテストクラス。
import org.junit.Test
import org.junit.experimental.runners.Enclosed
import org.junit.runner.RunWith;
import spock.lang.Specification
@RunWith(Enclosed.class)
class SpockJUnitMixTest {
static class Spockテストグループ1 extends Specification{
def "Spockテスト1-1"() {
when:
@j5ik2o
j5ik2o / gist:2996293
Created June 26, 2012 15:03
リトライハンドラー
case class RetryException(throwables: List[Throwable]) extends Exception(throwables.toString())
object RetryUtil {
import scala.util.control.Exception.allCatch
def retry[T](retryLimit: Int)(f: => T): T =
retry(retryLimit, 0, classOf[Throwable])(f)
@uasi
uasi / git-svn.markdown
Last active March 5, 2024 07:06
git-svn の使い方メモ

git-svn の使い方メモ

git-svn の使い方をメモする。他によいプラクティスがあれば指摘していただけるとありがたい。

用語

SVN のブランチと git のブランチが混在しているため、ここではブランチという語を以下のように区別する。

  • ブランチ、 SVN ブランチ:$SVN_REPO/branches 以下にあるディレクトリ
  • ローカルブランチ:git のローカルブランチ
  • リモートブランチ:git のリモートブランチ
@hzno
hzno / pycompress.py
Created November 25, 2010 01:01
(pycompress.py) A file is compressed by "tar.bz2", "tar.gz" or "zip".
#!/usr/bin/env python
# Author: Iyori Komiyama
# Contact: hazimarino@gmail.co.jp
# site: http://hazimarino.blogspot.com/
"""\
A file is compressed by "tar.bz2", "tar.gz" or "zip".
"""
import os
import tarfile
import zipfile