Skip to content

Instantly share code, notes, and snippets.

View olehermanse's full-sized avatar

Ole Herman Schumacher Elgesem olehermanse

View GitHub Profile
import java.io.*;
public class JavaRunCommand {
public static void main(String args[]) {
String s = null;
String navn = "Jeanette";
String nummer = "99998888";
try {
Process p = Runtime.getRuntime().exec("cowsay Hei mitt navn er " + navn + " og mitt nr er "+ nummer+".");

Bootstrapping to custom ports and/or host names

While implementing the bootstrap to custom ports and host names functionality I wrote this small "guide" on how to use the features and see if it worked.

Important: I have the repositories ~/cfengine/masterfiles and ~/cfengine/core on my machine. If you want to install from source you will need to adjust these paths accordingly to your folder locations.

PREREQUISITES

Add hostname (Optional)

If you want to test with a custom hostname, you can add it to /etc/hosts:

import random
attempts = 20000
choices = 25
def one_test(possibilities):
found = []
num = 0
while len(found) < possibilities:
r = random.randint(1,possibilities)
# 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
# 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
@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.

@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 / .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 / 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 / .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