Skip to content

Instantly share code, notes, and snippets.

View cjxgm's full-sized avatar
🐟
Slacking off

Giumo Clanjor (哆啦比猫/兰威举) cjxgm

🐟
Slacking off
View GitHub Profile
@cjxgm
cjxgm / Makefile
Created August 14, 2023 13:04
A simple Makefile-based project template
# A simple Makefile-based project
MAKE_FLAGS += --no-print-directory
CC = gcc
CXX = g++
LD = $(CXX)
ifneq (, $(shell which ccache 2>/dev/null))
CC := ccache $(CC)
CXX := ccache $(CXX)
@cjxgm
cjxgm / README.md
Last active February 11, 2024 16:03
The MessageBox() alternative for Gtk4

Why

You are writing a game in, say GLFW or SDL. Somehow you want to show a fatal error message to the user, preferrably in native style. How?

  • On Windows, you can simply call MessageBox() to show such message.
  • On Linux, you can use the method below.
  • On other platforms, well it's your homework.

How to compile

@cjxgm
cjxgm / remove-gnome-extensions-app.hook
Created May 8, 2020 22:09
Prevent GNOME Shell from checking extension updates, and disable automatic extension updates. Requires GNOME Shell 3.36.1+. Works on Arch Linux.
# Put this into /etc/pacman.d/hooks/
#
# In GNOME Shell 3.36.1 or later versions, if the extensions app (the GUI)
# does not exist, auto updates to extensions will be disabled.
# The check for existence of the extensions app is by checking its .desktop file.
[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = gnome-shell
@cjxgm
cjxgm / userChrome.css
Created May 8, 2020 22:05
Firefox 77+ User Chrome
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* Remove "Close" button on the tabs */
#tabbrowser-tabs .tabbrowser-tab .tab-close-button
{
display: none !important;
}
/* Do not shift up when URL bar is active */
#urlbar[breakout][breakout-extend] {
@cjxgm
cjxgm / README.md
Created November 29, 2019 08:11
Overload Resolution Anomaly

In this program, extract1 has a different output from all the rest. Why is that? Specifically, why extract1 and extract2 have different outputs?

Can be reproduced in GCC, Clang, ICC, ZapCC, EllCC. But it cannot be reproduced in MSVC.

@cjxgm
cjxgm / game.glsl
Last active December 3, 2018 14:59
Play Factorio with more saturated color
#version 120
// path: data/core/graphics/shaders/game.glsl
uniform sampler2D gameview; // "diffuse" texture
uniform sampler2D lightmap;
uniform vec4 darkness_data;
uniform vec4 nv_color;
uniform vec4 nv_desaturation_params;
uniform vec4 nv_light_params;
@cjxgm
cjxgm / template_id.cc
Created June 21, 2018 15:47
Getting typeid of C++ templates
#include <typeinfo>
#include <iostream>
template <template <class...> class T>
auto& template_id()
{
struct id {};
return typeid(id);
}
@cjxgm
cjxgm / rust-wasm-archlinux.md
Last active February 23, 2021 05:21
Rust + WebAssembly Guide, on Arch Linux

Rust + WebAssembly Guide, on Arch Linux

Motivation

It's just too complex to make Rust+WASM work on macOS, but all the other guides online target macOS. This guide targets only Arch Linux. If your favorate distro is great, you should be able to do the same thing.

Setup

Install rustup and emscripten with the distro's native package manager.

@cjxgm
cjxgm / avl.cc
Last active March 3, 2017 07:56
AVL Tree Implementation with 3+4 Reshaping
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#ifdef _NDEBUG
# define DDD(X...)
#else
# define DDD(X...) X
#endif
@cjxgm
cjxgm / spfa.cc
Created March 2, 2017 17:02
SPFA Shortest Paths
// ml:std = c++11
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
static int costs[512];
static int weights[512][512];
static int nvert;
static constexpr auto inf = 1000000;