Skip to content

Instantly share code, notes, and snippets.

@caot
caot / workaround-podman-issue19913.sh
Created March 7, 2024 15:33 — forked from rugk/workaround-podman-issue19913.sh
Workaround script for podman rm (--force) does not work anymore ("container state improper"/"invalid argument" when unmounting) and start neither, see https://github.com/containers/podman/issues/19913
#!/bin/bash
#set -x
# Define the list of containers you want to remove
containers=("nextcloud_redis_1" "nextcloud_db_1" "nextcloud_nc_1")
for container in "${containers[@]}"; do
echo "Now handling $container..."
# First attempt to forcefully remove the container
podman rm --force "$container"
@caot
caot / django_error_test_database_1005.md
Created September 19, 2023 20:10 — forked from rminderhoud/django_error_test_database_1005.md
Fix mysql error 1005 when running django tests

#Django Test Database Error 1005 8/1/2015

Environment

  • Django 1.8.3
  • MySQL 5.5

When running python manage.py test I was receiving the following error

@caot
caot / LoginRequiredMiddleware.py
Created May 12, 2023 13:26 — forked from brianlittmann/LoginRequiredMiddleware.py
Django middleware component that wraps the login_required decorator around all URL patterns be default, with exceptions. Can also require user to belong to a group ("admin" in this gist) or be adapted if using the Django admin app.
"""
Middleware component that wraps the login_required decorator around all URL patterns be default, with exceptions.
Define PUBLIC_URLS and ADMIN_URLS using regex in settings.py, where:
PUBLIC_URLS do not require user to be logged in.
ADMIN_URLS require user to be in admin group.
Source: http://stackoverflow.com/a/2164224/720054
"""
# settings.py
PUBLIC_URLS = (
@caot
caot / decode_shadowpad_dns.py
Created April 18, 2023 15:42 — forked from fox-srt/decode_shadowpad_dns.py
Netsarang backdoor DNS payload decrypter
#!/usr/bin/env python
"""
Netsarang backdoor DNS payload decrypter
file: decode_shadowpad_dns.py
author: Fox-IT Security Research Team <srt@fox-it.com>
Usage:
$ cat dns.txt
sajajlyoogrmkllmuoqiyaxlymwlvajdkouhkdyiyolamdjivho.cjpybuhwnjgkhllm.nylalobghyhirgh.com
@caot
caot / detect-zoom.js
Created March 10, 2023 19:07 — forked from abilogos/detect-zoom.js
Getting browser Zoom level
//for zoom detection
px_ratio = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth;
$(window).resize(function(){isZooming();});
function isZooming(){
var newPx_ratio = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth;
if(newPx_ratio != px_ratio){
px_ratio = newPx_ratio;
console.log("zooming");
function birthday(s, d, m) {
let result = 0;
for(let i = 0; i < s.length - (m - 1); i++) {
if (s.slice(i, i + m).reduce((r, v) => r + v, 0) === d) {
result++;
}
}
return result;
}
@caot
caot / ignore-line-endings
Created December 5, 2021 03:01 — forked from robert-claypool/ignore-line-endings
Ignore Line Endings with Git Merge
git config merge.renormalize true # prevents unnecessary merge conflicts, http://stackoverflow.com/a/12194759/23566
@caot
caot / Set up GitHub push with SSH keys.md
Created August 23, 2021 19:11 — forked from xirixiz/Set up GitHub push with SSH keys.md
Set up GitHub push with SSH keys

SSH keypair setup for GitHub (or GitHub/GitLab/BitBucket, etc, etc)

Create a repo.

Make sure there is at least one file in it (even just the README.md)

Generate a SSH key pair (private/public):

ssh-keygen -t rsa -C "your_email@example.com"
Serial Keys:
FU512-2DG1H-M85QZ-U7Z5T-PY8ZD
CU3MA-2LG1N-48EGQ-9GNGZ-QG0UD
GV7N2-DQZ00-4897Y-27ZNX-NV0TD
YZ718-4REEQ-08DHQ-JNYQC-ZQRD0
GZ3N0-6CX0L-H80UP-FPM59-NKAD4
YY31H-6EYEJ-480VZ-VXXZC-QF2E0
ZG51K-25FE1-H81ZP-95XGT-WV2C0
VG30H-2AX11-H88FQ-CQXGZ-M6AY4
@caot
caot / Hasher.java
Created July 29, 2020 18:12 — forked from lukaszb/Hasher.java
Java implementation of Django PasswordHasher
/* Example implementation of password hasher similar to Django's PasswordHasher
* Requires Java8 (but should be easy to port to older JREs)
* Currently it would work only for pbkdf2_sha256 algorithm
*
* Django code: https://github.com/django/django/blob/1.6.5/django/contrib/auth/hashers.py#L221
*/
import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;