Skip to content

Instantly share code, notes, and snippets.

@phako
phako / gist:96b36b5070beaf7eee27
Last active December 27, 2021 13:07
Hexdump a memory buffer in vala with address and printable dump
void hexdump (uint8[] data) {
var builder = new StringBuilder.sized (16);
var i = 0;
foreach (var c in data) {
if (i % 16 == 0) {
print ("%08x | ", i);
}
i++;
print ("%02x ", c);
@phako
phako / gist:5769beecec3c8f73ccfcb00312a41de0
Created May 18, 2017 07:06
Github PR handling aliases
[alias]
pr-fetch = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1; }; f"
pr = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
pr-merge = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git merge pr/$1 --no-ff --edit -m 'Merge pull request #'$1; }; f"
pr-clean = "!git for-each-ref refs/heads/pr/* --format=\"%(refname)\" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
@phako
phako / init.vim
Last active May 27, 2019 08:44
Portable vimrc
if &compatible
set nocompatible
endif
set runtimepath+=~/.vim/bundle/repos/github.com/Shougo/dein.vim
if dein#load_state('~/.vim/dein/plugins')
call dein#begin('~/.vim/dein/plugins')
call dein#add('~/.vim/bundle/repos/github.com/Shougo/dein.vim')
@phako
phako / fritzbox-hack.patch
Created September 7, 2017 19:08
Tr-064 hack fritzbox/gupnp-tools
diff --git a/src/universal-cp/main.c b/src/universal-cp/main.c
index 8e78b0b..80e3c0c 100644
--- a/src/universal-cp/main.c
+++ b/src/universal-cp/main.c
@@ -25,6 +25,7 @@
#endif
#include <libgupnp/gupnp.h>
+#include <libsoup/soup.h>
#include "gui.h"
@phako
phako / jsoncppgvariant.cpp
Last active October 16, 2017 11:04
Convert between JSON and GVariant using JSONCPP
/*
Example code for using jsoncpp and gio to convert JSON<->GVariant
MIT License
Copyright (C) 2017 Jens Georg <mail@jensge.org>
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
grep "\\bg_\\w\\+\\b" -hiro ~/Source/GNOME/rygel/build | sort | uniq | while read i; do grep \\b$i\\b -rol api-index | grep -v api-index-full ; done | sort | uniq
@phako
phako / scanner.py
Created June 18, 2020 07:32
contact tracing beacon scanner
import signal
import os
import time
from beacontools import BeaconScanner
from beacontools.scanner import Monitor
from beacontools.utils import is_packet_type, is_one_of, to_int, bin_to_int, get_mode, bt_addr_to_string, data_to_hexstring
from beacontools.const import *
class MyMonitor(Monitor):
def run(self):
# Installieren des installers
WINEPREFIX=$HOME/tmp/tso wine ~/Downloads/The\ Settlers\ Online\ Installer\ RC1.exe
WINEPREFIX=$HOME/tmp/tso winecfg
Libaries -> New override -> dnsapi (builtin, native)
Damit das Klicken auf den Button funktioniert
in ~/.local/share/applications tso-testing.desktop anlegen mit
use std::collections::VecDeque;
use std::env;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::io::{Error, ErrorKind};
use std::path::Path;
fn help() {
println!("Usage: decrypt <in> <key> <out>");