def container_id(pid)
cgroup_file = "/proc/#{pid}/cgroup"
return nil unless File.exist?(cgroup_file)
container_id = File.foreach(cgroup_file)
.map(&:strip)
.select { |cg| cg.match?(/docker/) }.first
container_id.split('/').last
end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import argparse | |
from collections import defaultdict | |
from datetime import datetime,timedelta | |
import requests | |
import logging | |
import traceback | |
class JenkinsJobProfiler(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
source credentials.sh | |
export JENKINS_URL=http://127.0.0.1:8080 | |
export NODE_NAME=foobar3 | |
export JENKINS_CRUMB=$(curl --cookie-jar jenkins-cookies -s -X GET $JENKINS_URL/crumbIssuer/api/json --user ${JENKINS_USERNAME}:${JENKINS_PASSWORD} | jq -r '.crumb') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# I used this script to scan pictures in a 15 year old | |
# windows hard-drive and copy them to a specific folder with a name | |
# based on an increasing sequence. It also seemed to pick multiple | |
# formats that weren't exactly the type of pictures I would care about, | |
# so I filtered for those (icons, bitmaps, etc) | |
# | |
import sys | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <errno.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <sys/mman.h> | |
#include <elf.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Harsh translation from C to Python, with minimal python idioms. | |
# Original code by Brian Kernighan in chapter 1 of Beautiful Code | |
# | |
def match(regstr, s): | |
'''match: search for regexp anywhere in text''' | |
if regstr.startswith('^'): | |
return matchhere(regstr[1:], s) |
Get a list of nodes and their runlists matching a given recipe
knife exec -E 'nodes.find("recipe:*elasticsearch*") { |n| puts "hostname: #{n.name} runlist: #{n.run_list}" }'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NAME=rpmfs | |
CONTAINER=$(docker ps -q -a --filter name=$NAME) | |
if test -z "$CONTAINER"; then | |
docker run --name=$NAME \ | |
-v ${PWD}/../centos/:/data/centos \ | |
-v ${PWD}/../linux:/data/linux \ | |
-v images:/data/images \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <dlfcn.h> | |
#include <asm-generic/errno-base.h> | |
#include <errno.h> |
NewerOlder