Skip to content

Instantly share code, notes, and snippets.

View haukurk's full-sized avatar

Haukur Kristinsson haukurk

View GitHub Profile
@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 / 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 / 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'
])
"""
@haukurk
haukurk / haukurks_id_rsa.pub
Last active August 18, 2017 12:38
Haukur's public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDxRkEH755QbPFZ602h/9tLz7O2Eu86aL2yXqEAbNuFe2w7op4bs3C/nYwLRzs3Ff2a073pIaB8GWy9YxWf6c1Sr8NIqiXyafvWyi1nLVJVb653dgM1nBsoQ2FYtVTCLe46OKf5S7gSHryfjT2B+zcUgNmWbgMAYCFTrNI1Q6+ajfB5dzXRP8hfmEljhCDAoFwo1sdVM4K3RhPCdVCD0XvXpXFLQ5pTykVslnk4nQX6EyZ2J4W4g3JztcYZLPxS5q2rYpu/3vR5et3T8OI2O0NeOdM2/Yuhxt28CT3Jdi7NCkr2mEGkCN4nOgpQpobQAos7+tQHQGWADquOoHVbvZst
@haukurk
haukurk / del_archivelogs.sh
Created June 13, 2017 22:55
Clean RMAN logs, without doing backup.
#!/bin/sh
INPSID=x850
usage()
{
echo "delete some archivelogs ahy!"
echo ""
echo "./del_archivelogs.sh"
echo "\t-h --help"
@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 / docker-deploy.sh
Created April 1, 2017 10:41
Deployment Docker Script
#!/usr/bin/env bash
set -e
echo '>>> Get old container id'
CID=$(sudo docker ps | grep "project" | awk '{print $1}')
echo $CID
echo '>>> Building new image'
# Due to a bug in Docker we need to analyse the log to find out if build passed (see https://github.com/dotcloud/docker/issues/1875)
sudo docker build ./deploy | tee /tmp/docker_build_result.log