This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#tagid").text("here is new text for the tag"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#tagid").click(function(){ | |
var someAttr = $(this).attr("data-hoge-fuga"); | |
// do something | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import simplejson | |
import re | |
import pprint | |
import iso8601 | |
__all__ = ('FluentLogS3', 'parse_fluent_log_line') | |
_parse_pat = re.compile(r'\A(\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d[\-+]\d\d:\d\d)\s+([^\s]+)\s+(.*)\n\Z') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
Vagrant.configure("2") do |config| | |
config.vm.hostname = "digital-ocean-test" | |
config.ssh.private_key_path = "~/.ssh/id_rsa" | |
config.vm.box = "digital_ocean" | |
config.vm.provider :digital_ocean do |provider| | |
provider.client_id = "YOUR CLIENT ID" | |
provider.api_key = "YOUR API KEY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pprint | |
print '----try not append----' | |
a = [] | |
print 'object id of variable \'a\' => %d' % id(a) | |
print 'content of variable \'a\': %s' % pprint.pformat(a) | |
a = a + [1] | |
print 'added value 1 with + operator' | |
print 'object id of variable \'a\' has changed: %d' % id(a) | |
print 'content of variable \'a\': %s' % pprint.pformat(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import gevent | |
from gevent.event import AsyncResult | |
from gevent.queue import Queue | |
__all__ = ('GExecutorNotRunningError', 'GExecutor') | |
class GExecutorNotRunningError(Exception): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyramid.i18n import make_localizer, TranslationString | |
dir = '/your/locale/dir' | |
directories = (dir,) | |
txt_want_to_translate = TranslationString('hoge_moge') | |
# txt_want_to_translate = TranslationString('hoge_moge', domain='some_domain') | |
locale = 'ja' | |
localizer = make_localizer(locale, directories) | |
transltaed_str = localizer.translate(txt_want_to_translate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
#from bs4 import BeautifulSoup | |
#soup = BeautifulSoup(some_html_string) | |
def get_string_by_id(soup, _tag, _id): | |
tag = soup.find(_tag, id=_id) | |
return tag.string if tag is not None else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from nose.tools import eq_ | |
import markupsafe | |
jinja_escape = lambda s: '%s' % markupsafe.escape(s) | |
# note: lambda s: str(markupsafe.escape(s)) doesn't work in some cases | |
scraped_string = soup.find('p', id='important').string # should be escaped by jinja2 escape filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import time | |
import math | |
__all__ = ('MongoCounterError', 'MongoCounter') | |
class MongoCounterError(Exception): | |
pass |