Skip to content

Instantly share code, notes, and snippets.

@porjo
porjo / citrix_fedora.md
Last active January 14, 2020 03:32
Install Citrix ICA client on Fedora

Running Citrix ICA client on Fedora

  • Download 'Receiver for Linux Web client (x86_64)' from Citrix website
  • Install package e.g.dnf install ICAClientWeb-rhel-13.10.0.20-0.x86_64.rpm
  • Install dependencies (not sure if all these are required):
sudo dnf install compat-openssl10 motif libXaw libidn1.34 libjpeg-turbo-utils
  • Modify launcher /usr/share/applications/wfica.desktop:
@porjo
porjo / ssl_CN_lookup_by_IP.sh
Created December 6, 2019 00:29
Given a list of IP addresses (in file 'ips') find what the SSL CN (subject) is for each one.
#!/bin/bash
# Given a list of IP addresses (in file 'ips') find what the SSL CN (subject) is for each one.
echo -en "IP\tSSL CN\n"
for i in `cat ips`; do
echo -en "$i\t"
out=`timeout 2 bash -c "openssl s_client -showcerts -connect $i:443 < /dev/null 2> /dev/null | openssl x509 -noout -subject 2> /dev/null | grep 'subject=' | sed -rn 's/.*CN=([^ /]+).*/\1/p'"`
if [ $? -eq 124 ]; then
echo "(timeout)"
@porjo
porjo / docker_LAMP.md
Last active November 21, 2019 09:54
Minimal Centos 6.4 LAMP stack running on Docker (Ubuntu 13.04 host). End result is running httpd and port 80 is forwarded through from host to container.

Installation

sudo apt-get update
sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
sudo apt-get install linux-image-extra-`uname -r`
sudo sh -c "curl http://get.docker.io/gpg | apt-key add -"
sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker
@porjo
porjo / aws_sign_v4.php
Created April 16, 2019 05:27
PHP function to generate curl headers suitable for signed requests agains AWS API
// Sign the request and return header array for use by curl
//
// For HTTP methods with no payload (GET,DELETE) leave $Payload , $ContentType empty
//
// Based on: http://usefulangle.com/post/34/aws-s3-upload-api-php-curl
private function SignRequest($Method, $URL, $Payload='', $ContentType='')
{
if(!defined('AWS_ACCESS_KEY_ID') || !defined('AWS_SECRET_ACCESS_KEY') || !defined('AWS_REGION'))
return null;
@porjo
porjo / mcast_pub.go
Last active January 28, 2019 22:49
Simple PUB-SUB using multicast, written in Go. The publisher sends the string 'hello' every 2 seconds to IPv4 multicast 224.0.0.1 on UDP port 5000
package main
import (
"bufio"
"fmt"
"net"
"time"
)
func main() {
@porjo
porjo / exetel.15m+.sh
Created December 24, 2018 11:29
Argos / Bitbar shell script for fetching Exetel usage stats
#!/usr/bin/env bash
echo "Exetel"
echo "---"
USERNAME="076543210"
PASSWORD="xxxxx"
MinAge=5
COOKIE="/tmp/exetel.cookies"
JSON="/tmp/exetel.json"
@porjo
porjo / ec2-instance-dumper.sh
Last active December 10, 2018 04:44
Dump AWS EC2 instances to tab delimited output
#!/bin/bash
echo -e "Name\tInstanceID\tInstanceType\tState\tLaunchTime\tAvailabilityZone\tPrivateIP\tPublicIP"
#aws ec2 describe-instances --output text --query 'Reservations[*].Instances[*].[[Tags[?Key==`Name`].Value] [0][0], InstanceId, InstanceType, State.Name, LaunchTime, Placement.AvailabilityZone, PrivateIpAddress, PublicIpAddress ]'
aws ec2 describe-instances > instances.json
cat instances.json | jq -r '.Reservations[].Instances[]| [(.Tags[] | select(.Key == "Name") | .Value), .InstanceId, .InstanceType, .State.Name, .LaunchTime, .Placement.AvailabilityZone, .PrivateIpAddress, .PublicIpAddress, .VpcId ] | @tsv'
@porjo
porjo / elb_compare.sh
Last active November 13, 2018 00:54
Compare AWS ELB response times
#!/bin/bash
# compare AWS ELB: CLB (classic) and ALB (application) response times
# all output times are in seconds
CLB_URL="https://clb.example.com"
ALB_URL="https://alb.example.com"
clb_wins=0
alb_wins=0
@porjo
porjo / ffmpeg_recipies.md
Last active August 15, 2018 08:35
ffmpeg recipes

Mux mp4 + subtitles into an MKV

ffmpeg -fflags +genpts -i infile.mp4 -f srt -i subtitles.srt \
-map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt outfile.mkv

-fflags +genpts necessary if you get Can't write packet with unknown timestamp errors.

Extract part of video using start + end times

@porjo
porjo / retext.css
Last active August 13, 2018 03:54 — forked from elclanrs/retext.css
Markdown theme for ReText
body {
color: #333;
font-family: Arial, sans-serif;
max-width: 7.5in;
margin: 0 auto;
}
a:link, a:visited {
color: #1B70D1;
text-decoration: none;