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
<?php | |
# shell | |
# $ printf '\xF0\x9D\x95\x92' | |
# $ printf "𝕒"| hexdump | |
# f09d9592 𝕀 | |
$start = 4036859264; | |
$end = 4036859281; | |
for ($i=$start; $i<$end; $i++) { | |
$hex = escape(dechex($i)); |
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 django.contrib import admin | |
""" | |
admin側ではproxyなどを使うと __str__ がうまく継承されない。 | |
単純に継承したほうがいいかも。 | |
""" | |
@admin.register(parendeModel) | |
class parentAdmin(admin.ModelAdmin): | |
pass |
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
// ref: https://docs.djangoproject.com/en/2.2/ref/csrf/#ajax | |
// 下記の関数のソースは上記の公式ドキュメントを参考 | |
var csrftoken = Cookies.get('csrftoken'); | |
$.ajaxSetup({ | |
headers: { | |
'X-CSRFToken': csrftoken | |
} | |
}); |
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
# ref: https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/#overriding-the-default-fields | |
from django import forms | |
class fooForm(forms.ModelForm): | |
class Meta: | |
model = foo | |
fields = ('name',) | |
labels = { | |
'name': 'なまえ', | |
} |
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
# ref: https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_per_page | |
from django.contrib import admin | |
class fooAdmin(admin.ModelAdmin): | |
# リスト表示で最大何件表示するか | |
list_per_page = 1 |
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
<?php | |
for ($i=0; $i<256; $i++) { | |
$hex = sprintf('%02s', dechex($i)); | |
$bin = pack('H*', $hex); | |
echo '0x'.$hex . ' ' . md5($bin) . PHP_EOL; | |
} | |
?> |
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
php main.php | |
ec824fb844e4df008219d4c1af2a7673eff8a762aac7acef5104e021ee39c498a9389620571cb9e77627ec6a03e8d72b5930abc65d2a7c3265676897aa46bbc7 | |
python main.py | |
ec824fb844e4df008219d4c1af2a7673eff8a762aac7acef5104e021ee39c498a9389620571cb9e77627ec6a03e8d72b5930abc65d2a7c3265676897aa46bbc7 |
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
#!/bin/sh | |
prefix="__" | |
usage_error () | |
{ | |
echo "$0: $*" >&2 | |
print_usage >&2 | |
exit 2 | |
} |
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
$ php -r "echo hash('sha256','test');" | |
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 | |
$ printf 'test' | openssl sha256 | |
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 | |
$ python --version | |
Python 3.6.0 | |
$ python -c 'import hashlib; print(hashlib.sha256(b"test").hexdigest())' | |
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 |
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
#!/bin/sh | |
cat <<-EOF | xargs -L1 -P4 sh -c | |
'sleep 3; echo "sleep3 end"' | |
'sleep 4; echo "sleep4 end"' | |
'sleep 2; echo "sleep2 end"' | |
'sleep 1; echo "sleep1 end"' | |
EOF |