Skip to content

Instantly share code, notes, and snippets.

View cchudant's full-sized avatar
🥳
happy

cchudant

🥳
happy
  • Paris, France
  • 04:49 (UTC +02:00)
View GitHub Profile
@cchudant
cchudant / main.c
Created January 20, 2022 17:42
clang -S -emit-llvm main.c
#include <stdio.h>
int factorial(int n, int p) {
int res = 1;
for (int i = 0; i < p; i++) {
res *= n;
}
return res;
}
@tlively
tlively / j2wasm_application.wat
Created April 20, 2021 19:42
j2wasm_application.wat
This file has been truncated, but you can view the full file.
;;; Code generated by J2WASM
(module
(global $java.lang.Object.rtt (rtt 0 $java.lang.Object) (rtt.canon $java.lang.Object))
(global $TestRunner.rtt (rtt 1 $TestRunner) (rtt.sub $TestRunner (global.get $java.lang.Object.rtt)))
(global $java.beans.Beans.rtt (rtt 1 $java.beans.Beans) (rtt.sub $java.beans.Beans (global.get $java.lang.Object.rtt)))
(global $java.io.Writer.rtt (rtt 1 $java.io.Writer) (rtt.sub $java.io.Writer (global.get $java.lang.Object.rtt)))
(global $java.io.BufferedWriter.rtt (rtt 2 $java.io.BufferedWriter) (rtt.sub $java.io.BufferedWriter (global.get $java.io.Writer.rtt)))
(global $java.io.InputStream.rtt (rtt 1 $java.io.InputStream) (rtt.sub $java.io.InputStream (global.get $java.lang.Object.rtt)))
(global $java.io.ByteArrayInputStream.rtt (rtt 2 $java.io.ByteArrayInputStream) (rtt.sub $java.io.ByteArrayInputStream (global.get $java.io.InputStream.rtt)))
(global $java.io.OutputStream.rtt (rtt 1 $java.io.OutputStream) (rtt.sub $java.io.OutputStream (global.get $java.lang.Object.rtt)))
@LuxXx
LuxXx / bedrock.c
Created August 2, 2020 11:46
2b2t Bedrock Finder by ChromeCrusher
/*
Written by ChromeCrusher for finding bases on 2b2t.org
This program requires you to know a top-level bedrock pattern.
A chunk-aligned 16x16 pattern (a complete chunk) is preferable and is the fastest method, but it can find any smaller pattern too (it just takes longer)
You could technically search for an area larger than 16x16 (up to 48x48), but it will be slower and the chances of finding two identical 16x16 bedrock patterns is basically zero.
An 8x8 pattern is usually enough to uniquely identify a location with a fairly low chance of false positives.
You'll need to know which direction is north. This can be found by looking at the textures of some blocks (cobblestone for example, see http://gaming.stackexchange.com/a/23103)
If you can't find which direction is north, you'll have to search for all 4 rotations of the pattern separately. I did not include a function to do it automatically because I haven't needed it.
import os
from Xlib.display import Display
from Xlib.xobject.drawable import Window
from Xlib.protocol.event import ClientMessage
from Xlib import X
from collections import namedtuple
WindowGeometry = namedtuple('WindowGeometry', 'x y width height')
WindowPosition = namedtuple('WindowPosition', 'x y')
@cchudant
cchudant / 1-sugar.rs
Last active May 9, 2020 15:55
Async await desugar (kind of)
async fn unicorn(arg: i32) {
println!("Hi!");
do_things().await;
println!("Hi x2!");
for i in arg..5 {
let num = do_other_things().await;
println!("Future {} returned {}!", i, num);
}
}
@cchudant
cchudant / cub3d.h
Last active January 7, 2020 10:27
Cub3d / MiniRT save first frame to .BMP file
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cube3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchudant <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/19 15:14:01 by cchudant #+# #+# */
/* Updated: 2019/11/21 15:09:43 by cchudant ### ########.fr */
/* */
#!/bin/bash
URL=https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
INSTALL_SCRIPT=/tmp/Miniconda3-latest-MacOSX-x86_64.sh
INSTALL_DIR=/goinfre/anaconda3
function remove_python {
rm -rf $INSTALL_DIR
sed -i '' "/^export PATH='\/goinfre\/anaconda3\/bin:\$PATH'$/d" ~/.zshrc
echo "Python has been removed."

Usage

Use gcc {your files} main.c -D MINE to compile main.c with your program

Use gcc main.c to compile main.c with libc's implementation

Tests are easy to add, and the TEST macro will display what printf (or ft_printf) returns

Use -D BONUS to test the bonuses

(() => {
const insertScript = src => {
const elem = document.createElement('script')
elem.src = src
document.head.append(elem)
}
const proxy = (original, proxyFn) => function (...args) {
try {
@cchudant
cchudant / nyaa_comments.js
Created August 11, 2019 22:14
Scrap nyaa comments and expose them as an RSS feed
const httpFetch = require('node-fetch')
const { JSDOM } = require('jsdom')
const express = require('express')
const morgan = require('morgan')
const { Feed } = require('feed')
const xmlEscape = require('xml-escape')
const wait = t => new Promise(r => setTimeout(r, t))
const {