Skip to content

Instantly share code, notes, and snippets.

Stig Lindqvist stojg

Block or report user

Report or block stojg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stojg
stojg / port-check.sh
Created May 2, 2015
port-check.sh - small script to check if TCP ports are opened through firewalls etc.
View port-check.sh
#!/bin/bash
function checkport {
if nc -zv -w30 $1 $2 <<< '' &> /dev/null
then
echo "[+] Port $1/$2 is open"
else
echo "[-] Port $1/$2 is closed"
fi
}
View check.diff
commit e7e69bb9a04803cd503cbe32ee9829aebd8dad18
Author: Stig Lindqvist <stig@silverstripe.com>
Date: Thu Apr 2 12:47:29 2015 +1300
check x509 certificates expiry time at 9:01 and email ops
diff --git a/cwp/manifests/manager.pp b/cwp/manifests/manager.pp
old mode 100755
new mode 100644
index 0a26a99..cabee8f
@stojg
stojg / gist:456d733015c6449b0dd1
Last active Aug 29, 2015
Speed up vagrant networking by a gazillion
View gist:456d733015c6449b0dd1
Vagrant.configure(2) do |config|
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
end
end
@stojg
stojg / parse.php
Last active Jun 23, 2016
simple parsing of aws cloudtrail logs
View parse.php
<?php
$files = glob("*.json");
foreach($files as $file) {
$content = file_get_contents($file);
$data = json_decode($content, true);
if(!isset($data['Records'])) {
continue;
}
View xhprof.sh
#!/bin/bash
apt-get update
apt-get install -y php5-dev make php-pear php5-mongo
pecl config-set preferred_state beta
pecl install xhprof
cd /var/www/mysite/www/
rm -rf xhprof
wget https://github.com/stojg/xhgui/archive/v0.4.1.tar.gz
tar xvzf v0.4.1.tar.gz
rm v0.4.1.tar.gz
@stojg
stojg / server-status.conf
Last active Aug 29, 2015
server-status.conf
View server-status.conf
Listen 81
<VirtualHost *:81>
ServerName localhost
<Location />
<IfModule mod_status.c>
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost ip6-localhost 127.0.0.0/255.0.0.0
@stojg
stojg / consul
Created Dec 1, 2014
consul service init script for debian
View consul
#!/bin/sh
### BEGIN INIT INFO
# Provides: consul
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Consul service discovery framework
# Description: Healthchecks local services and registers
# them in a central consul database.
@stojg
stojg / coreos.json
Created Nov 14, 2014
CoreOS On AWS Cloudformation
View coreos.json
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/",
"Mappings" : {
"RegionMap" : {
"eu-central-1" : { "AMI" : "ami-e8c6f0f5" },
"ap-northeast-1" : { "AMI" : "ami-858eb884" },
"sa-east-1" : { "AMI" : "ami-7b922666" },
"ap-southeast-2" : { "AMI" : "ami-13abc629" },
"ap-southeast-1" : { "AMI" : "ami-7e78592c" },
View gist:72d52f2e115cd55bbff4
--- a/cwp/files/repos/deploynaut-lib/cwptasks.rb
+++ b/cwp/files/repos/deploynaut-lib/cwptasks.rb
@@ -5,26 +5,9 @@ namespace :deploy do
# We are deploying to both sides, signal to csync2 that we want it disabled, and wait for it to finish.
task :disable_csync do
run "touch #{deploy_to}/csync2.disable"
-
- # Check lock by trying to acquire it for one minute (36 checks, 5s delay).
- # Outer bash is needed for the loop to function correctly.
- begin
View gist:45536da87b6776792528
<?php
$dateFrom = DateTime::createFromFormat('d/m/Y', '03/11/2014');
$dateTo = DateTime::createFromFormat('d/m/Y', '02/01/2015');
$difference = $dateFrom->diff($dateTo);
// diff in years, months and years
echo $difference->y.' '.$difference->m.' '.$difference->d.PHP_EOL;
You can’t perform that action at this time.