Skip to content

Instantly share code, notes, and snippets.

@skeeto
skeeto / reorder.c
Last active April 17, 2022 15:40
Observe memory reordering
#include <pthread.h>
#include <stdatomic.h>
#include <stdio.h>
#ifndef N
# define N 10000000
#endif
// Spin-lock barrier for two threads. Initialize to zero.
static void
@akihikodaki
akihikodaki / README.en.md
Last active May 11, 2024 02:14
Linux Desktop on Apple Silicon in Practice

Linux Desktop on Apple Silicon in Practice

I bought M1 MacBook Air. It is the fastest computer I have, and I have been a GNOME/GNU/Linux user for long time. It is obvious conclusion that I need practical Linux desktop environment on Apple Silicon.

Fortunately, Linux already works on Apple Silicon/M1. But how practical is it?

  • Two native ports exist.
@manics
manics / README.md
Last active March 18, 2024 23:57
Minio server with the Security Token Service (STS) and AssumeRole for temporary session tokens

MinIO Security Token Service (STS)

This is an example of setting up a Minio server with the Security Token Service (STS) and AssumeRole for temporary session tokens.

You must create a new Minio user to use STS, the default Minio access/secret won't work. The new user must have access to the objects you will be creating sessions for, the permissions of the created session are the intersection of the permissions of the STS user and the inline permissions requested when the session is created

Tested on 2020-04-06 with the current version of Minio. This is probably RELEASE.2020-04-04T05-39-31Z, though if using Homebrew on Mac OSX minio --version outputs DEVELOPMENT.GOGET so who knows.

@mortie
mortie / chrono-cheat-sheet.md
Last active April 30, 2024 15:12
std::chrono cheat sheet for the every-day programmer

Chrono cheat sheet

For the every-day programmer who needs to get shit done instead of fighting type errors.

If your application deals with times in any meaningful way, you should probably want to actually store time_points and durations and what-not; chrono has a pretty rich vocabulary for talking about time-related concepts using the type system. However, sometimes you just need to do something simple, like timing how long something takes, which is where chrono becomes overly complex, hence this cheat sheet.

All examples will assume #include <chrono>.

I just want to time something, then print the result

@AnnoyingTechnology
AnnoyingTechnology / Apple's SuperDrive tweak for use with Linux.md
Last active March 6, 2024 22:53
Make Apple's USB SuperDrive work on Linux

I was ready to throw it away, I opened it up and didn't find anything wrong with it. After a quick Google Search, turns out Apple fucked up their users (again) and locked this drive to only one laptop : the MacBook Air.

Bellow is the tweak (found online) to make it usable on Linux

# Debian/linux only - Linux SCSI generic driver
sudo apt install sg3-utils -y
@dimaryaz
dimaryaz / dropbox_ext4.c
Created August 15, 2018 07:28
Dropbox ext4 hack
/*
* dropbox_ext4.c
*
* Compile like this:
* gcc -shared -fPIC -ldl -o libdropbox_ext4.so dropbox_ext4.c
*
* Run Dropbox like this:
* LD_PRELOAD=./libdropbox_ext4.so ~/.dropbox-dist/dropboxd
*/
anonymous
anonymous / J1_Due_Sim_24
Created April 8, 2017 09:41
A simulator of the J1 Forth CPU - running SIMPL - on an Arduino Due (Atmel ARM M3)
// This is a cross compiler which uses the SIMPL text interpreter framework to compile short phrases of J1
// machine language which are then executed on a simulated J1
// J1_DUE_Sim_24
// This version runs on an Arduino Due - or any of the larger RAM Arduinos
// Ken Boak April 2017
@roxlu
roxlu / Config.cpp
Last active February 18, 2019 21:33
Tiny, fast and clean configuration file parser using rapidxml with example of a to be released streaming video library http://rapidxml.sourceforge.net/
#include <iostream>
#include <fstream>
#include <rapidxml.hpp>
#include "Config.h"
Config::Config() {
}
Config::~Config() {
}
@dsc
dsc / gist:3855240
Created October 8, 2012 21:52
Python argparse Cheatsheet
Arg Name or Optional Flags:
positional : str = "foo"
options : str = "-f", "--foo"
Standard:
action : str = [store], append, store_true, store_false, store_const, append_const, version
default : * = [None]
type : callable = [str], argparse.FileType(mode='wb', bufsize=0)
Exotic:
@nqnwebs
nqnwebs / pre-commit.py
Created June 4, 2012 13:03
pep8 and pyflake as git hook
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
An script to run pep8 and pyflakes via git's pre-commit hook
based on https://github.com/lbolla/dotfiles/blob/master/githooks/pre-commit
modified by Martin Gaitán <mgaitan@machinalis.com>
Install: