Skip to content

Instantly share code, notes, and snippets.

View Qyriad's full-sized avatar

Qyriad Qyriad

View GitHub Profile
@georgebrock
georgebrock / Info.plist
Last active June 26, 2026 09:52
AppleScript to handle URLs
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- ... -->
<!-- Add this section: -->
<key>CFBundleURLTypes</key>
<array>
<dict>
@eatnumber1
eatnumber1 / renameat2.c
Last active December 5, 2025 08:49
Command-line tool to call renameat2(2)
/*
* Copyright (c) 2023 Russell Harmon
*
* 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
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@ktemkin
ktemkin / fizzbuzz.c
Last active April 17, 2024 04:16
As a snark: fizzbuzz as a kernel module. (for extra snark credit: mknod /dev/fizzbuzz1 c <major> 0)
/**
* This is all your fault, Baljem.
*/
#include <linux/version.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/types.h>
@wisq
wisq / gist:0fa021df52a3bd2485ac
Last active April 25, 2024 10:22
Protip: Bisecting a single commit

Situation: Some commit (on master, but not necessarily head of master) has broken things, but it's a big commit and it's not clear what part broke things.

% git checkout master
% git checkout -b bisect-branch
% git revert <offending commit>

(test here to make sure reverting fixed your problem)

% git bisect start
@odarbelaeze
odarbelaeze / gist:5867459
Created June 26, 2013 13:43
Using std::copy to cast between container types with c++11.
#include <algorithm>
#include <iostream>
#include <valarray>
#include <vector>
template<typename T>
std::ostream& operator<< (std::ostream& os, std::valarray<T> va)
{
for (auto&& i : va)
os << i << " ";
@dabrahams
dabrahams / private_access.cpp
Created December 28, 2011 17:50
Accessing Private Data
#include <iostream>
// This is a rewrite and analysis of the technique in this article:
// http://bloglitb.blogspot.com/2010/07/access-to-private-members-thats-easy.html
// ------- Framework -------
// The little library required to work this magic
// Generate a static data member of type Tag::type in which to store
// the address of a private member. It is crucial that Tag does not
@jamescasbon
jamescasbon / template.py
Created December 11, 2011 16:37
Pure python templates using with statement
"""
A really stupid python template language inspired by coffeekup, markaby.
Do not use this code, it will ruin your day. A byproduct of insomnia.
TL;DR
-----
This module defines a template language that allows us to do:
d = Doc()