Skip to content

Instantly share code, notes, and snippets.

@p120ph37
p120ph37 / install_stuntman.sh
Created Jun 19, 2020
Stuntman install for CentOS
View install_stuntman.sh
yum install -y curl make gcc-c++ boost-devel openssl-devel
curl http://www.stunprotocol.org/stunserver-1.2.16.tgz | tar -xz
cd stunserver
make
cp stunserver /usr/sbin
cat - >/etc/init.d/stunserver <<'END'
#!/bin/sh
# chkconfig: 345 91 09
### BEGIN INIT INFO
# Provides: stunserver
@p120ph37
p120ph37 / BuildInfoExample.java
Last active Apr 28, 2020
Using BuildInfo in Gradle without Spring Boot
View BuildInfoExample.java
import java.io.IOException;
import java.util.Map.Entry;
import java.util.Properties;
public class BuildInfoExample {
public static void main(String[] args) throws IOException {
Properties buildInfo = new Properties();
buildInfo.load(BuildInfoExample.class.getClassLoader().getResourceAsStream("META-INF/build-info.properties"));
for(Entry<Object, Object> entry : buildInfo.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
@p120ph37
p120ph37 / setupOSX.sh
Last active Feb 25, 2020 — forked from tylerwalts/setupOSX.sh
This is a bash script to setup Mac OS X defaults on a new mac.
View setupOSX.sh
#!/bin/bash
#
# Set up OSX preferences
#
# Inspired by: https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###########################################
# CONFIG
if [ "$#" -lt 2 ]; then
echo -e "Usage: $0 {hostname} {timezone}\nExample: $0 machiavellia America/New_York"
@p120ph37
p120ph37 / ExampleUsage.java
Last active Dec 4, 2018
Servlet Parameter Validator Utility Class
View ExampleUsage.java
public class ExampleUsage extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final ParameterValidator validator = new ParameterValidator()
.regex("userName", "^[a-z0-9.]{1,20}$")
.regex("fullName", "^[A-Za-z0-9.]{1,40}$", false)
.regex("street", "^[A-Za-z0-9 ]{1,30}$")
.regex("city", "^[A-Za-z ]{1,30}$")
.regex("zip", "^[A-Za-z0-9 ]{1,20}$")
View autodeps.pm
###
package autodeps;
###
use strict;
use warnings;
use Cwd qw/cwd abs_path/;
use File::Basename qw/dirname/;
use File::Spec::Functions qw/catdir/;
@p120ph37
p120ph37 / Single_line_BadIdea.bgptheme
Last active Sep 25, 2018
A theme for https://github.com/magicmonty/bash-git-prompt, based on Single_line_Ubuntu, but with some spacing adjustment and with the Git path colorized and the branch name injected at the base of it rather than the end.
View Single_line_BadIdea.bgptheme
override_git_prompt_colors() {
gp_pwd() {
local git_top="$(git rev-parse --show-toplevel 2> /dev/null)"
case "$1" in
out) local out="${git_top:+$(dirname $git_top)/}"; out="${out:-$PWD}"; printf '%s' "${out/#$HOME/~}" ;;
in) printf '%s' "${git_top:+${PWD#$git_top}}" ;;
*) printf '%s' "${git_top:+$(basename $git_top)}" ;;
esac
}
# Based mostly on Single_line_Ubuntu, but with some excess space removed
View gist:e4fb0bdc52d2f1961a45f77e22303bcc
task depsize {
group 'Help'
description 'Displays the sizes of all dependencies.'
doLast {
def size = 0, formatStr = "%,10.2f", out = new StringBuffer()
configurations.default.collect{it.length() / (1024 * 1024)}.each{size += it}
out << 'Total dependencies size:'.padRight(45)
out << "${String.format(formatStr, size)} Mb\n\n"
configurations.default.sort{-it.length()}.each {
out << "${it.name}".padRight(45)
@p120ph37
p120ph37 / rtpping.pl
Created Apr 26, 2018
Send an RTP stream of G.711-silence to an arbitrary destination
View rtpping.pl
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
# use Time::HiRes qw/time sleep/;
# Since Time::HiRes is not always available, use the syscalls directly:
require 'syscall.ph';
use subs qw/time sleep/;
sub time {
my $tv = pack('q2', 0, 0);
@p120ph37
p120ph37 / csd-wrapper.sh
Last active Nov 20, 2019
A simple implementation of a CSD-Wrapper as required for OpenConnect to comply with Cisco AnyConnect "hostscan" policies.
View csd-wrapper.sh
#!/bin/bash
unset URL TICKET STUB GROUP CERTHASH LANGSELEN
shift
while [ "$1" ]; do
if [ "$1" == "-ticket" ]; then shift; TICKET=$1; fi
if [ "$1" == "-stub" ]; then shift; STUB=$1; fi
if [ "$1" == "-group" ]; then shift; GROUP=$1; fi
if [ "$1" == "-certhash" ]; then shift; CERTHASH=$1; fi
if [ "$1" == "-url" ]; then shift; URL=$1; fi
@p120ph37
p120ph37 / sipping.pl
Last active Jan 14, 2017
Send an OPTIONS ping to a SIP server - including peculiarities needed to make Asterisk happy.
View sipping.pl
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
# use Time::HiRes qw/time sleep/;
# Since Time::HiRes is not always available, use the syscalls directly:
require 'syscall.ph';
use subs qw/time sleep/;
sub time {
my $tv = pack('q2', 0, 0);
You can’t perform that action at this time.