Skip to content

Instantly share code, notes, and snippets.

@bjorand
bjorand / ocp.php
Created October 29, 2013 14:57 — forked from ck-on/ocp.php
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.6
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter
0.1.5 2013-04-12 added graphs to visualize cache state, please report any browser/style bugs
#!/bin/bash
awk 'BEGIN{ser=strftime("%Y%m%d",systime() )*100+1} /serial/{sub($1,$1 < ser ? ser : $1+1)}1' $1
@bjorand
bjorand / cleanup-ami.py
Last active September 10, 2015 16:29 — forked from marvinpinto/cleanup-ami.py
Python script to clean up and update the Jenkins AMIs after a successful Packer run
#!/usr/bin/python
import requests
import os
import boto.ec2
import sys
import re
build_url = os.environ['BUILD_URL']
jenkins_base_url = os.environ['JENKINS_URL']
@bjorand
bjorand / compile.rb
Last active April 20, 2016 16:02
Chef solo compile attribute
require 'mixlib/cli'
require "chef"
require "chef/config"
require "chef/config_fetcher"
require 'chef/workstation_config_loader'
class MyCLI
include Mixlib::CLI
import base64
import binascii
s = 'MDAxMDAwMDEwMTExMDEwMTAxMTAxMTExMDExMTEwMDEwMDEwMDAwMDAxMTEwMTAwMDExMDExMTAwMTEwMDAwMTAxMTEwMTExMDAxMDAwMDAwMTEwMDEwMTAxMDEwMTEx'
binary = int(base64.b64decode(s), 2)
ascii = binascii.unhexlify('%x' % binary)
print ascii[::-1]
@bjorand
bjorand / wait_tcp_port.sh
Last active June 22, 2016 19:14
Wait for a TCP port, Bash style
wait_tcp_port() {
local host="$1" port="$2"
# see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax.
while ! exec 6<>/dev/tcp/$host/$port; do
echo "$(date) - still trying to connect to $host:$port"
sleep 1
done
exec 6>&-
}
#!/usr/bin/env python
import re
import sys
import random
interrupts = {}
count = int(sys.argv[1])
@bjorand
bjorand / detect-os.sh
Created December 20, 2016 16:17
Helper for Detecting OS with bash
OS="$(uname -s)"
case $OS in
"Darwin")
echo dar
;;
"Linux")
echo lin
;;
*)
@bjorand
bjorand / bash-uuid.sh
Last active December 29, 2016 10:15
Generate UUID with bash
od -x /dev/urandom | head -1 | awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}'
@bjorand
bjorand / ansible-retry-example.yml
Created January 4, 2017 18:07
Ansible retry task example
---
- hosts: all
connection: local
tasks:
- shell: exit 1
register: task_result
until: task_result.rc == 0
retries: 10
delay: 1
ignore_errors: yes