Skip to content

Instantly share code, notes, and snippets.

View olehermanse's full-sized avatar

Ole Herman Schumacher Elgesem olehermanse

View GitHub Profile
@olehermanse
olehermanse / def.json
Last active January 22, 2019 12:04
CFEngine: Enable client initiated report and monitoring on all hosts
{
"classes": {
"client_initiated_reporting_enabled": [ "any" ],
"mpf_augments_control_enabled": [ "any" ],
"services_autorun": [ "any" ],
"cfengine_internal_purge_policies": [ "any" ]
},
"vars": {
"control_server_call_collect_interval": "1",
"control_hub_exclude_hosts": [ "0.0.0.0/0" ],
@olehermanse
olehermanse / .style.yapf
Last active March 19, 2018 18:42
My current yapf config for Python
[style]
based_on_style = pep8
split_before_first_argument = true
column_limit = 78
@olehermanse
olehermanse / .clang-format
Created March 19, 2018 16:31
My current clang-format config for C
---
BasedOnStyle: Google
---
Language: Cpp
ColumnLimit: 78
IndentWidth: 4
TabWidth: 4
UseTab: Never
MaxEmptyLinesToKeep: 3
AlignTrailingComments: true
@olehermanse
olehermanse / json_order.py
Created January 10, 2018 14:24
Recursively sorting json in python
import sys
import json
from collections import OrderedDict
def dict_sort(old_dict):
if isinstance(old_dict, list):
return [dict_sort(x) for x in old_dict]
if not isinstance(old_dict, dict):
return old_dict
new_dict = OrderedDict()
@olehermanse
olehermanse / .tmux.conf
Created June 27, 2017 13:03
My tmux conf, must start using "tmux attach" :(
#!/usr/bin/tmux source-file
bind-key C-o select-pane -t :.+
bind-key -n C-o select-pane -t :.+
set -g mouse on
bind-key -t emacs-copy MouseDragEnd1Pane copy-pipe "pbcopy"
bind-key -t vi-copy MouseDragEnd1Pane copy-pipe "pbcopy"
new-session -d
split-window -d -t 0 -v
@olehermanse
olehermanse / prob.py
Created April 3, 2017 21:31
Average number of tries to pick all options
import numpy.random as random
attempts = 100000
choices = 25
def one_test(possibilities):
found = []
num = 0
while len(found) < possibilities:
r = random.randint(1,possibilities)
@olehermanse
olehermanse / win-dev-aws.md
Last active January 24, 2017 17:32
Steps needed to set up a windows development machine in AWS.

Windows development machine on AWS

This outlines the steps needed to set up windows machines in AWS, and install the bare minimum requirements for development machines (notepad++, OpenSSH, gdb). I used windows server 2008R2 SP1 64-bit, procedure for other version should be very similar.

Important: If you just want to use a machine already set up, like the windows 2008R2 dev machine, scroll down to "Spawning a new machine".

Installation / First time setup

Select country

Instances/Images are stored per country, so make sure you have selected the appropriate country. If unsure, use Ireland.

# Run: curl -L -s bit.ly/libs_cfengine -o temp.sh && sudo bash ./temp.sh
apt-get update
apt-get -qy update
apt-get -qy install bison flex binutils build-essential fakeroot ntp dpkg-dev libpam0g-dev python debhelper pkg-config default-jre-headless psmisc nfs-common
apt-get install -y emacs24 git nano
apt-get install -y ntp ntpd
apt-get install -y gdb automake autoconf
apt-get install -y python-pip python3-pip
apt-get install -y libssl-dev libpcre3 libpcre3-dev
# run this script: bash <(curl -L -s bit.ly/clone_cfengine)
git clone https://github.com/cfengine/core.git
git clone https://github.com/cfengine/enterprise.git
git clone https://github.com/cfengine/nova.git
git clone https://github.com/cfengine/masterfiles.git
git clone https://github.com/cfengine/buildscripts.git
git clone https://github.com/cfengine/mission-portal.git
git clone https://github.com/cfengine/design-center.git
import random
attempts = 20000
choices = 25
def one_test(possibilities):
found = []
num = 0
while len(found) < possibilities:
r = random.randint(1,possibilities)