Skip to content

Instantly share code, notes, and snippets.

# This is a quick and dirty script that emails an admin about any new IP addresses found in the auth.log.
# It includes the last 10 lines featuring a new IP along with output from ip-api.com.
# It saves identified IPs in a text file to prevent repeat reporting.
# Set this up to run as a cron job to be notified of any new networks authenticating on your Linux server.
import sys
import os
import subprocess
msg_filename = 'monitor_auth.msg'
@bagaag
bagaag / change_path.py
Last active September 24, 2024 23:01
Update file system paths in Navidrome's database
# This script changes the path for a folder or file in Navidrome's database, allowing music files to be
# moved or renamed on the file system without losing associated metadata in Navidrome. Since the original
# version, it has been updatd to account for the media_file IDs, which are calculated from the path value
# and referenced in several tables.
#
# This script is based on Navidrome version 0.49.2. If you are running an older version of Navidrom, it
# will likely fail. If you are running a newer version of Navidrome, your mileage may vary.
#
# It does NOT make any modifications to the file system - only to the Navidrome database.
#
create database <name>;
use <name>;
grant all on <name>.* to <user>@'%' idendified by '<password>'';
@bagaag
bagaag / .vimrc
Last active February 24, 2020 13:45
.vimrc
set number
set swapfile
set dir=c:/temp
colorscheme slate
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
@bagaag
bagaag / tic-tac-toe.html
Last active March 2, 2017 13:00
Single File Tic Tac Toe against the Computer
<!DOCTYPE html>
<!--
Single file Tic Tac Toe against the Computer
https://gist.github.com/wiseley/9458565/
Author: Matt Wiseley
License: GPL - http://www.gnu.org/licenses/gpl.html
-->
<html>
<head>
<meta charset="UTF-8">
@bagaag
bagaag / HitAggregator.java
Created January 29, 2014 02:52
Hit Aggregator Problem
/* PROBLEM:
* Write a class to support the following website feature. On each product
* detail page, display the number of hits in the past 10 minutes if there have
* been at least 10. Otherwise, display the number of hits in the past hour if
* there have been at least 10. Otherwise, display the number of hits in the
* past 24 hours if there have been at least 10. Otherwise, display nothing.
* There is no analytics service available to provide realtime reporting on the
* number of hits, so this class must also collect that data. It should aim to
* work on a website that has a few million product pages and gets 10 million
* unique visitors per day.
@bagaag
bagaag / palindrome.js
Last active March 2, 2017 15:55
Palindrome Test in JavaScript
// reverse word and compare
function isPalindrome1(word) {
var s = '';
for (var i=word.length-1; i>=0; i--) {
s += word[i];
}
return s === word;
}
// compare from end to end (more efficient)
@bagaag
bagaag / Statement.java
Last active December 22, 2015 01:08
Parameterized string for safe sql queries, read from a sql.properties file in the classpath.
/*
* Parameterized string for safe sql queries, read from a sql.properties file
* Use: Statement.create("property.name")
* .set(":id", 123)
* .set(":date", new Date())
* .set(":name","O'Hara")
* .toString();
*/
package com.wiseley.util;