Skip to content

Instantly share code, notes, and snippets.

bool MoveCharacters()
{
for(auto character : Sys::Characters)
{
double &x = character->position->x;
double &y = character->position->y;
if(Input::inputs[Input::RIGHT])
x += 1;
if(Input::inputs[Input::LEFT])
# imagine, for a second:
db = new db('mysql:localhost');
results = (
select
(name, age, photo)
from
(db.elePHPants)
where
(age > 16)
@wareya
wareya / gist:f09529975da4086fc952
Created May 14, 2015 00:33
A perl script that dumps the number of time each character in a tree of source files appears
use strict;
use File::Find;
use Data::Dumper;
my @ext = qw(\.c \.h \.cpp \.hpp);
my %stats;
sub search
{
// Septalicensed under the CC0, ISC, MIT, New-BSD, WTFPL, GNU All-Permissive, and Unlicense licenses.
// Code for splitting up a commandline-like string into a series of arguments, where \ escapes certain characters, including space, and "" escapes full arguments
std::vector<std::string> arglist;
std::string scraparg("");
bool escape = false;
bool encapsulate = false;
for(auto character : command)
{
@wareya
wareya / gist:97b83e81658d44760529
Last active June 8, 2016 03:31
nna "o-n-n-a" = 「おんな」 anthy modification
>/usr/share/ibus-anthy/engine/tables.py:
= 'nm' : ('ん', 'm'),
+ 'nn' : ('ん', 'n'),
= 'np' : ('ん', 'p'),
>/usr/share/ibus-anthy/engine/romaji.py
=def romaji_correction_rule_get(k, d):
- return ('ん', k[1:2]) if k[0:1] == 'n' and not k[1:2] in "aiueony'" else d
+ return ('ん', k[1:2]) if k[0:1] == 'n' and not k[1:2] in "aiueoy'" else d
@wareya
wareya / stb_image_wrapper.h
Created September 7, 2016 22:31
_wfopen wrapper
#if _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static inline FILE* wrap_fopen(const char* X, const char* Y)
{
size_t X_S = MultiByteToWideChar(CP_UTF8, 0, X, -1, NULL, 0)*sizeof(wchar_t);
size_t Y_S = MultiByteToWideChar(CP_UTF8, 0, Y, -1, NULL, 0)*sizeof(wchar_t);
std::wstring W_X(X_S, L'#');
std::wstring W_Y(Y_S, L'#');
MultiByteToWideChar(CP_UTF8, 0, X, -1, &W_X[0], X_S);
@wareya
wareya / main.cpp
Last active December 17, 2016 06:30
Minimal low-CPU desktop style SDL2 mainloop with drawing, with mouse use
#include <SDL2/SDL.h>
#undef main
#include <stdio.h>
#include <stdint.h>
SDL_Rect d = {0, 0, 800, 600};
int mouse_x = 0;
int mouse_y = 0;
int main()
@wareya
wareya / extract.py
Created March 6, 2017 12:14
Dumps Magical Charming's compiled script files (incomplete but works for trivial uses)
#!/usr/bin/env python
from sys import argv, exit
from mmap import mmap
from struct import unpack, iter_unpack
#documented (poorly) by bgiop.py
opcodes = {
#-1 = unknown
# push : number of elements pushed to the stack
# pull: number of elements pulled from the stack
@wareya
wareya / demo.cpp
Created March 15, 2017 21:34
Lowpass implemented with an FFT
#include "fft.hpp"
#include <stdint.h>
#include <stdio.h>
#include <math.h> // cos
#include <vector> // lazy
#include <String.h> // strerror
// "Hann" window. This is essentially just the shape of a cosine
// from 0.0 to 1.0 to 0.0. The difference from a cosine window is
# Modified to spit out main script content in utf-8
# use "Phiber's Kirikiri tool. File:Kikiriki.rar" from https://tlwiki.org/?title=Tools#KiriKiri2.2FKAG3 to extract script files from realta nua's vanilla .exe files
# copy said scripts all into the same folder (ovewrite or don't copy files with the same name, do not rename) and delete non-script ones (menu, macro, subroutine, etc)
# krkr line counter script
#
# How to run:
#
# (1) Organize game scripts into directories one level below where this script resides.