Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#===================================================================================
#
# FILE: dump.sh
# USAGE: dump.sh [-i interface] [tcpdump-parameters]
# DESCRIPTION: tcpdump on any interface and add the prefix [Interace:xy] in front of the dump data.
# OPTIONS: same as tcpdump
# REQUIREMENTS: tcpdump, sed, ifconfig, kill, awk, grep, posix regex matching
# BUGS: ---
# FIXED: - In 1.0 The parameter -w would not work without -i parameter as multiple tcpdumps are started.
@thomseddon
thomseddon / gist:3511330
Last active March 8, 2023 03:39
AngularJS byte format filter
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
@thomseddon
thomseddon / bootstrap_cake_pagination.php
Last active November 6, 2020 11:08
Bootstrap style CakePHP pagination
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
));
?>
</p>
<ul class="pagination">
<?php
echo $this->Paginator->prev('&laquo;', array('tag' => 'li', 'escape' => false), '<a href="#">&laquo;</a>', array('class' => 'prev disabled', 'tag' => 'li', 'escape' => false));
@thomseddon
thomseddon / adem
Last active October 21, 2020 08:51
Anydump for ubnt edgemax
#!/bin/sh
#===================================================================================
#
# FILE: dump.sh
# USAGE: dump.sh [-i interface] [tcpdump-parameters]
# DESCRIPTION: tcpdump on any interface and add the prefix [Interace:xy] in front of the dump data.
# OPTIONS: same as tcpdump
# REQUIREMENTS: tcpdump, sed, ifconfig, kill, awk, grep, posix regex matching
# BUGS: ---
# FIXED: - In 1.0 The parameter -w would not work without -i parameter as multiple tcpdumps are started.
@thomseddon
thomseddon / auto-friends-except-acquaintances.js
Created July 24, 2018 09:46
Automatically change privay to friends except acquaintances (run in console on https://www.facebook.com/me/allactivity)
var confirm1 = () => { document.querySelectorAll('.uiLayer:not(.hidden_elem) .uiContextualLayer li')[3].click(); }
var confirm2 = () => { document.querySelectorAll('.uiLayer:not(.hidden_elem) .layerConfirm')[0].click() }
document.querySelectorAll('a[data-tooltip-content="Your friends"]').forEach(function (e, i) { setTimeout(() => { e.click(); setTimeout(confirm1, 1000); setTimeout(confirm2, 2000); }, 3000 * i); })
@thomseddon
thomseddon / mksalt.py
Created February 21, 2018 13:51
crypt mksalt for python 2
import string as _string
from random import SystemRandom as _SystemRandom
_saltchars = _string.ascii_letters + _string.digits + './'
_sr = _SystemRandom()
# SHA512 mksalt extracted from https://github.com/python/cpython/blob/master/Lib/crypt.py
def mksalt():
return '$6$' + ''.join(_sr.choice(_saltchars) for char in range(16))
@thomseddon
thomseddon / gist:4703968
Last active October 21, 2020 08:50
Auto Expanding/Grow textarea directive for AngularJS
/**
* The MIT License (MIT)
*
* Copyright (c) 2013 Thom Seddon
* Copyright (c) 2010 Google
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@thomseddon
thomseddon / gist:4703810
Last active December 27, 2016 02:58 — forked from nobuf/gist:3419910
Supporting placeholder on IE9 with AngularJS (without jQuery) > Removed jQuery dependency > Slight optimisation in retrieving placeholder text
angular.module('test', [])
.directive('placeholder', function($timeout){
var i = document.createElement('input');
if ('placeholder' in i) {
return {}
}
return {
link: function(scope, elm, attrs){
if (attrs.type === 'password') {
return;
@thomseddon
thomseddon / mkcrt.sh
Created December 18, 2013 20:21
SSL walkthrough for nginx
#!/bin/bash
# Copyright 2013-present Thom Seddon
if [ "$1" == "" ]; then
echo "Usage: sudo ./mkcrt <hostname>"
exit 1
fi
if [ "$(id -u)" != "0" ]; then
echo "Must run with sudo"
@thomseddon
thomseddon / git_deploy.sh
Last active December 29, 2015 10:09
Create a git deployment folder on a remote machine
#!/bin/bash
# Read vars
if [ "$1" == "" ]; then
echo "Usage: ./git_deploy <folder> <user?> <post-receive?>"
exit 1
fi
folder=$1
if [ -d "$folder" ]; then