Skip to content

Instantly share code, notes, and snippets.

set PGUSER=postgres
set PGPASSWORD=xxx
set OUTPUTPATH=e:\myfile.backup
set DB=whatever
set HOST=whatever
pg_dump -h %HOST% -p 5432 -U %PGUSER% -F c -b -v -f %OUTPUTPATH% %DB%
rem TCP port to unblock is 5432
echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
@tomfanning
tomfanning / FixEnterpriseWsdl.cs
Created June 19, 2015 14:28
Program to patch Enterprise.wsdl which Salesforce thinks is okay but causes Microsoft's wsdl.exe to emit non-working code
namespace FixEnterpriseWsdl
{
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml;
/// <summary>
/// Implements a fix for https://developer.salesforce.com/forums?id=906F0000000AiPEIA0
@tomfanning
tomfanning / start-mprime.sh
Created November 15, 2016 09:53
mprime / prime95 for linux
mkdir mprime
pushd mprime
wget http://www.mersenne.org/ftp_root/gimps/p95v2810.linux64.tar.gz
tar zxfv p95v2810.linux64.tar.gz
popd
./mprime/mprime -m
@tomfanning
tomfanning / resolve-mongodb-warnings.sh
Last active December 11, 2016 20:24
Fix mongodb startup warnings on RHEL
# run once
sed -i -e '/^readahead=/s/^.*$/readahead=32/' /usr/lib/tuned/throughput-performance/tuned.conf
echo "mongod soft nproc 64000" > /etc/security/limits.d/90-nproc.conf
echo '#!/bin/sh -e
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled' > /usr/local/sbin/mongodb-prep.sh
chmod +x /usr/local/sbin/mongodb-prep.sh
echo '[Unit]
Description=mongodb prep
Before=mongod.service
@tomfanning
tomfanning / relocate-pg-data-to-compressed-zfs-vol.sh
Last active January 18, 2017 15:16
Script to relocate postgres 9.5 data dir on Ubuntu 14.04 to a compressed ZFS volume (single disk, /dev/sdb, assumed to be blank)
#!/bin/bash -e
# Script to relocate postgres 9.5 data dir on Ubuntu 14.04 to a compressed ZFS volume (single disk, /dev/sdb, assumed to be blank)
# install ZFS and tools
apt-get install software-properties-common rsync -y
echo "
" | add-apt-repository ppa:zfs-native/stable
apt-get update
apt-get install ubuntu-zfs -y
@tomfanning
tomfanning / test.sh
Created February 21, 2017 00:21
rtl_fm sox ices2 direwolf icecast experiments
rtl_fm -f 144800000 -p 42 - | sox --buffer 128 -t raw -r 24k -es -b 16 -c 1 > /root/144800.wav
rtl_fm -f 144800000 -p 42 - | sox --buffer 128 -t raw -r 24k -es -b 16 -c 1 - -t wav -r 24k - > /root/144800.wav
rtl_fm -f 144800000 -p 42 - | tee /root/144800.raw | sox --buffer 128 -t raw -r 24k -es -b 16 -c 1 - -t wav -r 24k - > /root/144800.wav
rtl_fm -f 144800000 -p 42 - | tee <(direwolf -t 0 -c /root/direwolf.conf -r 24000 -D 1 -q d > /tmp/dw.log) | sox --buffer 128 -t raw -r 24k -es -b 16 -c 1 - -t wav -r 24k - > /root/144800.wav
@tomfanning
tomfanning / kiss-test.cs
Last active April 14, 2017 21:59
Minimal C# .NET implementation of a position-reporting APRS client for a serial KISS TNC (tested with Mobilinkd)
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO.Ports;
using System.Text;
namespace kiss_test
{
class Program
{
@tomfanning
tomfanning / repeater-controller.ino
Created May 5, 2017 12:53
Trivial crossband repeater controller
/*
* Trivial crossband repeater controller
* Yaesu FT-1500m to Baofeng with carrier detect pin brought out
*
* 1k resistor to NPN transistor base on D5 and D6
* Baofeng PTT pin to D5 transistor collector
* Yaesu data port PTT pin to D6 transistor collector
* FT-1500m data port SQL line to A0
* Baofeng CD line to A1
*
@tomfanning
tomfanning / obj-diff.cs
Created June 20, 2017 08:53
C# reflection-based object diff
public class Compared
{
public object Left { get; set; }
public object Right { get; set; }
}
public static System.Collections.Generic.Dictionary<string, Compared> Diff(object o1, object o2)
{
var result = new System.Collections.Generic.Dictionary<string, Compared>(StringComparer.Ordinal);
@tomfanning
tomfanning / gist:b7e90c92442fb9ee6bd41956737f2831
Created July 24, 2017 15:39
Linux command to drill down and find disk space
du -ch -d 1 | sort -hr