Skip to content

Instantly share code, notes, and snippets.

View uplime's full-sized avatar
👻
Spooky

Nick Chambers uplime

👻
Spooky
View GitHub Profile
--
-- Steps taken to solve https://mystery.knightlab.com/
--
SELECT description
FROM crime_scene_report
WHERE type = "murder"
AND city = "SQL City"
AND date = 20180115
;
@uplime
uplime / vers.rb
Created June 12, 2026 16:31
Sort version numbers in ascending order.
#!/usr/bin/env ruby
def sort_ver(vers)
vers.sort do |v1, v2|
v1_info = v1.split(?.).map &:to_i
v2_info = v2.split(?.).map &:to_i
ord_found = 0
while ord_found.zero? and not v1_info.empty? and not v2_info.empty?
ord_found = v2_info.first <=> v1_info.first
@uplime
uplime / words.rb
Created June 12, 2026 16:34
Find all words that match a set of letters.
#!/usr/bin/env ruby
WORDS = File.open("/usr/share/dict/words", &:read).lines.map do |word|
word.strip.downcase
end.freeze
def word?(word)
WORDS.include? word.downcase
end
@uplime
uplime / commas.pl
Created June 12, 2026 16:41
Comma-ize any number bigger than 999.
#!/usr/bin/env perl
foreach $arg (0..$#ARGV) {
my $num = int($ARGV[$arg]);
my $fmt = "", $cnt = 0;
while($num > 0) {
$fmt = ($num % 10) . $fmt;
if(++$cnt % 3 == 0 and $num >= 10) {
@uplime
uplime / linksmith.go
Created June 12, 2026 16:52
Find missing links in an X.509 certificate chain.
package main
import (
"crypto/x509"
_ "embed"
"encoding/base64"
"errors"
"flag"
"fmt"
"io"
@uplime
uplime / hexdump.py
Created June 12, 2026 16:57
Display an input as all hexidecimal values.
import sys
def padlen(number):
return ((16 - (number % 16)) * 3) + 1 + int(number % 16 < 8)
def hexdump(data):
printed = []
print(f"{0:08x}", end=" ")
@uplime
uplime / number-words.py
Created June 12, 2026 16:58
Convert digital numbers to English words.
import collections
import sys
DIGITS = {
"1": ["one", "ten", "eleven"],
"2": ["two", "twenty", "twelve"],
"3": ["three", "thirty", "thirteen"],
"4": ["four", "forty", "fourteen"],
"5": ["five", "fifty", "fifteen"],
"6": ["six", "sixty", "sixteen"],
@uplime
uplime / sherver.c
Created June 12, 2026 17:03
Application protocol servers written in Bash, using a C-based socket backend.
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <loadables.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <sys/socket.h>
@uplime
uplime / unique.c
Created June 12, 2026 17:04
Determine if a string has any duplicate characters.
// not uniq(1)
#include <stdint.h>
#include <stdio.h>
#include <ctype.h>
const char *unique(const char *str, const char **dup) {
const char *alphabet[26] = { NULL };
for(; *str; str += 1) {
@uplime
uplime / sha256.c
Created June 12, 2026 17:17
A sample SHA256 implementation, just to say I wrote one.
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static uint64_t pad_length(uint64_t len) {
uint64_t space_needed = 1;
while(((len + space_needed) % 64) != 56) {