Skip to content

Instantly share code, notes, and snippets.

View syakesaba's full-sized avatar
🍙
ごはんください

SYA-KE syakesaba

🍙
ごはんください
View GitHub Profile
print "Hello world"
def _callback_uri_for(self, provider):
if (provider in secrets.AUTH_CONFIG.keys()):
if provider == "google":
return "https://paper-mobile.appspot.com/auth/google/callback"
return self.uri_for('main', provider=provider, _full=True)
{# ヘッダを情報バーにする。 #}
<div data-role="header" data-id="header_withLogin" data-position="fixed" id="{{page_name}}_header_withLogin">
<h1>{{title}}</h1>
<img id="{{page_name}}_user_settings_button" class="ui-btn-left" alt="{{user.name}}の{{user.auth_provider}}の画像" src="{{user.avatar_url}}" width="32px" height="32px">
<a href="#{{page_name}}_settings_popup" data-rel="popup" data-inline="true" class="ui-btn ui-shadow ui-btn-right">設定</a>
</div>
{# 上のボタンをクリックしたら開くメニューパネル。 #}
<div id="{{page_name}}_settings_popup" data-transition="pop" data-role="popup" class="ui-content" style="min-width:210px;">
<div data-role="collapsible-set">
<div data-role="collapsible">
webapp2.Route('/auth/<provider>', handler='controllers.AuthHandler:_simple_auth', name='auth_login'),
uri_for('auth_login',None,provider='twitter') == "/auth/twitter"
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
@syakesaba
syakesaba / gist:3f9f840911c859f1ce4f
Created August 12, 2014 14:50
ndb.Modelでプロパテぃが全てSerializableな時のmemcache。
@classmethod
def get_cached_univs_info(cls):
"""
returns cached universities infomation.
@return: dict universities. all ["univ_name"]["key"] are defined but value can be None.
@rtype: dict
"""
univs_info = memcache.get("univs_info") # @UndefinedVariable
if univs_info is None:
@syakesaba
syakesaba / ExHandler
Created August 12, 2014 14:57
jinja2にJSP以上の機能を持たせるRequestHandler、template_nameに基づくHTMLキャッシュ機能
class BaseRequestHandler(webapp2.RequestHandler):
def dispatch(self):
# Get a session store for this request.
self.session_store = sessions.get_store(request=self.request)
try:
# Dispatch the request.
webapp2.RequestHandler.dispatch(self)
except Exception as e:
logging.info(e)
691 class PcapWriter(RawPcapWriter):
692 def _write_header(self, pkt):
693 if self.linktype == None:
694 if type(pkt) is list or type(pkt) is tuple or isinstance(pkt,Bas
695 pkt = pkt[0]
696 try:
697 self.linktype = conf.l2types[pkt.__class__]
698 except KeyError:
699 warning("PcapWriter: unknown LL type for %s. Using type 1 (E
700 self.linktype = 1
@syakesaba
syakesaba / scapy DNSQR is ????
Created September 13, 2014 14:04
scapy DNSQR can't be serialize
>>> PacketList(a).jsondump("1")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Python/2.7/site-packages/scapy/modules/serialize.py", line 24, in dump_packet_as_json
json.dump(s, file(filename,"wb"),ensure_ascii=False)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 189, in dump
for chunk in iterable:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 431, in _iterencode
for chunk in _iterencode_list(o, _current_indent_level):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 332, in _iterencode_list
@syakesaba
syakesaba / dnet1.12.c.pypy.patch
Created September 21, 2014 01:27
dnet1.12.c.pypy.patch
24,29d23
< typedef struct {
< PyObject_HEAD
< PyClassObject *in_class; /* The class object */
< PyObject *in_dict; /* A dictionary */
< PyObject *in_weakreflist; /* List of weak references */
< } PyInstanceObject;