Skip to content

Instantly share code, notes, and snippets.

Avatar
🏝️
Living the dream

Jeffrey Clark h0tw1r3

🏝️
Living the dream
View GitHub Profile
@cjthompson
cjthompson / RobustPDO.php
Created Feb 3, 2014
Extended PDO class that detects dropped connections and reconnects
View RobustPDO.php
<?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 */
@Twinklebear
Twinklebear / main.cpp
Last active Oct 8, 2021
Example of render to texture with SDL2
View main.cpp
#include <iostream>
#ifdef __linux__
#include <SDL2/SDL.h>
#elif defined(_WIN32)
#include <SDL.h>
#endif
const int WIN_WIDTH = 640;
const int WIN_HEIGHT = 480;
@tnolet
tnolet / puppetdb_postgres_hacks.md
Last active May 13, 2021
PuppetDB is awesome. Here's some tips on accessing the data in the Postgresql database...most of 'm just reminders for myself.
View puppetdb_postgres_hacks.md

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.
@lantian
lantian / install.php
Last active Dec 19, 2015
Phalcon createTable
View install.php
<?php
foreach ($this->_getModels() as $model) {
$columns = array();
$primaries = array();
foreach ($model['columns'] as $columnName => $column) {
if (isset($column['is_primary']) && $column['is_primary']) {
$primaries = $columnName;
}
@lukespragg
lukespragg / sign4j.c
Last active Aug 2, 2018
Sign4j for Linux
View sign4j.c
/*
sign4j.c: a simple utility to sign executables created by Launch4j
Copyright (c) 2012 Grzegorz Kowal
Modified for Linux by Luke Spragg (Wulfspider), Dalton Pelc (Olloth), Contex, and raphfrk
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
View manifests__site.pp
node demo {
nagios::host::service { 'ping':
check_command => 'check_ping',
}
}
@mtourne
mtourne / nxg_request_time_var.c
Created Dec 3, 2012
Expose a $request_time in msec to Nginx core
View nxg_request_time_var.c
/* 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();
@joshenders
joshenders / sabnzbdplus.default
Last active Dec 8, 2017
Installing sabnzbdplus on Debian Wheezy from source
View sabnzbdplus.default
# This file is sourced by /etc/init.d/sabnzbdplus
#
# When SABnzbd+ is started using the init script, the
# --daemon option is always used, and the program is
# started under the account of $USER, as set below.
#
# Each setting is marked either "required" or "optional";
# leaving any required setting unconfigured will cause
# the service to not start.
@rday
rday / gist:3504674
Created Aug 28, 2012
Abstract wrapper to allow connection pools
View gist:3504674
type InitFunction func() (interface{}, error)
type ConnectionPoolWrapper struct {
size int
conn chan interface{}
}
/**
Call the init function size times. If the init function fails during any call, then
the creation of the pool is considered a failure.
@jasonhancock
jasonhancock / puppet apache log analyzer
Created Aug 23, 2012
Analyze puppet's apache logs.
View puppet apache log analyzer
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $file = $ARGV[0] or die('Must pass an apache access logfile');
open IN, "<$file" or die("Can't open $file");