Skip to content

Instantly share code, notes, and snippets.

@cemtopkaya
cemtopkaya / Dockerfile.debrepo
Last active March 30, 2025 17:33 — forked from awesomebytes/simple_debian_repository.md
How to create a simple debian repository with minimal dependences
# docker build -t my-debrepo -f Dockerfile.deb .
# Bulunduğu dizinde latest ve packages adından iki dizin oluşturulur.
# latest en güncel paketim tutulduğu dizin jenkins tarafımndan otomatik kullanılacaktır.
# packages ise tüm deb paketlerinin tutulduğu dizin.
# docker run --privileged -dit --name debrepo -p 8080:80 -v $(pwd)/latest:/usr/local/apache2/htdocs/latest/debs/amd64 -v $(pwd)/packages:/usr/local/apache2/htdocs/debs/amd64 -v "$(pwd)"/httpd.conf:/usr/local/apache2/httpdconf my-debrepo
# docker exec -it debianrepo nohup bash -c "/usr/local/apache2/htdocs/updaterepo.sh &" && sleep 4 ile repo'yu otomatik scan edecek script çalıştırılır.
FROM httpd:2.4
RUN echo "root:root" | chpasswd
RUN apt-get update && \
@dorneanu
dorneanu / plugin_architecture.md
Last active April 9, 2025 16:18
Python: Implement basic plugin architecture with Python and importlib

Implementing a basic plugin architecture shouldn't be a complicated task. The solution described here is working but you still have to import every plugin (inheriting from the base class).

This is my solution:

Basic project structure

$ tree
@prziborowski
prziborowski / gist:ba3ebf610dd6cca3f4e7be5e2874499f
Last active November 15, 2024 02:10
Use property collector to retrieve names quickly
#!/usr/bin/env python
"""
Written by Nathan Prziborowski
Github: https://github.com/prziborowski
This code is released under the terms of the Apache 2
http://www.apache.org/licenses/LICENSE-2.0.html
The property collector can be used to fetch a subset of properties
for a large amount of objects with fewer round trips that iterating.
This sample shows how to use the TraversalSpec to get properties
of another object without multiple calls.
@dgeo
dgeo / surveille-spam.pl
Last active January 13, 2025 15:13
parse postfix maillog to detect hacked accounts
#!/usr/bin/env perl
#
# surveilleur de logins sasl: compte les IP's de provenance d'un meme login
#
# needs geoip2 perl module and GeoLite2-Country.mmdb (use geoipupdate)
#
# run by cron on a daily-rotated maillog:
# 2 */1 * * * root /usr/local/admin/ssi/surveille-spam.pl /data/logs/serveurs/maillog
# 1 0 * * * root /usr/local/admin/ssi/surveille-spam.pl /data/logs/serveurs/maillog.0
use strict;
@JimWestergren
JimWestergren / checkPawnedPasswords.php
Last active December 22, 2023 23:06
Simple method to check the Pwned Passwords API using PHP
<?php
/**
* Simple method to use the API from https://www.troyhunt.com/ive-just-launched-pwned-passwords-version-2/
* Written by Jim Westergren and released to public domain
* @return int count
*/
function checkPawnedPasswords(string $password) : int
{
$sha1 = strtoupper(sha1($password));
$data = file_get_contents('https://api.pwnedpasswords.com/range/'.substr($sha1, 0, 5));
@mino98
mino98 / checkpass.sh
Last active March 14, 2018 23:07
Check password against pwnedpasswords repo.
#!/bin/bash
# Original:
# https://blog.cloudflare.com/validating-leaked-passwords-with-k-anonymity
echo -n Password:
read -s password
echo
hash="$(echo -n $password | openssl dgst -sha1 -binary | xxd -p)"
upperCase="$(echo $hash | tr '[a-z]' '[A-Z]')"
@posener
posener / go-shebang-story.md
Last active March 15, 2025 16:08
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@awesomebytes
awesomebytes / simple_debian_repository.md
Last active April 8, 2025 17:25
How to create a simple debian repository with minimal dependences

Simple debian repository

How to have a simple debian repository to offer your packages.

Requirements

You probably have them already installed

  • Python (I used 2.7).
  • dpkg-scanpackages: sudo apt-get install dpkg-dev
  • gzip: sudo apt-get install gzip
@malobre
malobre / ts3-afk-bot.sh
Created September 17, 2016 22:38
Teamspeak 3 AFK bot, move clients to the specified channel when they are muted for more than the specified period of time and move them back when they unmute themself.
#!/bin/bash
#
# ts3server-bot.sh
#
# Teamspeak 3 AFK bot, move clients to the specified channel when they are muted
# for more than the specified period of time and move them back when they unmute
# themself.
#
# Copyright 2016, Malobre.
#
@markllama
markllama / schema2ldif.sh
Last active April 12, 2023 14:47
Convert LDAP Schema to LDIF
#!/bin/bash
#
# Stolen from https://stuckinadoloop.wordpress.com/2011/04/14/script-to-convert-openldap-schema-files-to-ldif-format/
SCHEMAD=/etc/openldap/schema
SCHEMAS='dhcp.schema'
tmpd=`mktemp -d`
pushd ${tmpd} >>/dev/null