Skip to content

Instantly share code, notes, and snippets.

View berkus's full-sized avatar
🎯
Practice your desensitization exercises to remain unfazed by enemy atrocities

Berkus Decker berkus

🎯
Practice your desensitization exercises to remain unfazed by enemy atrocities
View GitHub Profile
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active July 14, 2025 04:47
Conventional Commits Cheatsheet
// Capture SIGINT and SIGTERM to perform a clean shutdown
net::signal_set signals(ioc, SIGINT, SIGTERM);
signals.async_wait(
[&](beast::error_code const&, int)
{
// Stop the `io_context`. This will cause `run()`
// to return immediately, eventually destroying the
// `io_context` and all of the sockets in it.
ioc.stop();
});
class utf8_text_view {
const char *text;
size_t bytes_count;
public:
friend class iterator;
class iterator {
const utf8_text_view &parent;
size_t offset;
public:
@rust-play
rust-play / playground.rs
Created August 26, 2018 17:34
Code shared from the Rust Playground
use std::marker::PhantomData;
trait ConnT<T> {
type Res;
fn proc(T) -> Self::Res;
}
struct Conn1;
impl<T> ConnT<T> for Conn1 {
type Res = Result<T, ()>;
Re: Need Help With Jekyll GitHub Project Page and Team Git Workflow
> The simplest solution to this trouble is to remove the leading slash
Hmm....no, that is not simple at all because pages in subdirectories would
require different treatment.
The actual simplest solution would be for GitHub to put the project name in
the domain name instead of the request target. For example, instead of:
@bugaevc
bugaevc / obozrenie-rs.diff
Created August 16, 2018 09:10
gio-rs resources
diff --git a/src/main.rs b/src/main.rs
index ac542de..e40605d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,12 +16,10 @@ use futures_timer::*;
use gio::prelude::*;
use gtk::prelude::*;
use librgs::ServerEntry;
-use static_resources::Resources;
use std::sync::{
@sopvop
sopvop / unique.rs
Created June 18, 2018 15:57
unique global id at compile time
#[derive(PartialEq, PartialOrd, Debug, Clone, Copy)]
pub struct UniqueId(pub u64);
macro_rules! unique {
() => {{
#[allow(missing_copy_implementations)]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
struct __unique_id_tag {};
use core::any::TypeId;
@daniellAlgar
daniellAlgar / Logger.kt
Last active March 28, 2020 10:36
This is a safe way to do logging in your Android apps without running the risk of having Log() statements in your production code. It reduces garbage collection and eliminates the need for a log tag.
package com.?
import android.os.Build
import android.util.Log
import com.varvet.shipgaz.BuildConfig
import java.util.regex.Pattern
/**
* A logger to avoid logging in production. It will check if [BuildConfig.DEBUG] is true or not.
* If true then allow logging, otherwise don't.
@Smertig
Smertig / EnumTraits.h
Last active April 2, 2018 09:32
Simple enum traits implementation for C++17
//
// Created by int3 on 14.02.18.
//
/*
Usage:
enum class Foo : int8_t {
a, b, c
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?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">