This file contains 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
""" | |
1. install openai and memory_profiler | |
2. Add following to class Completions(SyncAPIResource): | |
def forceClose(self): | |
self.with_raw_response = None | |
3. Add following to class class OpenAI(SyncAPIClient): |
This file contains 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 os | |
import re | |
import shutil | |
from datetime import datetime | |
from pathlib import Path | |
from PIL import Image | |
import argparse | |
import logging |
This file contains 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 | |
# This script will cleanup docker registry images, that are older than 7 days (see REMOVE_OLDER_THAN_DAYS). | |
# Note: This will only work on v2 registry. | |
# Before running make sure you have: | |
# 1. Installed requirements by running `python3 -m pip install -r requirements.txt` | |
# 2. Put registry password in `.registry-password` file | |
# 3. Updated correct values in `Constants` section | |
# Then run `python3 cleanup.py` or `chmod +x cleanup.py && ./cleanup.py` | |
# After cleaning registry, run garbage collector on registry, for example: `docker compose exec registry sh -c "/bin/registry garbage-collect --delete-untagged /etc/docker/registry/config.yml"` |
This file contains 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 | |
# | |
# Make sure you have screen installed (on debian). On Arch linux no screen is required. | |
# Debian: | |
# apt-get install screen | |
# | |
# Monit example: | |
# check process ssh-tunnel matching "^ssh -N sshtunnel" | |
# user root | |
# start program = "/root/ssh_tunnel.sh" |
This file contains 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 | |
## Unifi NVR + letsencrypt certificate | |
# Remember to use fullchain.pem | |
# Thanks: https://www.john.geek.nz/2018/05/using-letsencrypt-with-ubiquiti-unifi-video-server/ | |
# | |
# Also remember adding `ufv.custom.certs.enable=true` to the `/usr/lib/unifi-video/data/system.properties` file | |
# | |
HOSTNAME=XXX.gm.lv |
This file contains 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
// jQuery addons | |
// Serialize form fields recursively into json type object, | |
// so for example <input type="text" name="record[type][x]" value="1"> becomes {type: {x: 1}} | |
var | |
rbracket = /\[\]$/, | |
rarrayKeys = /\[(.*?)\]/g, | |
rarrayKeysPrefix = /^(.*?)\[.*/g, | |
rCRLF = /\r?\n/g, | |
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, |
This file contains 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
CREATE OR REPLACE FUNCTION jsonb_array_search(json_arr jsonb, col TEXT, search_for TEXT) RETURNS boolean | |
LANGUAGE plpgsql IMMUTABLE AS $$ | |
DECLARE | |
rec jsonb; | |
len int; | |
ret boolean = false; | |
BEGIN | |
-- If json_arr is not an array, return false | |
BEGIN | |
len := jsonb_array_length(json_arr); |
This file contains 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 | |
# Little library for email and sms (using SMSEagle - http://www.smseagle.eu/) notifications. | |
# Can be used as a command line or library. | |
# For this to work please set SMTP and SMSEAGLE parameters | |
import argparse | |
import smtplib | |
import json | |
from email.mime.text import MIMEText |
This file contains 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 | |
/** | |
* Returns fixed floating number with precision of $precision. Replaces "," to "." and " " to "". | |
* | |
* @param $input mixed | |
* @param $precision int | |
* @return float | |
*/ | |
function fixFloat($input, $precision = -1) |
This file contains 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 | |
const SESSION_EXPIRATION_TIME = 100; // Seconds | |
function session_expire() | |
{ | |
if (empty($_SESSION['last_visit'])) { | |
$_SESSION['last_visit'] = time(); | |
} | |
if ($_SESSION['last_visit'] + SESSION_EXPIRATION_TIME < time()) { |
NewerOlder