Skip to content

Instantly share code, notes, and snippets.

View h0tw1r3's full-sized avatar
🏝️
Living the dream

Jeffrey Clark h0tw1r3

🏝️
Living the dream
View GitHub Profile
@KatelynHaworth
KatelynHaworth / notifyAddrChange.go
Created June 22, 2017 05:03
A simple go program leveraging the Window API to listen for IPv4 network address change events
package main
import (
"log"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
@cjthompson
cjthompson / RobustPDO.php
Created February 3, 2014 19:52
Extended PDO class that detects dropped connections and reconnects
<?php
class RobustPDO extends PDO
{
/** Call setAttribute to set the session wait_timeout value */
const ATTR_MYSQL_TIMEOUT = 100;
/** @var array */
protected $config = [];
/** @var bool For lazy connection tracking */
@ibqn
ibqn / mailserver-howto.md
Last active January 24, 2023 15:00
Email server based on Dovecot, Postfix, MySQL, Rspamd and Debian 9 Stretch

Email server based on Dovecot, Postfix, MySQL, Rspamd and Debian 9 Stretch

MySQL database setup

Install MariaDB as a database management system DBMS

sudo apt install mariadb-server

Create a new database named srvmail for a mail server:

@berlincount
berlincount / http-server.py
Last active December 20, 2022 21:22
Twisted HTTP server example
#!/usr/bin/env python
from twisted.web import server, resource
from twisted.internet import reactor, defer
from pprint import pprint
import base64
class DummyServer(resource.Resource):
isLeaf = True
@larsch
larsch / PrecompiledHeader.cmake
Last active March 12, 2022 10:49
cmake module for setting up precompiled headers (MSVC & GCC)
# Function for setting up precompiled headers. Usage:
#
# add_library/executable(target
# pchheader.c pchheader.cpp pchheader.h)
#
# add_precompiled_header(target pchheader.h
# [FORCEINCLUDE]
# [SOURCE_C pchheader.c]
# [SOURCE_CXX pchheader.cpp])
#
@aputs
aputs / replace-centos6x-iptables
Last active February 28, 2022 04:58
replace centos 6.x iptables
# compile iptables from source and install to /usr/local
mkdir -p /tmp/iptables
wget "http://www.netfilter.org/projects/iptables/files/iptables-1.4.21.tar.bz2" -qO- | tar --strip-components=1 -C /tmp/iptables -xvj
cd /tmp/iptables
./configure
make
make install
# set alternatives
sudo alternatives --install /sbin/iptables iptables.x86_64 /usr/local/sbin/iptables 100 \
@tnolet
tnolet / puppetdb_postgres_hacks.md
Last active May 13, 2021 01:32
PuppetDB is awesome. Here's some tips on accessing the data in the Postgresql database...most of 'm just reminders for myself.

NB: The following examples where done on Puppet Enterprise 3.0 running on Centos 6. Should be similar for open source versions, except for some file locations.

1. Logging into the PuppetDB PostgresQL database on Linux

The easiest way to snoop around in de actual PuppetDB postgres database is using the command prompt. You have to be the peadmin user though. Couldn't get it working just under root.

[root@master bin]# sudo su - pe-postgres -s /bin/bash
-bash-4.1$ /opt/puppet/bin/psql
psql (9.2.4)

Type "help" for help.

@mtourne
mtourne / nxg_request_time_var.c
Created December 3, 2012 20:31
Expose a $request_time in msec to Nginx core
/* inspired from ngx_http_log_module.c:ngx_http_log_request_time() */
static ngx_int_t
ngx_http_request_time(ngx_http_request_t *r,
ngx_http_variable_value_t *v,
uintptr_t data) {
ngx_time_t *tp;
ngx_msec_int_t ms;
tp = ngx_timeofday();
@f0ster
f0ster / slack_history.py
Last active November 8, 2019 01:25
slack history downloader (pub and priv) with rate limit retry :)
#https://gist.github.com/Chandler/fb7a070f52883849de35 SEE HERE
# MIT License
# Copyright (c) 2016 Chandler Abraham
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights