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/bash | |
| # uses surekillpid: https://gist.github.com/tubaman/377458a11fedb49cc2132ea6e31ae8b2 | |
| pgrep $@ | grep -v $$ | xargs --no-run-if-empty surekillpid |
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 urllib.request import urlopen | |
| from django.conf import settings | |
| from django.template import Origin, TemplateDoesNotExist | |
| from django.template.loaders.base import Loader as BaseLoader | |
| from django.utils.module_loading import import_string | |
| class Loader(BaseLoader): |
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.template.loaders.cached import Loader as CachedLoader | |
| from django.conf import settings | |
| from .cacheddict import CachedDict | |
| class Loader(CachedLoader): | |
| """A cached template loader where the templates expire after self.timeout | |
| seconds. |
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
| import time | |
| class CachedDict(object): | |
| """A dictionary where the items timeout after self.timeout seconds | |
| We've implemented just enough of a real dictionary to work as a | |
| replacement for the dicts in django.template.loader.cached.Loader | |
| """ |
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
| if [ "$interface" = eth1 ]; then | |
| if [ "$if_up" = true ]; then | |
| IP=`ip add show eth1|grep global |awk '{print $2}'` | |
| PREVIOUS_IP=`cat /tmp/previous_ip` | |
| if [ "$PREVIOUS_IP" != "$IP" ]; then | |
| echo "$IP" > /tmp/previous_ip | |
| systemctl restart shorewall.service | |
| fi | |
| fi | |
| fi |
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
| import sys | |
| import os,re,telnetlib,time | |
| class SlowTelnet(telnetlib.Telnet): | |
| """Spoon feed slow telnet servers""" | |
| def __init__(self, *args, delay=0.2, **kwargs): | |
| super().__init__(*args, **kwargs) | |
| self.delay = delay |
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.db import models | |
| from django.db.models import Count, ExpressionWrapper, F, Case, When | |
| from django.utils import timezone | |
| class PersonQuerySet(models.QuerySet): | |
| def with_age(self): | |
| now = timezone.now() | |
| age_expr = ExpressionWrapper( |
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
| import logging | |
| from decimal import Decimal | |
| from django import db | |
| from django.db.models import DecimalField as DjangoDecimalField | |
| logger = logging.getLogger(__name__) | |
| #logger.setLevel(logging.DEBUG) | |
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
| #!/usr/bin/env python3 | |
| """Print out all the chatgpt responses in a conversation | |
| Use the devtools in your browser to download the json file from: | |
| https://chat.openai.com/backend-api/conversation/nnnnnnnnnnnnnn | |
| """ | |
| import sys | |
| import json |
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
| #!/usr/bin/env python3 | |
| import sys | |
| import argparse | |
| import json | |
| from urllib.parse import quote | |
| def main(argv=None): | |
| if argv is None: | |
| argv = sys.argv |