Skip to content

Instantly share code, notes, and snippets.

View rothwerx's full-sized avatar

Jeremiah Roth rothwerx

View GitHub Profile
@AvnerCohen
AvnerCohen / delete_branches_older_than.sh
Last active June 28, 2023 14:11 — forked from antonio/delete_branches_older_than.sh
Script to delete branches older than 6 months old, ignore local vs remote errors.
#!/bin/sh
ECHO='echo '
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
if [[ "$(git log $branch --since "6 months ago" | wc -l)" -eq 0 ]]; then
if [[ "$DRY_RUN" = "false" ]]; then
ECHO=""
fi
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
$ECHO git branch -d "${local_branch_name}"
@nmussat
nmussat / find.repo.biggest.files
Created January 4, 2010 23:50
Find biggest files from a Git repository
#!/bin/bash
# Find biggest files from a Git repository
# See http://progit.org/book/ch9-7.html
MAX_FILES=20
LINES=`git verify-pack -v .git/objects/pack/pack-*.idx | grep blob | sort -k 3 -n | tail -${MAX_FILES}`
IFS=$'\n'
for LINE in $LINES
do
@movitto
movitto / lvm-parser.rb
Created March 30, 2016 01:30
LVM Parser & Block Reader
# LVM Parser & Block Reader
#
# Copyright (C) 2016 Red Hat Inc
require 'optparse'
require 'ostruct'
require 'binary_struct'
### constants
@floer32
floer32 / tupperware.py
Last active September 26, 2022 12:13
recursively convert nested dicts to nested namedtuples, giving you something like immutable object literals
from UserDict import IterableUserDict
import collections
__author__ = 'github.com/hangtwenty'
def tupperware(mapping):
""" Convert mappings to 'tupperwares' recursively.
@mkutz
mkutz / Jenkinsfile
Last active August 11, 2022 10:57
Configure a secret text credential in Jenkins using a post-initialization script (https://wiki.jenkins.io/display/JENKINS/Post-initialization+script)
pipeline {
agent any
environment {
SECRET_TEXT = credentials("my-secret-text-crendentials-id")
USERNAME_PASSWORD = credentials("my-username-password-crendentials-id")
}
stages {
@jonaslejon
jonaslejon / Mailgun PHP API with curl
Last active July 31, 2021 21:29
Send mail with Mailgun API version 2 and PHP. Should also work with version 3 of the Mailgun API
define("DOMAIN", "test.se");
define("MAILGUN_API", "XXX123"); // Mailgun Private API Key
function br2nl($string) {
return preg_replace('/\<br(\s*)?\/?\>/i', "\n", $string);
}
function mg_send($to, $subject, $message) {
$ch = curl_init();
@jasonberanek
jasonberanek / README.md
Last active January 29, 2018 18:59
Enabling VNC support in the VMware ESXi 5.x Firewall

VMware ESXi includes a built in VNC server that can be used to access a VMs console for manipulation via automated tools (e.g., veewee) or by users on platforms where the vSphere Client is not supported. In ESXi 5.x, the built-in firewall does not allow VNC traffic to be received by the VNC server, even when an individual VM is configured to support this configuration. To complete this activity, the firewall has to be modified to allow the appropriate ports.

The below script can be run via the ESXi command line to setup the firewall rules necessary to run VNC. A few items to note:

  • Scripts assumes the firewall rules file is the default provided as by 5.0.0 update 2 build 914586 and/or 5.1.0 build 799733 (may work in other versions)
  • In order to persist settings after a reboot, it is necessary to copy the firewall settings to either a specific datastore mapped to the host, or the local persistent storage linked under the /store directory. Further, the either the /etc/rc.local (ESXi 5.0) or `/etc/rc.local
@iammilton82
iammilton82 / mailgun-sample.php
Created April 17, 2016 04:21
Mailgun APi Sample
class Mailgun {
function post($headers, $url, $data){
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
package main
import (
"github.com/codegangsta/martini"
"github.com/codegangsta/martini-contrib/binding"
"github.com/codegangsta/martini-contrib/render"
"labix.org/v2/mgo"
)
type Wish struct {
@ryanobjc
ryanobjc / pkg-graphite.sh
Created September 6, 2012 21:05
package up graphite using fpm
#!/bin/bash
VER=0.9.10
HERE=`pwd`
apt-get install python-setuptools python-django-tagging python-pysqlite2 python-memcache python-ldap python-django python-cairo-dev
wget https://launchpad.net/graphite/0.9/${VER}/+download/graphite-web-${VER}.tar.gz
wget https://launchpad.net/graphite/0.9/${VER}/+download/carbon-${VER}.tar.gz