Skip to content

Instantly share code, notes, and snippets.

View ento's full-sized avatar

ento

View GitHub Profile
@ento
ento / flask_static_file_for.py
Created April 4, 2012 16:28
Given a (static) endpoint, return its actual filesystem location.
import os
from flask import current_app, request
def static_file_for(endpoint, filename=None):
if endpoint[0] == '.' and request.blueprint:
folder = current_app.blueprints[request.blueprint].static_folder
else:
folder = current_app.static_folder
return os.path.join(folder, filename) if folder else None
@ento
ento / gist:2477429
Created April 24, 2012 07:23
Getting the model instance from Python's fixture dataset row
import logging
import sqlalchemy as sa
from sqlalchemy import MetaData
from sqlalchemy import orm, create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from fixture import DataSet
from fixture import SQLAlchemyFixture
from fixture.style import NamedDataStyle
@ento
ento / gist:3090348
Created July 11, 2012 13:18
Bookmarklet: Open in Chrome
javascript:location.href="googlechrome"+location.href.slice(location.href.search("://"));
@ento
ento / gist:3168822
Created July 24, 2012 08:26
.screenrc
escape ^t^t
zombie "^d^r"
hardstatus alwayslastline I%wI
@ento
ento / gist:3524077
Created August 30, 2012 08:16
Make python understand 'utf8mb4' as an alias for 'utf8'
# oursql in particular doesn't recognize utf8mb4 as a valid charset
# source: https://code.djangoproject.com/ticket/18392#comment:10
import codecs
codecs.register(lambda name: codecs.lookup('utf8') if name == 'utf8mb4' else None)
@ento
ento / gist:3888966
Created October 14, 2012 15:43 — forked from jkerian/gist:2305769
Comments on some of the resource questions in JL&U
@ento
ento / 0 chakoshi settings.md
Created November 16, 2012 12:28
「見覚える」を茶漉で検索

茶漉

コーパス指定

  • 青空文庫(小説集)
  • 名大会話コーパス

検索パターン設定

スパン:

#!/usr/bin/env python
"""pre-commit-pep8.py
requirements
- pep8==1.3.3
in .git/hooks/pre-commit
#!/bin/sh
./path/to/this/script/in/your/repo/pre-commit-pep8.py
@ento
ento / gist:5234873
Last active December 15, 2015 08:59 — forked from drawks/gist:1556276
Enable _source compression in elasticsearch
curl -XPUT 'http://localhost:9200/_template/template_logstash/' -d '
{
"template": "logstash-*",
"mappings": {
"_default_": {
"_source": { "compress": "true" }
}
}
}'
@ento
ento / macosx_voices_demo.py
Created May 21, 2013 14:07
Mac OS X: Ask every voice found by `say -v "?"` to say the demo text. Note that `say` only returns voices for your system language.
# -*- coding: utf-8 -*-
"""
Ask every voice found by `say -v "?"` to say the demo text.
Note that `say` only returns voices for your system language.
"""
import time
from subprocess import Popen, PIPE
def say(voice, text):