Skip to content

Instantly share code, notes, and snippets.

@jeruyyap
jeruyyap / django_timestamp_fields.py
Last active January 24, 2018 15:36
Django "Last Modified" and "Created" timestamps as custom field types.
"""
This is a simple implementation of "last modified" and "created" timestamps custom field types for Django.
I used this in a few projects due to talk of deprecating "auto_now" and "auto_now_add" for DateTime fields.
It doesn't seem as necessary now that said options appear to be staying in Django.
That said, I figured I might as well have this snippet just in case.
"""
from django.db import models
from django.utils import timezone
@jeruyyap
jeruyyap / .vimrc
Last active August 25, 2016 13:29
My .vimrc file
" set basic vim options and colorscheme
set number
set showcmd
syntax on
colorscheme torte
" disable viminfo file
set viminfo=
" replace tabs with 4 spaces
@jeruyyap
jeruyyap / GPG_Conf
Created June 7, 2016 20:26
GPG Conf Settings
# Copy and paste this into gpg.conf file
# Hash and Cipher preferences
personal-digest-preferences SHA512 SHA384 SHA256 SHA224
personal-cipher-preferences AES256 AES192 AES CAST5
cert-digest-algo SHA512
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
@jeruyyap
jeruyyap / keybase.md
Created March 24, 2016 00:05
keybase.md

Keybase proof

I hereby claim:

  • I am jeruyyap on github.
  • I am jeruyyap (https://keybase.io/jeruyyap) on keybase.
  • I have a public key whose fingerprint is 088B 25D0 06FC 0A1F 3D0E E5B5 2F0F 3437 4B1F D063

To claim this, I am signing this object:

@jeruyyap
jeruyyap / Jeremy_Yap_Key
Last active February 23, 2024 06:17
Jeremy Yap's GnuPG Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFbspJIBEACwARxTv3kt31IfgznLWt/A+BdwAIJDfsgDb4zBhcxv9BAVq1zh
eRMcFlRbm8qsM75BZyf+5C0aO01XRGcmmfakb3CI2VVqyiLt8dYFIvUF5ly0wupJ
JH6Kt/HYgQCf2EyAJgp2vHAgySqsxOEO+oiMGzzd9Ciwj2kaz9nOFwG/0GROMRQf
vB4QkkOYxZKV5PLrftmcOgkX5+gQs8OmIMYzfouhSmlJSactM9e6ukOokifwdfBA
dIVZWlFQ6OUAbXquUA+roQiYWvGnyUnAB/nfkX0iZhmK7GG9kEh0p4BS5Kar+edn
5Z1XOiKUOkh72MXe9zrh3A+Tn1hmgN5bhAqNSVGGGyUswy/BceFS3Ukg7yp73kQ9
JI5iImjuxqLQ5vGtISLApk6vLLelxKub26IznJNx9iatBVM/XjULzDcD32BxW4YS
T/MCx0oaB7dA0X+9lhJJ05NgwNIDcnINexSZN14Y8acuIpx1h3trK/IKdaDeQy1Y
@jeruyyap
jeruyyap / Matching Rijndael-128 in C#.NET, PHP, and Python
Last active March 18, 2024 07:05
Matching Encrypt/Decrypt Methods With Rijndael-128, CBC Mode, PKCS7 Padding in C#.NET, PHP, And Python
DO NOT use these as-is for anything important!
These are only very basic examples and they are missing much of what would be needed for a real-world use case.
These are snippets for matching encrypt and decrypt (Rijndael-128 in CBC mode with PKCS7 padding) in C#.NET, PHP, and Python.
I cobbled these together from various existing examples because at the time it seemed like a lot of existing examples out there for different languages/platforms did not quite match and would require quite a bit more work before they would encrypt/decrypt identically.
Each of these take Keys and IVs that are 16 character strings encoded in base64.