Skip to content

Instantly share code, notes, and snippets.

View haukurk's full-sized avatar

Haukur Kristinsson haukurk

View GitHub Profile
@haukurk
haukurk / syslogger.py
Created December 11, 2014 17:04
Logger that sends to syslog servers.
#!/usr/bin/python
# -*- encoding: iso-8859-1 -*-
"""
Python syslog client.
This code is placed in the public domain by the author.
Written by Christian Stigen Larsen.
This is especially neat for Windows users, who (I think) don't
@haukurk
haukurk / check_docker_container.sh
Created September 7, 2016 22:07
Monitoring scripts for docker containers.
#!/bin/bash
# Author: Haukur Kristinsson / Erik Kristensen
# Email: haukur@hauxi.is / erik@erikkristensen.com
# License: MIT
# Nagios Usage: check_nrpe!check_docker_container!_container_id_
# Usage: ./check_docker_container.sh _container_id_
#
# The script checks if a container is running.
# OK - running
@haukurk
haukurk / myips.sh
Created October 3, 2018 16:21
cli myips
# return my IP addresses
function myip() {
ExtIP=`dig TXT +short o-o.myaddr.l.google.com @ns1.google.com`
echo $ExtIP | tr -d '"' | awk '{print "external : " $1}'
ifconfig lo0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "lo0 : " $2}'
ifconfig en0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en0 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en0 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en0 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en1 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en1 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}'
ifconfig en1 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en1 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}'
}
@haukurk
haukurk / logstash-netscaler.conf
Created December 3, 2014 17:13
Logstash - Netscaler Config
input {
syslog {
type => "netscaler"
port => "5560"
}
}
filter {
# Set tags for ASAs
@haukurk
haukurk / keybase.md
Created September 19, 2019 22:16
keybase.md

Keybase proof

I hereby claim:

  • I am haukurk on github.
  • I am hauxi (https://keybase.io/hauxi) on keybase.
  • I have a public key ASAuAPmKWphFhCqMR0py36c-otQlfo-JrnHHSL9xX0Hcvwo

To claim this, I am signing this object:

@haukurk
haukurk / Dockerfile
Last active November 8, 2018 17:58
.NET Core NancyFx with IdentityServer4
FROM microsoft/dotnet:1.1.1-sdk
COPY ./NancyAPI.csproj /app/
WORKDIR /app/
RUN dotnet restore
ADD ./ /app/
RUN dotnet publish -c Debug
EXPOSE 5000
@haukurk
haukurk / PublishContentExtensions.cs
Created September 18, 2018 14:18
PublishContentExtensions
using Our.Umbraco.Vorto.Extensions;
using System;
using Umbraco.Core.Models;
namespace Umbraco.Custom.Extensions
{
public static class PublishContentExtensions
{
public static T GetNonNullableVortoValue<T>(this IPublishedContent content, string propertyAlias, T defaultValue, string cultureName = null)
{
@haukurk
haukurk / empty-recycle-bin-umbraco7.sql
Last active June 7, 2018 23:36
Empty recycle bin in Umbraco
--deletes in Document
--at this point all associated media files are deleted
delete from umbracoDomains where id in (select id from umbracoNode where path like '%-20%' and id!=-20);
delete from cmsDocument where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20);
--deletes in Content
delete from cmsPropertyData where contentNodeId in (select id from umbracoNode where path like '%-20%' and id!=-20);
delete from cmsPreviewXml where nodeId in (select id from umbracoNode where path like '%-20%' and id!=-20);
delete from cmsContentVersion where ContentId in (select id from umbracoNode where path like '%-20%' and id!=-20);
delete from cmsContentXml where NodeId in (select id from umbracoNode where path like '%-20%' and id!=-20);
@haukurk
haukurk / README-LockOSX.md
Last active October 28, 2017 11:45
Lock OSX without going to sleep.
cat > main.m <<EOF

#import <objc/runtime.h>
#import <Foundation/Foundation.h>

int main () {
    NSBundle *bundle = [NSBundle bundleWithPath:@"/Applications/Utilities/Keychain Access.app/Contents/Resources/Keychain.menu"];

 Class principalClass = [bundle principalClass];
@haukurk
haukurk / _core.py
Created September 10, 2017 12:07 — forked from justanr/_core.py
Clean Architecture In Python
from abc import ABC, ABCMeta, abstractmethod
from collections import namedtuple
from itertools import count
PayloadFactory = namedtuple('PayloadFactory', [
'good', 'created', 'queued', 'unchanged', 'requires_auth',
'permission_denied', 'not_found', 'invalid', 'error'
])
"""