Skip to content

Instantly share code, notes, and snippets.

@0xack13
0xack13 / dock.nix
Created July 11, 2023 02:15 — forked from antifuchs/dock.nix
A nix module that arranges the macOS dock the way you want it. Note: It won't allow you to manually re-arrange the items on it; the dock gets reset everytime you log in.
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.local.dock;
stdenv = pkgs.stdenv;
in
{
options = {
local.dock.enable = mkOption {
description = "Enable dock";
@0xack13
0xack13 / table.c
Created June 28, 2023 01:14 — forked from 1devm0/table.c
A Hash Table in C
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef uint8_t u08;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t i32;
@0xack13
0xack13 / Makefile
Created June 4, 2023 20:31 — forked from mmitou/Makefile
list_head sample
obj-m := listtest.o
INC := /usr/src/kernels/3.4.0-1.fc17.x86_64/include
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
check-syntax:
@0xack13
0xack13 / praytimes.py
Created May 23, 2023 04:24 — forked from Deja-Vu1/praytimes.py
Fix for the python code version 2 of the Pray Times algorithm http://praytimes.org/code/ (Berkin İlkan Seçkin)
#!/usr/bin/env python
# compatible with python 2.x and 3.x
import math
import re
'''
--------------------- Copyright Block ----------------------
praytimes.py: Prayer Times Calculator (ver 2.3)
@0xack13
0xack13 / http_streaming.md
Created May 21, 2023 02:29 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@0xack13
0xack13 / .gitignore
Created May 19, 2023 21:06 — forked from atoponce/.gitignore
Simple Compression Benchmarks
cantrbry.tar
cantrbry.tar.*.*
.*.swp
@0xack13
0xack13 / notarize.md
Created May 10, 2023 17:25 — forked from mitchellh/notarize.md
macOS Catalina (10.15+) Notarization Requirement for Go

macOS 10.15 Catalina requires binaries are notarized to run without annoying additional steps. See the issue here: hashicorp/terraform#23033

These are steps to notarize a direct binary. This does not cover stapling, installers (pkg), etc. This is primarily useful for static binary developers such as Go developers.

Manual Steps

Apple Developer Account

You first need an Apple Developer Account ($99/year). You need to accept all the agreements and stuff.

@0xack13
0xack13 / build-gcc-9.2.0-on-centos7.md
Created April 26, 2023 20:10 — forked from nchaigne/build-gcc-9.2.0-on-centos7.md
Building GCC 9.2.0 on CentOS 7

Building GCC 9.2.0 on CentOS 7

Introduction

CentOS 7 distribution (as well as RHEL 7) ships with a somewhat outdated version of the GCC compiler (4.8.5 on CentOS 7.5), which may not be suitable to your compilation requirements. For example, C11 - which supersedes C99 - is fully supported only starting from GCC 4.9).

Additionally, recent versions of GCC (GCC6, GCC7, GCC8, GCC9) come with improvements which help detect issues at build time and offer suggestions on how to fix them. Sometimes, these are even actually helpful!

This note describes how to build the latest GCC (9.2.0 as of October 2019) from sources on CentOS 7. This should be applicable as is on RHEL 7. For other Linux distributions, adapt as needed.

@0xack13
0xack13 / backpressure-detection.go
Created April 14, 2023 09:47 — forked from garukun/backpressure-detection.go
Go example regarding channels and backpressure
// https://play.golang.org/p/z2eYKhyoIk
package main
import "fmt"
import "time"
import "sync"
// Blocking detection for when pushing on filled buffered channel by using default.
func main() {
ch1 := make(chan int, 2)
@0xack13
0xack13 / backpressure.go
Created April 14, 2023 09:45 — forked from marianogappa/backpressure.go
Example backpressure implementation in Go
/*
This snippet is an example of backpressure implementation in Go.
It doesn't run in Go Playground, because it starts an HTTP Server.
The example starts an HTTP server and sends multiple requests to it. The server starts denying
requests by replying an "X" (i.e. a 502) when its buffered channel reaches capacity.
This is not the same as rate-limiting; you might be interested in https://github.com/juju/ratelimit
or https://godoc.org/golang.org/x/time/rate.