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
# 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/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
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
<?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
#!/bin/sh | |
pkg_base_path="/usr/local/bin/" | |
get_python_path () { | |
ls -1 "${pkg_base_path}" | grep -E '^python[0-9]{1}\.[0-9]{1}$' | |
} | |
pkg -N > /dev/null | |
st_code=$? |
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 | |
class a { | |
protected $hoge = 'foo'; | |
} | |
$a = new a(); | |
$closure = Closure::bind(function () { | |
$this->hoge = 'foofoo'; | |
}, $a, $a); | |
$closure(); |
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 | |
$file = new SplFileObject(__FILE__); | |
while (!$file->eof()) { | |
echo $file->current(); | |
$file->next(); | |
} | |
?> |
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
set ip=`ifconfig -l | awk '{print $1}' | xargs -L1 -I@ ifconfig @ inet | grep inet | awk '{print $2}' | head -n 1` | |
set prompt="%{\e[00;32;40m%}${ip}:%/%{\e[0m%} \n[freebsd]❯" |
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 | |
# nginx.conf の pid /path/nginx.pid; の調整は必要。 | |
args=${1:-""} | |
case "${args}" in | |
stop) | |
echo 'stop'; | |
;; | |
restart) |