Skip to content

Instantly share code, notes, and snippets.

/*!
* jQuery Tiny Pub/Sub - v0.X - 11/18/2010
* http://benalman.com/
*
* Original Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Made awesome by Rick Waldron
*
@antonlindstrom
antonlindstrom / dnscheck
Created July 22, 2011 10:13
keepalived for DNS
#!/bin/bash
#$Id: keepalivepin,v 1.2 2006/02/27 07:30:41 hmy Exp hmy $
#use dig check the powerdns's status.
#in the dns database,have a IN TXT RR keepalivepin.vmmatrix.net,content is "AaBbCcDdEeFf"
# Source: http://puppet-manifest-share.googlecode.com/svn/trunk/vmx-puppet/modules/lvs/files/keepalived.dns-pin
#
RR=keepalivepin.vmmatrix.net
[ $# -le 1 ]&&{ echo "usage: ${0} -h <ip>"; exit 126;}
while getopts "h:" OPT;do
case $OPT in
@kylelemons
kylelemons / valsort.go
Created September 22, 2011 21:36
Sort a map by its values
package main
import "fmt"
import "sort"
func main() {
m := map[string]int{
"One": 1,
"Two": 2,
"Three": 3,
@wheresalice
wheresalice / redisdns.py
Created November 27, 2011 12:56
Python DNS server with Redis backend
# A naive dns server with a Redis backend
# Set keys in Redis you want to be authoritative for (set google.com. 127.0.0.1)
# Tip: Use Redis's ttl functions to have temporary names
# Currently only does A records, feel free to fix that
#
# Licensed under the PSF License
# Thanks to: http://code.activestate.com/recipes/491264-mini-fake-dns-server/
# Author: @Kaerast <alice@kaerast.info>
import socket
@austinmarton
austinmarton / sendRawEth.c
Created February 27, 2012 08:40
Send a raw Ethernet frame in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
@extraordinaire
extraordinaire / reconnecting_pdo.php
Last active June 27, 2023 11:12
Reconnectable PDO
<?php
class ReconnectingPDO
{
protected $dsn, $username, $password, $pdo, $driver_options;
public function __construct($dsn, $username = "", $password = "", $driver_options = array())
{
$this->dsn = $dsn;
$this->username = $username;
$this->password = $password;
@inouetakuya
inouetakuya / td-agent.conf
Last active December 13, 2015 19:58
sample of td-agent config file
# ステップバイステップで学ぶ Fluentd + GrowthForecast でグラフ作成まとめ - 彼女からは、おいちゃんと呼ばれています
# http://d.hatena.ne.jp/inouetakuya/20130216/1361015295
<source>
type forward
</source>
<match apache.access>
type copy
@9466
9466 / fcgiclient.go
Last active March 20, 2016 14:53 — forked from wofeiwo/fcgiclient.go
// Copyright 2012 Junqing Tan <ivan@mysqlab.net> and The Go Authors
// Use of this source code is governed by a BSD-style
// Part of source code is from Go fcgi package
// Fix bug: Can't recive more than 1 record untill FCGI_END_REQUEST 2012-09-15
// By: wofeiwo
package fcgiclient
import (
@Gaubee
Gaubee / index.html
Last active December 20, 2015 14:59
nodejs远程命令行系统
<html>
<head>
<title>hehe</title>
<meta content="The Shell command runner Based on Nodejs">
<style>
/**
* basic styles for the javascript sandbox console - joss crowcroft
*
* http://josscrowcroft.github.com/javascript-sandbox-console/
*/
@hintjens
hintjens / gist:6634071
Created September 20, 2013 06:41
Multistage blackbox test
#include <czmq.h>
static void *
s_source (void *args)
{
zctx_t *ctx = zctx_new ();
void *pub = zsocket_new (ctx, ZMQ_PUB);
zsocket_bind (pub, "tcp://127.0.0.1:9000");
while (true) {