Skip to content

Instantly share code, notes, and snippets.

View nicka101's full-sized avatar

Nick Anstee nicka101

  • Anstee Development
  • Norway
View GitHub Profile
@nicka101
nicka101 / socket-constant-rebind.cpp
Last active August 29, 2015 14:23
Test ephemeral port allocation for routed connections
#include <string>
#include <iostream>
#ifdef _WIN32
#include <WS2tcpip.h>
#define LAST_ERR WSAGetLastError()
#define SOCK_INVALID(s) s == INVALID_SOCKET
#else
#define LAST_ERR errno
#define SOCK_INVALID(s) s < 0
#include <sys/socket.h>
@nicka101
nicka101 / nginx
Created June 16, 2015 09:24
Nginx init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@nicka101
nicka101 / table_dependents.sql
Last active August 29, 2015 14:08
Return a list of tables which depend on the specified table
CREATE PROCEDURE table_dependents
(
IN tbl_name varchar(255)
)
BEGIN
CREATE TEMPORARY TABLE tbl_dependents_processing(
table_name varchar(255) PRIMARY KEY NOT NULL
)ENGINE=MEMORY;
INSERT INTO tbl_dependents_processing SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME = tbl_name;