Skip to content

Instantly share code, notes, and snippets.

View xfbs's full-sized avatar
👋

Patrick Elsen xfbs

👋
View GitHub Profile
@xfbs
xfbs / binary.rb
Created March 15, 2013 13:39
Ruby: convert string to binary form and back (one liners
# not the most efficient way,
# but you get the idea.
str = "meow"
# convert string to binary
bin = str.bytes.map{|d| d.to_s(2)}.map{|b| b.rjust(8, '0')}.join
puts bin
# and convert it back to a string
@xfbs
xfbs / dedyn.sh
Created December 25, 2020 19:12
Dedyn.io Update Script
#!/bin/bash
# Script by Patrick M. Elsen <pelsen@xfbs.net>
# Updates your dedyn.io dynamic DNS, only if your IP address has changed.
# Licensed under MIT license.
# Uses openDNS IP lookup. Ideally, put this script into a cron job and run hourly.
set -euo pipefail
# dns credentials
dnsuser=yourdedyniousername
dnstoken=yourdedyniotoken
@xfbs
xfbs / decrypt.m
Last active September 28, 2022 16:17
Decrypted bash file of macOS malware downloaded from mac-torrents.io
// file: decrypt.m
// "decrypts" a single base64-encoded string from a shitty macos malware.
// compile with: clang -o decrypt -framework Foundation decrypt.m
#import <Foundation/Foundation.h>
#include <stdint.h>
int main (int argc, const char * argv[]) {
//NSString *string = @"TRYEGVoFAQ0HD1sGCg==";
NSString *string = [NSString stringWithUTF8String: argv[1]];
@xfbs
xfbs / dotfiles.sh
Created March 9, 2013 13:33
A script to keep your dotfiles in sync using Dropbox. Basically, this script backs your local dotfiles up and replaces them with links to the ones in your dropbox.
#!/bin/bash
# dotfiles.sh - a tiny script to keep your dotfiles in
# sync by using dropbox
# this should be the name of the folder where you keep
# your dotfiles.
dotfiles_folder="$HOME/Dropbox/Dotfiles"
# these are the dotfiles to be kept in sync
dotfiles="bashrc concyrc hnbrc screenrc gitconfig vimrc ssh/config irssi/config"
@xfbs
xfbs / Makefile
Created November 9, 2019 15:43
setup node and vscode environment
# which APT packages to install
# nodejs
PACKAGES += nodejs
PACKAGES += yarn
PACKAGES += npm
PACKAGES += nodejs-dev node-gyp
# tools (dev)
PACKAGES += git
@xfbs
xfbs / c21.h
Last active June 13, 2019 11:56
22nd century C
#ifndef C21_H
#define C21_H
#include <stdbool.h>
#include <inttypes.h>
typedef int8_t i8;
typedef uint8_t u8;
typedef int16_t i16;
typedef uint16_t u16;
@xfbs
xfbs / Makefile
Last active November 11, 2018 21:41
Program to count identifiers.
CFLAGS += $(shell pkg-config --cflags glib-2.0)
LDFLAGS += $(shell pkg-config --libs glib-2.0)
all: task
@xfbs
xfbs / markd_spec_out.md
Created February 10, 2018 15:42
CommonMark markd output

Example 3 (lines 364-371) Tabs

    a	a
    ὐ	a

--- expected HTML
+++ actual HTML
@@ -1,3 +1,2 @@
-<pre><code>a	a
-ὐ	a

+a a ὐ a

#include <range/v3/all.hpp>
#include <vector>
#include <array>
#include <iostream>
using std::cout;
using std::endl;
using namespace ranges;
auto is_six = [](int i) -> bool { return i == 6; };
@xfbs
xfbs / map_iter.hpp
Created January 26, 2018 22:09
map_iter: (broken) map iterator in C++.
template<class InputIt>
using value_type = typename std::iterator_traits<InputIt>::value_type;
template<class InputIt>
using iterator_category = typename std::iterator_traits<InputIt>::iterator_category;
template<class InputIt>
using difference_type = typename std::iterator_traits<InputIt>::difference_type;
template<class InputIt>