Skip to content

Instantly share code, notes, and snippets.

@easyaspi314
easyaspi314 / tolowersimd.c
Created February 6, 2019 05:52
tolower SIMD implementation
/* Created by easyaspi314.
* Released into the public domain. */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __SSE2__
#include <immintrin.h>
@easyaspi314
easyaspi314 / OvercomplicatedWayToPrintA5x5Square.java
Last active February 9, 2019 04:41
Java assignment to print a 5x5 square
/* filename: OvercomplicatedWayToPrintA5x5Square.java */
public class OvercomplicatedWayToPrintA5x5Square {
/*
* An abstract class representing a shape that can be printed to the console.
*/
private static abstract class Shape {
/*
* Prints the contents of the shape to the console.
*/
public abstract void printToConsole();
@easyaspi314
easyaspi314 / README.md
Last active February 25, 2019 08:03
C+: Another Better C

C+: Another Better C

C+ is like halfway between C11 and C++.

Unlike C++, C+ remains a procedural language, and some things are intentionally left out.

Here are some potential ideas.

First, what will be removed:

@easyaspi314
easyaspi314 / assembler.c
Last active March 8, 2019 21:53
A WIP Thumb-like 8-bit assembly language which interprets C structs
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#if __STDC_VERSION__ >= 201112L
# include <stdnoreturn.h>
#elif defined(__GNUC__)
# define noreturn __attribute__((__noreturn__))
@easyaspi314
easyaspi314 / README.md
Last active March 18, 2019 18:58
gets, but safer thanks to GNU extensions

gets but safer

This is like gets. It is a drop in for gets. It is smarter though.

gets_safe, which is aliased to gets for convenience, takes an optional length argument, but it also uses GCC and Clang's __builtin_object_size builtin to calculate the length.

The length will not always be calculated properly, but for static arrays and malloc'd pointers in the current block with a fixed size (only with optimizations), it will usually pick up on it.

This also has a safety feature: If it can properly calculate the length and the supplied length is larger than the one it calculated, it will be an error. Additionally, when both the optional length parameter are omitted and the length cannot be calculated at compile time, it is an error.

@easyaspi314
easyaspi314 / Product.c
Created April 8, 2019 21:28
Faversaver project in C
#include "Product.h"
#include "ErrorState.h"
#include "iProduct.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static const struct iProductVtable Product_vtable;
@easyaspi314
easyaspi314 / gimpcairo.c
Created May 7, 2019 00:53
gimpcairo.c reformat
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcairo.c
* Copyright (C) 2007 Sven Neumann <sven@gimp.org>
* 2010-2012 Michael Natterer <mitch@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@easyaspi314
easyaspi314 / xxh3-rust.rs
Created July 8, 2019 04:53
xxh3_64bits in Rust
///
/// xxHash - Extremely Fast Hash algorithm
/// Rust implementation of XXH3_64bits
/// Copyright (C) 2019-present, Yann Collet.
///
/// BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
///
/// Redistribution and use in source and binary forms, with or without
/// modification, are permitted provided that the following conditions are
/// met:
@easyaspi314
easyaspi314 / orthodoxc++.md
Created July 18, 2018 19:56 — forked from bkaradzic/orthodoxc++.md
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

@easyaspi314
easyaspi314 / _README.md
Last active May 19, 2021 15:40
iostream.h: cin and cout for C using GCC and C11 extensions

iostream.h

iostream.h (ab?)uses _Generic, __builtin_choose_expr, __typeof__, statement expressions, and recursive variadic macro expansion to create a cin and cout for C11+GCC extension compilers.

Should you use this? Of course not. But it's pretty f***ing cool.

Usage