Skip to content

Instantly share code, notes, and snippets.

View xfbs's full-sized avatar
👋

Patrick Elsen xfbs

👋
View GitHub Profile
@xfbs
xfbs / dedyn.sh
Created December 25, 2020 19:12
Dedyn.io Update Script
#!/bin/bash
# Script by Patrick M. Elsen <[email protected]>
# 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 / 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 / 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 / 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>
@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 / solve.ml
Created January 25, 2018 08:44
solver for https://projecteuler.net/problem=74 — except that it doesn't quite work
let factorials max =
let rec next_factorial cur =
match cur with
| 0 -> [1]
| _ ->
match next_factorial (cur - 1) with
| prev :: rest -> cur * prev :: prev :: rest
| _ -> []
in
next_factorial max |> List.rev
@xfbs
xfbs / prime.rs
Created January 17, 2018 13:27
rust prime generator
use std::vec::Vec;
pub struct Prime {
list: Vec<u64>
}
impl Prime {
pub fn new() -> Self {
Prime {
list: vec![2, 3]