Skip to content

Instantly share code, notes, and snippets.

Avatar

Enteee

View GitHub Profile
@Enteee
Enteee / add_nodes.py
Created Aug 27, 2019
ucmdb-api example
View add_nodes.py
import random
import string
N=20
api.insert([
{
'ucmdbId': i,
'type': 'node',
'properties': {
'name': ''.join(random.choices(string.ascii_uppercase + string.digits, k=N))
}
@Enteee
Enteee / class-variable-in-subprocess.py
Last active Aug 6, 2019
Demonstrate operating syste dependent behaviour w.r.t static class members in subprocess
View class-variable-in-subprocess.py
from multiprocessing import Process
class C(object):
VAR = 'DEFAULT'
def print_c():
print(f'C.VAR = {C.VAR}')
def main():
@Enteee
Enteee / events.js
Last active Aug 5, 2019
FluentFlow Example: If you see within 2 seconds two invalid login attemps followed by a successful login from the same source, then alert.
View events.js
const ff = require('fluentflow')
const $ = ff.RuleBuilder;
const _ = require('lodash');
const moment = require('moment')
/**
* Not interesting if older than 2 seconds
*/
function isInteresting(c, pc){
return moment.duration(
@Enteee
Enteee / docker-compose.sh
Last active Sep 25, 2019 — forked from Gems/docker-compose.sh
A `docker-compose` wrapper for multiple configuration files with relative paths
View docker-compose.sh
#!/usr/bin/env bash
# Docker compose wrapper with submodule support
# Reads all docker-compose.yaml files given with -f / --files and compiles one
# big docker-compose.yaml file before running docker-compose.
#
# This is useful when you have nested docker-compose subprojects in different
# folders which contain relative paths.
# see: https://github.com/docker/compose/issues/3874
#
# Environment:
@Enteee
Enteee / :for
Last active Dec 27, 2018
Bash: Parallel execute and retain exit code
View :for
#!/usr/bin/env bash
# Wait for pids to terminate. If one pid exits with
# a non zero exit code, send the TERM signal to all
# processes and retain that exit code
#
# usage:
# :wait 123 32
function :wait(){
local pids=("$@")
@Enteee
Enteee / code_quality.py
Created Oct 7, 2017
Check eval(repr(cls())) == cls() for whole package
View code_quality.py
#!/usr/bin/env python3
# vim: set fenc=utf8 ts=4 sw=4 et :
"""
Tests the follwoing rules for a whole package:
1. Repr is unique: All classes must implement __repr__ with eval(repr(cls())) == cls()
"""
import unittest
@Enteee
Enteee / Makefile
Last active Aug 11, 2016
scanf userland & kernelspace test
View Makefile
.PHONY: all runtest
MODULES_DIR := /lib/modules/$(shell uname -r)
KERNEL_DIR := $(MODULES_DIR)/build
obj-m := test.o
all: test test.ko
You can’t perform that action at this time.