Skip to content

Instantly share code, notes, and snippets.

Avatar

Isaac Garzón iscgar

View GitHub Profile
@iscgar
iscgar / fizz4.c
Last active Nov 13, 2020
Hand-rolled FizzBuzz, with reduced arithmetic (thanks, clang!)
View fizz4.c
#ifdef _WIN32
# include <Windows.h>
typedef HANDLE out_handle_t;
#else
# include <unistd.h>
typedef int out_handle_t;
#endif
#ifdef _MSC_VER
# include <string.h>
@iscgar
iscgar / fizz3.c
Last active Nov 9, 2020
Hand-rolled, compiler copy FIzzBuzz (thanks, Gal!)
View fizz3.c
#include <string.h>
#include <unistd.h>
#define CACHELINE 64
#define ALIGNED_BUF 65536
#define FIZZ "Fizz"
#define BUZZ "Buzz"
#define DELIM " "
typedef struct {
@iscgar
iscgar / fizz2.c
Created Nov 9, 2020
Hand-rolled FizzBuzz redux (thanks, Itai!)
View fizz2.c
#include <string.h>
#include <unistd.h>
#define CACHELINE 64
#define ALIGNED_BUF 65536
#define DELIM " "
typedef struct {
unsigned short offset;
char data[CACHELINE - sizeof(unsigned short)];
@iscgar
iscgar / fizz.c
Last active Nov 9, 2020
Hand-rolled FizzBuzz
View fizz.c
#include <string.h>
#include <unistd.h>
#define ALIGNED_BUF 65536
#define DELIM ' '
#define MAX_DIGITS 20 /* 64-bit */
typedef unsigned int fizz_t;
__attribute__((always_inline))
@iscgar
iscgar / fizzbuzz.c
Last active Aug 15, 2020
Embedded Software Engineer Solves FizzBuzz
View fizzbuzz.c
#include <stdio.h>
enum
{
FIZZ = 1,
BUZZ = 2
};
static int get_natural(const char *val, unsigned int *out)
{
View foo.py
from __future__ import print_function
import os
import requests
from datetime import datetime
def _format_size(s):
SIZES = ('B', 'KiB', 'MiB', 'GiB')
f = 0
s = float(s)
while s > 1024:
@iscgar
iscgar / realbasic-overlay-resolve.py
Created Sep 26, 2018
REALbasic (Xojo) Reverse-Engineering Helper Script
View realbasic-overlay-resolve.py
# IDA REALbasic reverse engineering helper script
# It seems that every version of REALbasic (Xojo) the loader
# has a different behaviour (especially with regard to parsing
# the imports table), so I'm documenting here that this script
# was created based on a 2009r5 executable.
# iscgar, 2018-09-26
#
# Based on the REALbasic OVERLAY resolver
# XpoZed @ http://nullsecurity.org, 2017-07-16
# http://www.nullsecurity.org/article/reverse_engineering_realbasic_applications
@iscgar
iscgar / murmur_hash3_constexpr.cpp
Created Jul 6, 2018
A C++11 constexpr implementation of 32-bit MurmurHash3
View murmur_hash3_constexpr.cpp
#include <stddef.h>
#include <stdint.h>
#include <limits>
#include <type_traits>
namespace detail
{
template<size_t R, class T>
static inline constexpr T rotl(const T v)
{
@iscgar
iscgar / rustup-mirror.py
Created Jun 22, 2018
Quick and dirty Rust ditribution (rustup) mirror script (prints are now messed up due to added parallelism)
View rustup-mirror.py
from __future__ import print_function
import os
import sys
import re
from datetime import datetime, timedelta
import pickle
from multiprocessing import cpu_count
from multiprocessing.dummy import Pool as ThreadPool
import toml
import requests
@iscgar
iscgar / is_compatible.hpp
Created Feb 10, 2018
C++ Version of __builtin_types_compatible_p
View is_compatible.hpp
#include <stddef.h>
namespace detail
{
template<class, class> struct is_compatible { enum { value = 0 }; };
template<class T> struct is_compatible<T, T> { enum { value = 1 }; };
template<class T, size_t N> struct is_compatible<T[], T[N]> { enum { value = 1 }; };
template<class T, size_t N> struct is_compatible<T[N], T[]> { enum { value = 1 }; };
You can’t perform that action at this time.