Skip to content

Instantly share code, notes, and snippets.

View peketamin's full-sized avatar
🐔
Hello world!

Yuki Yokoyama peketamin

🐔
Hello world!
View GitHub Profile
@peketamin
peketamin / GLSL_Noise_Algorithm_in_Python.md
Last active November 6, 2023 13:33
"10年程前からビデオゲーム開発者の間で語り継がれている謎の一様乱数生成アルゴリズム" を Python で実装 (自信なし)

"10年程前からビデオゲーム開発者の間で語り継がれている謎の一様乱数生成アルゴリズム" を Python で実装 (自信なし)

元ネタ

@peketamin
peketamin / mono_repo.rst
Created April 8, 2019 04:25
モノリシックレポジトリ (単一レポ運用) についてリンク集

Keybase proof

I hereby claim:

  • I am peketamin on github.
  • I am peketamin (https://keybase.io/peketamin) on keybase.
  • I have a public key ASAjWnO2sh4WV9znCF2rDgm5gIDtZAYK8_vOjePQgIQEyAo

To claim this, I am signing this object:

@peketamin
peketamin / django_orm_when_case_f_example.py
Created January 24, 2018 03:54
Django ORM: When, Case, F (keyword: zero division error)
from django.db.models import F, Case, When, FloatField
from myapp import models
md = models.MyModel.objects.filter(pk=3).annotate(pr=Case(When(price__gte=40., then=F('price') * 10), default=F('price') / 10, output_fields=FloatField())).first()
In [27]: md.price
Out[27]: 40.7424047560126
In [29]: md.pr
Out[29]: 407.424047560126
@peketamin
peketamin / HBLT.js
Last active May 13, 2021 11:59
ブラウザ版はてブのホッテントリリストのタイトル省略を展開するブックマークレット (説明: https://peketamin.hatenablog.jp/entry/2021/05/12/221554)
class HatebuLongTitler {
constructor () {
HatebuLongTitler.makeStyle();
HatebuLongTitler.applyStyle();
}
static makeStyle() {
const newRule = `
.style-headline:not(.search-url-nothing) .entrylist-main .entrylist-contents-title {
white-space: none!important;
@peketamin
peketamin / PCHBCS.js
Last active May 13, 2021 11:58
ブラウザ版はてブのお気に入りユーザーのコメントを一括表示するブックマークレット (説明: https://peketamin.hatenablog.jp/entry/2021/05/12/221554)
if(typeof(String.prototype.trim) === "undefined")
{
String.prototype.trim = function()
{
return String(this).replace(/^\s+|\s+$/g, '');
};
}
class PCHateBuCommentStyle {
@peketamin
peketamin / frame_example.java
Created October 15, 2020 04:48
frame_example.java
import java.awt.*;
import java.awt.event.*;
public class Rei26 extends Frame {
private int oldx = 0, oldy = 0;
public Rei26() {
setSize(400, 300);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
@peketamin
peketamin / cat.go
Last active July 24, 2020 13:06
go benchmark test
package cat
import (
"bytes"
)
func buf(ss []string) string {
var b bytes.Buffer
for _, s := range ss {
b.WriteString(s)
@peketamin
peketamin / django_phone_jp.py
Created May 21, 2020 06:03
Django: phone number (JP)
from django.core.validators import ValidationError # type: ignore[attr-defined]
from django.core.validators import RegexValidator
## validators.py
phone_number_validator = RegexValidator(
regex=r"^[0-9-()+ ]{9,20}$", message="入力可能文字は半角の、数字、ハイフン、括弧のみ. 9文字以上, 20文字以下."
)
## models.py
@peketamin
peketamin / admin.py
Last active May 3, 2020 11:04
Django: Create ImageField thumbnail
from pathlib import PosixPath
from django import forms
from django.conf import settings
from django.contrib import admin
from my_app.models import Item
class ItemForm(forms.ModelForm):