Skip to content

Instantly share code, notes, and snippets.

@lion328
lion328 / grade_bench.c
Last active June 3, 2018 12:08
Grading program benchmark
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <float.h>
#include <windows.h>
#define GRADE_BENCHMARK_EMULATE_IO false
#define GRADE_RUN_COUNT 50
#define GRADE_BENCHMARK_COUNT 10000000
@lion328
lion328 / grade.c
Last active June 1, 2018 12:54
Branchless Grading
#include <stdio.h>
#include <stdint.h>
int main()
{
uint8_t buf[4] = {0};
fgets(buf, sizeof(buf), stdin);
int32_t i = (buf[2] << 8) | (buf[0]);
@lion328
lion328 / auth.php
Created September 25, 2016 08:26
Simple AuthMe login API
<?php
// ---- CONFIGURATION -------------------------------
define('DB_HOST', '127.0.0.1');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'minecraft');
define('DB_TABLE', 'authme');
@lion328
lion328 / second.c
Last active August 18, 2016 12:58
Programming competition
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
char buffer[1024];
unsigned int lenBuffer[512], lenBufferSize = 0, i, j, k;
fgets(buffer, 1024, stdin);
char c;
for(i = 0, j = 0; i < 1024; i++, j++) {
if(buffer[i] == 0) break;
@lion328
lion328 / thaitext.c
Last active February 9, 2016 12:35
Thai character render on IPST Microbox SE
//#include <ipst.h>
#define IPST_SCREEN_WIDTH 128
#define IPST_SCREEN_HEIGHT 160
const int GLCD_BLACK = 0;
const int GLCD_WHITE = 1;
const int GLCD_YELLOW = 2;
const int GLCD_RED = 3;
@lion328
lion328 / ThaiFixesUtils.java
Created May 1, 2015 13:56
ThaiFixes 1.8.4 (Vanilla mod) Source code
/*
* Copyright (c) 2014-2015 Waritnan Sookbuntherng
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@lion328
lion328 / Main.java
Created March 24, 2015 19:34
mclauncher
package com.lion328.mclauncher;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.lion328.libmclauncher.gamelaunch.json.JSONGameLaunch;
import com.lion328.libmclauncher.utils.MinecraftUtil;
<?
//Config --
$Cfg['dir']['skin'] = 'skin/';
$Cfg['dir']['cloak'] = 'cloak/';
$url['global']['skin'] = 'http://s3.amazonaws.com/MinecraftSkins/';
$url['global']['cloak'] = 'http://s3.amazonaws.com/MinecraftCloaks/';
//-- Config
$url['home']['skin'] = NULL;
@lion328
lion328 / natty_encrypt.c
Last active August 29, 2015 14:17
Natty
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void natty_encrypt(char *in, char *out) {
for(int i = 0; in[i]; i++) out[i] = in[i] + i;
}
void natty_decrypt(char *in, char *out) {
for(int i = 0; in[i]; i++) out[i] = in[i] - i;
@lion328
lion328 / gist:00e174cb4f4fdbecc9f2
Last active August 29, 2015 14:09
NCN CUR reader
public static int[] readNcnCur(File f) throws IOException {
DataInputStream in = new DataInputStream(new FileInputStream(f));
int[] out = new int[(int)Math.ceil(f.length() / 2)];
int i = 0;
while(in.available() > 0) {
int temp = in.readUnsignedByte();
int byte2 = in.readUnsignedByte();
if(byte2 != 255) {
temp += byte2 << 8;
out[i++] = temp;