Skip to content

Instantly share code, notes, and snippets.

#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main(int argc, char* argv[])
{
Display* display = XOpenDisplay(NULL);
XVisualInfo vinfo;
XMatchVisualInfo(display, DefaultScreen(display), 32, TrueColor, &vinfo);
@m13253
m13253 / bird-dn42-util.conf
Last active November 5, 2022 05:32
BIRD 2.0 utility for DN42 related operations
# BIRD 2.0 utility for DN42 related operations
# To be used with:
# include "bird-dn42-util.conf";
# in bird.conf main configuration file.
function reset_origin (int transit; int origin)
{
bgp_path.empty;
bgp_path.prepend(origin);
bgp_path.prepend(transit);
@m13253
m13253 / init.sh
Last active February 19, 2024 11:31
Minimal working initramfs for BusyBox, with login
#!/bin/busybox sh
# 1) Download a prebuilt BusyBox binary here:
# https://busybox.net/downloads/binaries/
#
# 2) Prepare your kernel
# cp /boot/vmlinuz vmlinuz
#
# 3) Copy the files
# install -Dm0755 busybox-x86_64 initramfs/bin/busybox
package main
import (
"log"
"github.com/miekg/dns"
)
func main() {
err := dns.ListenAndServe(":5533", "udp", dns.HandlerFunc(handler))
if err != nil {
@m13253
m13253 / TagCloud.pde
Created May 20, 2017 15:38
Program to draw a rotating tag cloud, using Processing schetchbook
/*
TagCloud.pde
Copyright (C) 2017 StarBrilliant <m13253@hotmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@m13253
m13253 / conver.pe
Created April 28, 2017 09:39 — forked from endel/conver.pe
FontForge script to convert .ttf file to its webfont variations (.otf, .svg, .woff, .woff2)
#!/usr/local/bin/fontforge
Open($1)
Generate($1:r + ".otf")
Generate($1:r + ".svg")
Generate($1:r + ".woff")
Generate($1:r + ".woff2")
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <queue>
#include <unistd.h>
#include <utility>
#include <vector>
@m13253
m13253 / HorseTraverse.c
Last active July 24, 2019 08:38
DFS demo: horse traverse the whole chessboard
#include <stdio.h>
#include <unistd.h>
static const int OFFSETS[8][2] = {
{-1, -2}, {-2, -1}, {-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}
};
static void print_board(int const board[8][8], long solution_num) {
fputs("\033[10A\033[2K", stdout);
if(solution_num != 0) {
@m13253
m13253 / PolyAdder.cc
Last active July 24, 2019 08:38
C++ program to add two polynomials in forms like "4x^3+3x^2+2x+1"
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <utility>
template <typename T>
class List {
@m13253
m13253 / upower-Add-a-critical-action-Ignore.patch
Created October 5, 2016 14:19
A patch for UPower to disable low battery action
From 1ba6e724dabf3a91e59b871750e22d420a4b1238 Mon Sep 17 00:00:00 2001
From: Star Brilliant <m13253@hotmail.com>
Date: Wed, 5 Oct 2016 22:02:36 +0800
Subject: [PATCH] Add a critical action: Ignore
---
etc/UPower.conf | 3 ++-
src/linux/up-backend.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)