Skip to content

Instantly share code, notes, and snippets.

View ashafq's full-sized avatar

Ayan Shafqat ashafq

View GitHub Profile
/*
* Copyright (C) 2020 Ayan Shafqat <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <immintrin.h>
static void mat8x8mul(float *dst, const float *src_a, const float *src_b)
{
// Load 8 rows of B into 8 YMM registers
__m256 b0 = _mm256_load_ps(src_b + (0 * 8));
__m256 b1 = _mm256_load_ps(src_b + (1 * 8));
__m256 b2 = _mm256_load_ps(src_b + (2 * 8));
__m256 b3 = _mm256_load_ps(src_b + (3 * 8));
__m256 b4 = _mm256_load_ps(src_b + (4 * 8));
@ashafq
ashafq / fizzbuzz.S
Created May 8, 2020 17:23
Fizzbuzz in RV32IM assembly
//
// FizzBuzz in RISC-V Assembly
// build: riscv64-elf-gcc -mcmodel=medany -nostdlib \
// -march=rv32im -mabi=ilp32 -o start start.s
// run: Open in Ripes simulator ;)
//
.section .rodata
// Strings need to be aliged to two byte boundaries
/**
* @brief A shitty password generator in C++
*/
//
// It's 2019, yet no command line parsers in C++ :'(
//
#include <boost/program_options.hpp>
namespace opt = boost::program_options;
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#!/usr/bin/env python2
"""Display a rainbow color gradiant"""
from __future__ import print_function
from collections import namedtuple
__activity_ctx = 0.0
Color = namedtuple("Color", ["red", "green", "blue"])
def rainbow(seed=0, frequency=0.01):
"""Return a color"""
@ashafq
ashafq / main.c
Last active October 27, 2023 15:51
/*
* This work is released under the Creative Commons CC0 1.0 Universal License.
*
* Must compile with GCC for x86_64 target:
* gcc -fno-pie -fno-stack-protector -o hello hello.c && ./hello
*
* Last tested: 2023-10-27, on gcc-13.2
* https://godbolt.org/z/o8o97Pjca
*/
@ashafq
ashafq / rdtsc.rs
Last active April 5, 2018 22:03
Works on rustc 1.27.0-nightly (fb44b4c0e 2018-04-04)
#![feature(asm)]
fn rdtsc() -> u64 {
let eax: u32;
let edx: u32;
unsafe {
asm!("rdtsc; ": /* Assembly */
"={eax}"(eax), "={edx}"(edx) : /* Output registers */
: /* Input registers */
@ashafq
ashafq / l33t.py
Last active June 30, 2017 12:49
1337 §p€@k
__module_name__ = "Hexchat L33T"
__module_version__ = "1.0"
__module_description__ = "Do you speak l33t? No? Well, now you can with /l33t"
__author__ = "ashafq"
import hexchat
import random
def l33t_enc(string):
/*
* Copyright (C) 2019-2025 Ayan Shafqat <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of