Skip to content

Instantly share code, notes, and snippets.

View haukurk's full-sized avatar

Haukur Kristinsson haukurk

View GitHub Profile
@haukurk
haukurk / DTOExtensions.cs
Created November 15, 2016 15:10
DTO Extensions
/// <summary>
/// Extension methods for mapping entities to DTOs
/// </summary>
public static class DTOExtensions
{
/// <summary>
/// Extension method for IEnumerable to map them to DTO of type T
/// </summary>
/// <typeparam name="T">DTO type</typeparam>
/// <param name="obj">Collection of entities</param>
@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 / native fb ionic service
Created February 16, 2016 01:05
Ionic fb native
angular.module('far.core.social', [])
.factory('$facebook', function(LoopBackAuth, $rootScope, FARAuthService, $raven, $ionicLoading) {
// This is the success callback from the login method
var fbLoginSuccess = function(response) {
if (!response.authResponse){
fbLoginError("Cannot find the authResponse");
return;
}
@haukurk
haukurk / renew.sh
Created February 14, 2016 20:58
Simple renewal script for letsencrypt standalone server
#!/bin/sh
service nginx stop # or whatever your webserver is
if ! /root/letsencrypt/letsencrypt-auto certonly --standalone --email haukur@hauxi.is -d farcore.farapp.io -d farcore-test.farapp.io > /var/log/letsencrypt/renew.log 2>&1 ; then
echo Automated renewal failed:
cat /var/log/letsencrypt/renew.log
exit 1
fi
service nginx start # or whatever your webserver is
REQ.IP.SOURCEIP == 5.23.64.0 -netmask 255.255.224.0
REQ.IP.SOURCEIP == 31.15.112.0 -netmask 255.255.248.0
REQ.IP.SOURCEIP == 31.209.136.0 -netmask 255.255.248.0
REQ.IP.SOURCEIP == 31.209.144.0 -netmask 255.255.240.0
REQ.IP.SOURCEIP == 31.209.192.0 -netmask 255.255.192.0
REQ.IP.SOURCEIP == 37.152.64.0 -netmask 255.255.248.0
REQ.IP.SOURCEIP == 37.205.32.0 -netmask 255.255.248.0
REQ.IP.SOURCEIP == 37.235.49.0 -netmask 255.255.255.0
REQ.IP.SOURCEIP == 46.22.96.0 -netmask 255.255.240.0
REQ.IP.SOURCEIP == 46.28.152.0 -netmask 255.255.248.0
@haukurk
haukurk / nginx.pp
Last active August 29, 2015 14:11
Puppet Nginx
class { 'nginx': }
nginx::resource::vhost { "public.hauxi.is":
ensure => present,
proxy => 'http://localhost:3100'
}
@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 / logstash-cisco-asa.conf
Created December 3, 2014 17:15
Logstash - Cisco ASA
input {
syslog {
type => "cisco-asa"
port => "5561"
}
}
filter {
# Set tags for ASAs
@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 / postgresql-postgis.pp
Last active August 29, 2015 14:09
PostgreSQL with PostGIS2 extension - Puppet Example
# Install PostgreSQL 9.3 server from the PGDG repository
class {'postgresql::globals':
version => '9.3',
manage_package_repo => true,
encoding => 'UTF8',
locale => 'it_IT.utf8',
}->
class { 'postgresql::server':
ensure => 'present',
listen_addresses => '*',