This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
body { | |
color: #777; | |
} |
This file contains hidden or 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 | |
from django import forms | |
class PersonForm(forms.Form): | |
name = forms.CharField() | |
age = forms.IntegerField() | |
class AtLeastOneFormRequiredBaseFormSet(forms.formsets.BaseFormSet): |
This file contains hidden or 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 sys | |
data = """-**----*--***--***---*---****--**--****--**---**-- | |
*--*--**-----*----*-*--*-*----*-------*-*--*-*--*- | |
*--*---*---**---**--****-***--***----*---**---***- | |
*--*---*--*-------*----*----*-*--*--*---*--*----*- | |
-**---***-****-***-----*-***---**---*----**---**-- | |
--------------------------------------------------""" | |
big_digit_data = zip( |
This file contains hidden or 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 | |
class SampleException1(Exception): | |
message = "sample 1 exception" | |
class SampleException2(Exception): | |
message = "sample 2 exception" |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func main() { | |
// +Infinity |
This file contains hidden or 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 | |
import math | |
# +Infinity | |
positive_inf = float('inf') | |
# -Infinity | |
negative_inf = float('-inf') | |
# Nan | |
nan = float('nan') |
This file contains hidden or 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 distutils.version import StrictVersion | |
# バージョン番号の比較 | |
print StrictVersion("11.0.0") > StrictVersion("2.0.0") | |
# => True | |
# バージョン番号のソート | |
tests = [ | |
"1.0", |
This file contains hidden or 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 | |
from django import forms | |
from django.template.defaultfilters import striptags | |
class PersonForm(forms.Form): | |
name = forms.CharField() | |
age = forms.IntegerField() | |
def errors_as_dict(self): |
This file contains hidden or 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 | |
import os | |
import tempfile | |
import shutil | |
from django.test import TestCase, override_settings | |
TEST_MEDIA_ROOT = tempfile.mkdtemp() |
This file contains hidden or 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 | |
import base64 | |
def convert_file_to_b64_string(file_path): | |
"""ファイルをbase64にエンコードする | |
""" | |
with open(file_path, "rb") as f: | |
return base64.b64encode(f.read()) |
NewerOlder