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
@lantian
lantian / install.php
Last active December 19, 2015 13:18
Phalcon createTable
<?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;
}
@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.

@Twinklebear
Twinklebear / main.cpp
Last active February 18, 2024 02:28
Example of render to texture with SDL2
#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;
@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 */
@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 \
@ebirn
ebirn / runkexec
Last active November 15, 2017 05:20
kexec latest kernel on Centos 6
#!/bin/sh
VERSION=$(ls -t1 /boot/vmlinuz-* | cut -f 1 -d '-' --complement | head -1)
BOOT=/boot
KEXEC=/sbin/kexec
KERNEL=$BOOT/vmlinuz-$VERSION
INITRD=$BOOT/initramfs-$VERSION.img
@andrewkroh
andrewkroh / fstab.pp
Created August 9, 2014 16:55
Configuring /etc/fstab with Puppet Augeas
augeas{ '/etc/fstab - nosuid on /sys':
context => "/files/etc/fstab",
changes => [
"ins opt after /files/etc/fstab/*[file = '/sys']/opt[last()]",
"set *[file = '/sys']/opt[last()] nosuid",
],
onlyif => "match *[file = '/sys']/opt[. = 'nosuid'] size == 0",
}
augeas{ '/etc/fstab - acl on /sys':
@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
@samhocevar
samhocevar / gist:00eec26d9e9988d080ac
Last active January 13, 2024 23:40
Configure sshd on MSYS2 and run it as a Windows service
#!/bin/sh
#
# msys2-sshd-setup.sh — configure sshd on MSYS2 and run it as a Windows service
#
# Please report issues and/or improvements to Sam Hocevar <sam@hocevar.net>
#
# Prerequisites:
# — MSYS2 itself: http://sourceforge.net/projects/msys2/
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights
#
@dalenoe
dalenoe / unifi_ssl_import.sh
Last active October 14, 2018 16:20 — forked from stevejenkins/unifi_ssl_import.sh
Import and use SSL certificates (including Let's Encrypt) with the Ubiquiti UniFi Controller on Unix/Linux Systems
#!/usr/bin/env bash
# unifi_ssl_import.sh
# UniFi Controller SSL Certificate Import Script for Unix/Linux Systems
# by Steve Jenkins <http://www.stevejenkins.com/>
# Incorporates ideas from https://source.sosdg.org/brielle/lets-encrypt-scripts
# Version 2.2
# Last Updated June 26, 2016