Skip to content

Instantly share code, notes, and snippets.

View bitsmanent's full-sized avatar

Claudio Alessi bitsmanent

  • Italy
View GitHub Profile
@bitsmanent
bitsmanent / msleep.c
Last active December 21, 2022 11:38
Sleep for a specified number of milliseconds
int
msleep(int ms) {
struct timespec req = {0}, rem;
int r = ms / 1000;
if(r >= 1) {
req.tv_sec = r;
ms -= r * 1000;
}
if(ms)
@aileftech
aileftech / hex-colors.txt
Created October 1, 2022 18:10
A Bash one-liner to produce a list of HEX color codes that read like (supposedly) valid English words
$ grep -P "^[ABCDEFabcdefOoIi]{6,6}$" /usr/share/dict/words | tr 'OoIi' '0011' | tr '[:lower:]' '[:upper:]' | awk '{print "#" $0}'
#ACAD1A
#B0BB1E
#DEBB1E
#AB1DED
#ACAC1A
#ACCEDE
#AC1D1C
#BAB1ED
#BA0BAB
@bitsmanent
bitsmanent / react-native-sprite-sheets.js
Last active September 25, 2021 17:18
Simple sprite sheets for React Native
import React from "react";
import {ImageBackground} from "react-native";
export function Sprite(props) {
const [w, h] = [props.geometry.width, props.geometry.height];
const r = Math.min(w / (props.width / props.cols), h / (props.height / props.rows));
return (
<ImageBackground
source={props.source}
@lmillucci
lmillucci / greenpass.js
Created June 29, 2021 12:08
Simple green pass decoder in JavaScript
/**
* Simple green pass decoder inspired by https://git.gir.st/greenpass.git/blob_plain/master:/greenpass.py
*
* 2021 Lorenzo Millucci
*
* Before usage install following dependecies `npm install base45 cbor jpeg-js jsqr pako`
*/
const base45 = require('base45');
const cbor = require('cbor');
@shakna-israel
shakna-israel / LetsDestroyC.md
Created January 30, 2020 03:50
Let's Destroy C

Let's Destroy C

I have a pet project I work on, every now and then. CNoEvil.

The concept is simple enough.

What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?


@zazapeta
zazapeta / auth.js
Created November 23, 2019 10:43
Password hashing/verifying in node.js using 'pbkdf2'
const crypto = require("crypto");
// larger numbers mean better security
const config = {
// size of the generated hash
hashBytes: 32,
// larger salt means hashed passwords are more resistant to rainbow table, but
// you get diminishing returns pretty fast
saltBytes: 16,
// more iterations means an attacker has to take longer to brute force an
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active May 1, 2026 19:17
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}

Bash tips: Colors and formatting (ANSI/VT100 Control sequences)

The ANSI/VT100 terminals and terminal emulators are not just able to display black and white text ; they can display colors and formatted texts thanks to escape sequences. Those sequences are composed of the Escape character (often represented by “^[” or “<Esc>”) followed by some other characters: “<Esc>[FormatCodem”.

In Bash, the <Esc> character can be obtained with the following syntaxes:

  • `\e`
@Jessidhia
Jessidhia / react-scheduler.md
Last active June 11, 2024 10:48
Implementation notes on react's scheduling model as of (shortly before) 16.8.0

Implementation notes on react's scheduling model as of (shortly before) 16.8.0

While the public API intended for users to use is the scheduler package, the reconciler currently does not use scheduler's priority classes internally.

ReactFiberScheduler has its own internal "mini-scheduler" that uses the scheduler package indirectly for its deadline-capable scheduleCallback.

This is kind of a documentation of implementation details that I suppose will be gone by the end of the year, but what can you do.

@RabaDabaDoba
RabaDabaDoba / ANSI-color-codes.h
Last active April 8, 2026 16:32 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes working in C!
/*
* This is free and unencumbered software released into the public domain.
*
* For more information, please refer to <https://unlicense.org>
*/
//Regular text
#define BLK "\e[0;30m"
#define RED "\e[0;31m"
#define GRN "\e[0;32m"