Skip to content

Instantly share code, notes, and snippets.

View dnaga392's full-sized avatar
🐱
In front of the computer

mountlong dnaga392

🐱
In front of the computer
View GitHub Profile
@yymm
yymm / checker.py
Last active October 26, 2017 02:10
Encoding and newline checker (required chardet)
import os
from chardet.universaldetector import UniversalDetector
def check_encode(file_path):
detector = UniversalDetector()
with open(file_path, mode='rb') as f:
for binary in f:
detector.feed(binary)
if detector.done:
@krovma
krovma / the-monster-license.txt
Last active August 6, 2026 16:24
The Monster License
"THE MONSTER LICENSE" (Rev. 11.45.14):
<krovma726@gmail.com> wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a Monster Energy®[https://www.monsterenergy.com]
in return. Shitao "KZ" Zhou
Pirate from [https://en.wikipedia.org/wiki/Beerware]
------------------------------------------------------------
------------------------TRANSLATION-------------------------
------------------------------------------------------------
"MONSTER协议" (11.45.14版):
@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 の環境を作る方法です。

@Gab-km
Gab-km / obsolete.py
Last active July 31, 2017 04:12
C# の Obsolete 属性を Python に持ち込んでみた。
def obsolete(message=None, deprecated=False):
"""今後使用しない関数やメソッドにマークを付けます。
@message 警告に表示するテキスト
@deprecated すでに非推奨の場合、True
今後非推奨になる予定の場合、False
@see http://msdn.microsoft.com/ja-jp/library/system.obsoleteattribute.aspx
"""
def outer(fn):
import warnings
def inner(*args, **kwargs):