Skip to content

Instantly share code, notes, and snippets.

@tori29umai0123
tori29umai0123 / ContentSafetyAnalyzer.py
Last active June 14, 2024 02:36
ContentSafetyAnalyzer.py
import csv
import os
from pathlib import Path
import cv2
import numpy as np
from PIL import Image
import onnxruntime as ort
from huggingface_hub import hf_hub_download
@drumnation
drumnation / genre-seeds.json
Created January 20, 2019 22:36
Spotify Genre Seeds Available
{
"genres": [
"acoustic",
"afrobeat",
"alt-rock",
"alternative",
"ambient",
"anime",
"black-metal",
"bluegrass",
@ftnext
ftnext / titanic_handson_sample_code.ipynb
Created January 10, 2019 11:58
サポーターズ勉強会「Kaggleタイタニックハンズオン」
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@d-kuro
d-kuro / git-completion_zsh.md
Last active April 20, 2023 01:25
zsh で git コマンドの補完を有効にする

zsh で git コマンドの補完を有効にする

brew で git をインストールした

$ ls -l `brew --prefix`/share/zsh/site-functions/

_gitgit-completion.bash が表示されていることを確認する。

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

http://nao-y.hatenablog.com/entry/2018/08/01/231336 のコードではまった原因

Pythonでは import したモジュールはキャッシュされ、もう一度 import してもインポート処理は省略され、キャッシュが使われる

  • このため、 import_module 関数を使っても import 文を使っても、 fortune.py は1回しか実行されない
  • blogでは、この問題回避のために reload を使っている
  • このgistのコードでは、import時のコード実行にたよらずに、main関数を用意し、テストからはこれを呼ぶことで明示的に実行している

このgistのテストコードでは、patchデコレータの引数を変えた版を用意した(test2.py)。 また、テストメソッドにはmock後のオブジェクトが渡されるため、引数に m を受け取るようにした。

@voluntas
voluntas / death_march.md
Last active February 13, 2026 13:32
デスマーチが起きる理由 - 3つの指標

デスマーチが起きる理由 - 3つの指標

著者: 青い鴉(ぶるくろ)さん @bluecrow2

これは結城浩さんの運用されていた YukiWiki に当時 Coffee 様 (青い鴉(ぶるくろ)さん)がかかれていた文章です。 ただ 2018 年 3 月 7 日に YukiWiki が運用停止したため消えてしまいました。その記事のバックアップです。

今は 404 ですが、もともとの記事の URL は http://www.hyuki.com/yukiwiki/wiki.cgi?%A5%C7%A5%B9%A5%DE%A1%BC%A5%C1%A4%AC%B5%AF%A4%AD%A4%EB%CD%FD%CD%B3 になります。

昔、自分がとても感銘を受けた文章なので、このまま読めなくなるのはとてももったいないと思い、バックアップとして公開しています。

@lorey
lorey / markdown_to_text.py
Last active January 20, 2026 14:20
Markdown to Plaintext in Python
from bs4 import BeautifulSoup
from markdown import markdown
import re
def markdown_to_text(markdown_string):
""" Converts a markdown string to plaintext """
# md -> html -> text since BeautifulSoup can extract text cleanly
html = markdown(markdown_string)
@erdem
erdem / countries.json
Last active February 24, 2026 16:12
Country list as JSON format. fields: name, coordinates, timezones, country code and capital resource: https://github.com/mledoze/countries
[
{
"timezones": [
"America/Aruba"
],
"latlng": [
12.5,
-69.96666666
],
"name": "Aruba",
@hrp
hrp / twitter.json
Created April 4, 2011 00:20
Example JSON response from Twitter streaming API
{
"text": "RT @PostGradProblem: In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during ...",
"truncated": true,
"in_reply_to_user_id": null,
"in_reply_to_status_id": null,
"favorited": false,
"source": "<a href=\"http://twitter.com/\" rel=\"nofollow\">Twitter for iPhone</a>",
"in_reply_to_screen_name": null,
"in_reply_to_status_id_str": null,
"id_str": "54691802283900928",