Skip to content

Instantly share code, notes, and snippets.

View dserodio's full-sized avatar
🐕

Daniel Serodio dserodio

🐕
View GitHub Profile
@jerrac
jerrac / gitlab2elk.yml
Created March 23, 2015 22:19
Logstash and Logstash-Forwarder config for GitLab logs
# YAML config for these Ansible roles:
# https://github.com/LaneCommunityCollege/aspects_logstash
# https://github.com/LaneCommunityCollege/aspects_logstash_forwarder
#
# Since it's just straight config blocks, you should be able to just copy and paste what you need if you don't use
# those Ansible roles.
#
# End result is multiline logs combined into one, and dates are parsed correctly.
aspects_logstash_rules:
function setjava {
local vmdir=/Library/Java/JavaVirtualMachines
local ver=${1?Usage: setjava <version>}
export JAVA_HOME=`/usr/libexec/java_home -v $ver`
PATH=$(echo $PATH | tr ':' '\n' | grep -v $vmdir | tr '\n' ':')
export PATH=$JAVA_HOME/bin:$PATH
java -version
}
anonymous
anonymous / gist:223853355d67123fdda8
Created October 22, 2014 16:06
EC2 ssh tunnel bash script
#!/bin/bash
# Start/stop an EC2 instance for use as an ssh tunnel
# requires the aws package locally -- sudo apt-get install awscli
#
# usage: ./tunnel.sh start (spin up EC2 and create the tunnel)
# ./tunnel.sh stop (terminate the EC2 instance to save money)
# ./tunnel.sh resume (in case your tunnel is interrupted but the EC2 instance is still running)
# CHANGE THE PARAMETERS BELOW
@wdullaer
wdullaer / docker-cleanup
Last active August 17, 2023 14:17
Cleanup unused Docker images and containers
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@abayer
abayer / jenkins-git-backup.sh
Last active January 8, 2023 09:19
Example of a script for backing up Jenkins config in git.
#!/bin/bash
#
# Copies certain kinds of known files and directories from a given Jenkins master directory
# into a git repo, removing any old ones, adds 'em, commits 'em, pushes 'em.
#
set -ex
if [ $# -ne 2 ]; then
echo usage: $0 root_dir jenkins_master
# While GNU coreutil's ls is generally more featureful (including colorization
# based on file extensions, SI size formats, ISO date and time formats,
# semantic version sort, etc.), OS X's fork of FreeBSD ls allows viewing HFS+
# extended attributes and access control lists through the -@ and -e flags,
# respectively.
#
# This script provides a shim to allow BSD ls to be invoked with GNU-style
# flags and .dircolor files, and a function that shadows ls, invoking coreutils
# ls by default but automatically switching to the shim when the -@ and/or -e
# flags are detected.
@bradmontgomery
bradmontgomery / ipython_magic_function_inspector.py
Last active February 9, 2022 11:02
An IPython Magic function that will pretty-print python objects with syntax highlighting.
"""
An IPython magic function to pretty-print objects with syntax highlighting.
See, "Defining your own magics":
http://ipython.org/ipython-doc/stable/interactive/reference.html#defining-your-own-magics
For more on Pygments:
http://pygments.org/docs/quickstart/
Usage
@tehranian
tehranian / gist:7123269
Created October 23, 2013 17:43
Jenkins SSH slave launcher for 10x faster data transfer rates when archiving/copying artifacts. Leverages the learnings from: http://www.damtp.cam.ac.uk/user/ejb48/sshspeedtests.html
#!/bin/bash
# High-performance, native SSH implementation for Jenkins SSH slaves. Jenkins'
# standard turn-key SSH slave implementation uses an embedded, "pure Java"
# implementation of SSH (https://github.com/jenkinsci/trilead-ssh2).
# That standard implementation combines all of the convenience of a pure Java
# implementation with all of the "performance" of a pure Java implementation :P
# If your distributed build process generates large build artifacts like ISOs,
# VM images, Vagrant boxes, etc, then you will see a substantial benefit from
@willurd
willurd / web-servers.md
Last active April 26, 2024 12:46
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@bcap
bcap / start-stop-daemon-template
Last active July 21, 2023 11:12
Template file for creating linux services out of executables using the start-stop-daemon
#!/bin/bash
### BEGIN INIT INFO
# Provides: <service name>
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: <service description>
### END INIT INFO