Skip to content

Instantly share code, notes, and snippets.

Thomas Hurst Freaky

Block or report user

Report or block Freaky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Freaky
Freaky / Dockerfile
Last active Apr 7, 2019
tarssh Dockerfile
View Dockerfile
FROM rust:1.33-stretch as build
WORKDIR /usr/src/tarssh
# Make a blank project with our deps for Docker to cache.
# We skip rusty-sandbox because it does nothing useful on Linux.
COPY Cargo.toml Cargo.lock .
RUN mkdir -p src \
&& echo 'fn main() { }' >src/main.rs \
&& cargo build --release --no-default-features --features drop_privs
@Freaky
Freaky / tarssh.rs
Last active Mar 26, 2019
Rust ssh tarpit
View tarssh.rs
use std::env;
use std::net::SocketAddr;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::{Duration, Instant};
use exitcode;
use env_logger;
use log::{error, info, warn};
View fast-memchr.c
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#define LO ((uint64_t)0x0101010101010101L)
#define HI ((uint64_t)0x8080808080808080L)
#define LOOP_SIZE (2 * sizeof(uint64_t))
@Freaky
Freaky / readline-prefixed-junk.rb
Created Jan 2, 2019
Print crap before readline
View readline-prefixed-junk.rb
#!/usr/bin/env ruby
require 'readline'
run = true
puts
worker = Thread.new do
i = 0
while run
STDOUT.print("\e[s\r\e[A\e[KMoo moo baa #{i += 1}\n\e[u");
@Freaky
Freaky / vm_superhub.rb
Created Dec 28, 2018
Munin plugin for Virgin Media Superhub
View vm_superhub.rb
#!/usr/local/bin/ruby
Host = '192.168.100.1'
require 'net/http'
require 'timeout'
def get(page)
Timeout.timeout(5) { Net::HTTP.get(Host, page) }
rescue => e
STDERR.puts "GET http://#{Host}/#{page} failure: #{e.class}: #{e.message}"
@Freaky
Freaky / freebsd-update-progress.patch
Last active Dec 13, 2018
Patch to CURRENT freebsd-update to replace the 10....20....30.... progress indicator
View freebsd-update-progress.patch
--- freebsd-update.sh.orig 2018-12-13 16:28:44.343075728 +0000
+++ freebsd-update.sh 2018-12-13 16:44:41.440009430 +0000
@@ -1059,6 +1059,30 @@
# Print user-friendly progress statistics
fetch_progress () {
+ if [ "$1" -gt 0 -a -t 1 ]; then
+ fetch_progress_tty $1
+ else
+ fetch_progress_classic
@Freaky
Freaky / divebar.rb
Last active Dec 6, 2018
Start of yet another progress bar library?
View divebar.rb
# require "divebar/version"
module Divebar
Style = Struct.new(:name, :tick_chars, :progress_chars, :template)
module Styles
Default = Style.new(
"default",
"⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈ ".chars,
"█░".chars,
" %<bar>s %<spinner>s %<pos>d/%<len>d %<msg>s"
View iptest.rb
module IpTest
module V4
MAX_LEN = '255.255.255.255'.size
SEGMENT = /(?:25[0-5]|(?:2[0-4]|1?[0-9])?[0-9])/
PATTERN = /#{SEGMENT}\.#{SEGMENT}\.#{SEGMENT}\.#{SEGMENT}/
PATTERN_ANCHORED = /\A#{PATTERN}\z/
def self.contains?(str)
PATTERN.match?(str)
end
@Freaky
Freaky / email_sucks_completely.rs
Created Sep 3, 2018
Quick and dirty email search index test thing that sucks completely
View email_sucks_completely.rs
/// Email Sucks Completely / Email Search Command
extern crate mailparse;
extern crate tantivy;
extern crate walkdir;
use mailparse::*;
use tantivy::collector::TopCollector;
use tantivy::query::QueryParser;
View check_listen_ports.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative 'ragios'
Listener = Struct.new(:user, :command, :pid, :fd, :proto, :local_addr, :foreign_addr) do
def to_s
"#{user}/#{command} (#{pid}) on #{local_addr}"
end
end
You can’t perform that action at this time.