Skip to content

Instantly share code, notes, and snippets.

@mattia-beta
mattia-beta / ddos.conf
Last active May 5, 2025 08:22
IPtables DDoS Protection for VPS
### 1: Drop invalid packets ###
/sbin/iptables -t mangle -A PREROUTING -m conntrack --ctstate INVALID -j DROP
### 2: Drop TCP packets that are new and are not SYN ###
/sbin/iptables -t mangle -A PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP
### 3: Drop SYN packets with suspicious MSS value ###
/sbin/iptables -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP
### 4: Block packets with bogus TCP flags ###
int[] lines = new int[10];
int counter = 0;
float startTime, currTime;
float hitTime;
float bpm = 170;
PShape bassDrum;
@bennylope
bennylope / ffmpeg-watermark.md
Created April 22, 2016 23:17 — forked from webkader/ffmpeg-watermark.md
FFmpeg add a watermark to video

How to Add a Watermark to Video

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i test.mp4 -i watermark.png -filter_complex "overlay=10:10" test1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as test1.mp4.

@cgmartin
cgmartin / check-certs.sh
Created January 17, 2016 18:00
Bash SSL Certificate Expiration Check
#!/bin/bash
TARGET="mysite.example.net";
RECIPIENT="[email protected]";
DAYS=7;
echo "checking if $TARGET expires in less than $DAYS days";
expirationdate=$(date -d "$(: | openssl s_client -connect $TARGET:443 -servername $TARGET 2>/dev/null \
| openssl x509 -text \
| grep 'Not After' \
|awk '{print $4,$5,$7}')" '+%s');
in7days=$(($(date +%s) + (86400*$DAYS)));
@kkAyataka
kkAyataka / datetime_to_string_to.py
Last active June 14, 2022 16:13
Python datetime to iso format string and iso format string to datetime
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""datetimeとISO 8601文字列の変換"""
import datetime
# datetimeからISO 8601を得る
d = datetime.datetime(2014, 11, 11, 9)
print d.isoformat() # 2014-11-11T09:00:00
@yendor
yendor / ParallelTask.php
Created November 14, 2011 05:54
Base class for doing forked, parallel execution in PHP easily
<?php
class ParallelTask
{
protected $pid = null;
public $max_workers = 8;
protected $num_workers = 0;
public function run()