Skip to content

Instantly share code, notes, and snippets.

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 April 26, 2018 17:56
Send an RTP stream of G.711-silence to an arbitrary destination
#!/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 December 12, 2023 23:52
A simple implementation of a CSD-Wrapper as required for OpenConnect to comply with Cisco AnyConnect "hostscan" policies.
#!/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 January 14, 2017 00:37
Send an OPTIONS ping to a SIP server - including peculiarities needed to make Asterisk happy.
#!/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 / colorbars.js
Created September 12, 2016 23:14
Draws SMPTE test color bars on a Canvas element.
// Takes a canvas context2d and draws the SMPTE test color bars on it.
function drawSMPTEColorBars(c, x, y, w, h) {
c.save();
c.translate(x, y); c.scale(w / 1920, h / 1080);
var g = c.createLinearGradient(445, 0, 1680, 0);
g.addColorStop(0, '#000000');
g.addColorStop(1, '#ffffff');
c.fillStyle='#000000'; c.fillRect(0, 0, 1920, 1080);
c.fillStyle='#666666'; c.fillRect(0, 0, 240, 630);
c.fillStyle='#bfbfbf'; c.fillRect(240, 0, 205, 630);
@p120ph37
p120ph37 / autodeps.pm
Created July 20, 2016 19:52
Automatically download/build/install CPAN dependencies into a project-local folder.
###
package autodeps;
###
#
# Example usage:
#
# #!/usr/bin/perl
# use warnings;
# use strict;
#
@p120ph37
p120ph37 / mksh-dynamicfd.patch
Last active May 27, 2016 02:00
Add support for dynamic file descriptors to the MirBSD Korn Shell.
Index: check.t
===================================================================
RCS file: /cvs/src/bin/mksh/check.t,v
retrieving revision 1.732
diff -u -r1.732 check.t
--- check.t 17 May 2016 15:36:56 -0000 1.732
+++ check.t 27 May 2016 01:47:35 -0000
@@ -10032,6 +10032,28 @@
bar
baz
@p120ph37
p120ph37 / curl_file_exists.sh
Last active January 2, 2024 23:36
How to test if a remote file exists from a shell script using curl.
url='http://example.com/index.html'
# "HEAD" request
# (most servers support "HEAD", but some don't)
if curl -sfILo/dev/null "$url"; then
echo "URL exists"
else
echo "URL does not exist"
fi
@p120ph37
p120ph37 / Vagrantfile
Created April 18, 2016 11:16
Use Vagrant's "docker-provider" to run a Dockerfile on any host. Works around issues with the current hashicorp/boot2docker image.
Vagrant.configure(2) do |config|
# Generate shared docker-host Vagrantfile
# (the default hashicorp/boot2docker image doesn't work very well at the moment)
env = Vagrant::Environment.new
vf_path = env.data_dir.join("docker-virtualbox-host", "Vagrantfile")
begin
env.lock("docker-provider-virtualbox-hostvm") do
vf_path.dirname.mkpath
File.open(vf_path, 'w') do |file|
@p120ph37
p120ph37 / gist:7ae912d9eaa9b938a7f4
Last active March 16, 2016 21:27
Docker on OS X via homebrew + virtualbox
# brew cask install virtualbox
brew install docker docker-machine
docker-machine create -d virtualbox default
# docker-machine start
# eval $(docker-machine env)