Skip to content

Instantly share code, notes, and snippets.

View jamierocks's full-sized avatar

Jamie jamierocks

View GitHub Profile
@ityonemo
ityonemo / test.md
Last active May 1, 2024 15:37
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@comp500
comp500 / fabricserversidemods.md
Last active April 15, 2024 20:13
Useful Fabric server side mods
package com.unascribed.materialpicker;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public enum MaterialColor {
RED("Red",
0xFF_F44336,
@falkreon
falkreon / InvertedNormalRandom.java
Last active August 22, 2017 17:25
Selecting unusually-distributed pseudorandom numbers
/**
* Creates a random number from (-1..1), exclusive, distributed in an inverse-bell-curve fashion. That is, numbers
* closer to -1 or 1 are exponentially more likely to appear than numbers closer to 0.
*/
public static double invertedNormalRandom(Random r) {
/*
* Implementation note: log10 reaches y=0 at x=1, and reaches y=1 at x=10, so it's really important, if we
* want to get good numbers out of it, to feed it numbers in the range of 1..10. So we multiply by 9 and add 1.
*/
double a = Math.log10((r.nextDouble()*9)+1);
@Deamon5550
Deamon5550 / Summary.md
Last active August 14, 2016 17:15
Sponge Event Benchmarking

All Tests were performed with 20 warmup iterations of 10000 cycles and 40 benchmarking iterations of 50000 cycles. Times are all in milliseconds.

These arguments were choosen such that the GC pauses would be long, but infrequent. VM arguments: -verbose:gc -Xbatch -XX:CICompilerCount=1 -XX:-TieredCompilation -Xmx10G -Xms10G -XX:+UseG1GC -XX:MaxGCPauseMillis=500 -XX:InitiatingHeapOccupancyPercent=80

Guava:

@Byteflux
Byteflux / ip2asn.php
Last active September 24, 2021 03:40
<?php
// ip2asn.php?ip=IP_OR_HOSTNAME : Returns a comma-separated list of matching ASNs
// ip2asn.php?asn=AS_NUMBER : Returns the organization name
// ip2asn.php?update=1&token=SECRET_TOKEN : Updates the local database (setup cron to run once a day)
$SECRET_TOKEN = 'ChangeMe';
$TMP_DIR = '/tmp/ip2asn';
$DATA_DIR = '/var/lib/ip2asn';
@matthewprenger
matthewprenger / 01-mapping_update_instructions.txt
Last active December 18, 2019 16:16
Place the new methods.csv and fields.csv in the root of your project (TEMPORARILY, Don't commit these to git!) and add this to the end of your build.gradle and run 'gradle updateMappings`. Updated sources will be placed in src_remapped/main/java. You should do a diff to ensure that they are correct and then replace src/main/java with them.
Important note: Your code must compile on the old mappings, and the obfSourceJar must be enabled (it is by default)
1. Download a copy of the new methods.csv and fields.csv from http://export.mcpbot.bspk.rs/ to the root of your project.
2. Add the following gradle script to your build.gradle.
3. Run 'gradle(w) updateMappings'.
4. Do a diff between src/main/java/ and src_remapped/main/java/ to make sure everything looks right.
5. replace src/main/java/* with src_remapped/main/java/*
@unascribed
unascribed / BrokenHash.java
Last active March 28, 2024 16:10
How to generate a (correct) Minecraft-style hex digest. Tested.
package com.unascribed.brokenhash;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.nio.charset.StandardCharsets;
/**
* Generates a broken Minecraft-style twos-complement signed
@bkaradzic
bkaradzic / orthodoxc++.md
Last active April 23, 2024 13:59
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++?

@Vazkii
Vazkii / LiMI.java
Created December 7, 2015 00:01
LiMI - Lightweight Mod Indicator
package vazkii.limi;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;