Skip to content

Instantly share code, notes, and snippets.

View stojg's full-sized avatar

Stig Lindqvist stojg

View GitHub Profile
-----BEGIN CERTIFICATE-----
MIIDQzCCAiugAwIBAgIJAJp4tvc4WSmQMA0GCSqGSIb3DQEBCwUAMDgxCzAJBgNV
BAYTAk5aMSkwJwYDVQQDDCBhZDEuZGMuY3dwLndndG4uc2lsdmVyc3RyaXBlLmNv
bTAeFw0xNjA2MjcwMjU2MTRaFw0xNzA2MjcwMjU2MTRaMDgxCzAJBgNVBAYTAk5a
MSkwJwYDVQQDDCBhZDEuZGMuY3dwLndndG4uc2lsdmVyc3RyaXBlLmNvbTCCASIw
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMcKuK7H0pRzslSwDu9X3yMA7QIv
qAo/gOmjdPTmOjC3a6bLJEFgO8+RHOC+p2WvttGvLQqKOP2H4L1yqD+yNHpfSQAL
6bqq7byUPm4MFMgmx6LD+LaQWii7b9awLOJ8cxZ+d6wmYxcIkY1SDOjO2jpYz6pS
DMknsuWXcJfDejyl4MyRMZGyW46iPxi6jg+eMTsX6CeHjPIHBdg9g6YZvG++fRI3
Vbm4LB/fz3GNQBkq0VAWTuVp9e4ymVyAXEIrs/GSYt7mqFnVDL8bhgXBIhEA2VZ+
@stojg
stojg / sleep_server.go
Created March 16, 2016 23:43
Sleep server, connects, but takes ages to respond
package main
import(
"fmt"
"net/http"
"log"
"time"
"flag"
)
@stojg
stojg / sleep.ino
Last active April 4, 2023 14:23
Arduino sleep example
// This is an example how to put an arduino board into deep sleep to save on battery power and
// periodically wake up to run some logic. Ideal for sensor stations like plant moisture sensors.
#include "Arduino.h"
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
// Blink Before sleeping
#define LED_PIN (13)
@stojg
stojg / clean_whisper.sh
Created February 3, 2016 20:38
delete corrupted graphite whisper files
#!/bin/bash
options=('find' 'delete')
PS3='state your wish: '
echo -e "\nfind/delete corrupt whisper-files"
select opt in "${options[@]}"; do
case $REPLY in
[12] ) option=$opt; break;;
* ) exit;;
@stojg
stojg / curl.php
Last active August 29, 2015 14:21
simple curl template
<?php
function get($url) {
$timeout = 2;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
@stojg
stojg / port-check.sh
Created May 2, 2015 22:55
port-check.sh - small script to check if TCP ports are opened through firewalls etc.
#!/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
}
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 August 29, 2015 14:16
Speed up vagrant networking by a gazillion
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 June 23, 2016 01:38
simple parsing of aws cloudtrail logs
<?php
$files = glob("*.json");
foreach($files as $file) {
$content = file_get_contents($file);
$data = json_decode($content, true);
if(!isset($data['Records'])) {
continue;
}
@stojg
stojg / xhprof.sh
Last active August 29, 2015 14:11
#!/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