Skip to content

Instantly share code, notes, and snippets.

@MasterEx
MasterEx / ArrayTraversal.java
Last active December 19, 2021 20:50
"Overflowing the stack for fun" code examples
public class RecursiveArrayTraversal {
public static void main(String[] args) {
int[] arr = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for(int i=0; i< arr.length; i++) {
System.out.println(i);
}
}
}
public class OutputStreamAdapter extends OutputStream implements Appendable, Closeable {
private OutputStream os;
private CheckedOutputStream cos;
private DeflaterOutputStream dos;
private Appendable appendable;
private PrintStream pos;
public OutputStreamAdapter(OutputStream os) {
setOutputStream(os);
@MasterEx
MasterEx / main.lua
Last active July 19, 2020 00:10
Comparison of drawing pacman character both in code and by using images.
local x = 20
-- image code
local images = {}
local image
local quad
local t = 0
-- gen code
local PI_QUARTER = math.pi/4
local TWO_PI = 2*math.pi
@MasterEx
MasterEx / example.txt
Last active May 12, 2019 09:55
Print all the substrings of a string in Bash
$ ./substrings.bash '1234567890' 133
1234567890
$ ./substrings.bash '1234567890' 10
1234567890
$ ./substrings.bash '1234567890' 9
1234567890
123456789
234567890
$ ./substrings.bash '1234567890' 8
1234567890
@MasterEx
MasterEx / Readme.md
Created June 21, 2014 14:36
Drawing polygons and polylines in lua/love2d with rounded corners

This is a simple module that can be used to draw polygons or polylines with rounded corners in love2d. The polygons/polylines must consist only from 90/270 degrees corners.

I wanted this functionality to draw pacman like mazes.

Example from a random pacman game:

Pacman

How it works

@MasterEx
MasterEx / Readme.txt
Created November 18, 2013 21:59
new Hedgewars mode, temporary name: Team5 This is a version for the Hedgewars 0.9.20
INSTALL
Windows
Copy the two files (team5.lua and team5.cfg) to My Documents/Hedgewars/Data/Scripts/Multiplayer
Linux
Copy the two files (team5.lua and team5.cfg) to ~/.hedgewars/Data/Scripts/Multiplayer
@MasterEx
MasterEx / Readme.txt
Last active December 28, 2015 17:29
new Hedgewars mode, temporary name: Team5 This is a version for the Hedgewars 0.9.19
INSTALL
Windows
Copy the two files (team5.lua and team5.cfg) to My Documents/Hedgewars/Data/Scripts/Multiplayer
Linux
Copy the two files (team5.lua and team5.cfg) to ~/.hedgewars/Data/Scripts/Multiplayer
@MasterEx
MasterEx / Coolphpobfuscator.java
Created April 4, 2013 10:09
A more advanced implementation of the original coolphpobfuscator (https://gist.github.com/MasterEx/1171816) described in http://masterex.github.com/archive/2011/08/27/php-protect-the-code.html . Credit goes to Dan.
package coolphpobfuscator;
import java.io.*;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Scanner;
@MasterEx
MasterEx / AdvancedAudioSynthesisDemoActivity.java
Created May 24, 2012 21:12
Audio Synthesis with android AudioTrack - 1
package pntanasis.master_ex.android;
import pntanasis.master_ex.android.Synthesizer.Note0;
import android.app.Activity;
import android.os.Bundle;
public class AudioSynthesisDemoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
<?php
function getDays($start,$end,$day) {
$days = array();
$now = strtotime("first $day $start");
$stop = strtotime("last $day $end");
while($now <= $stop) {
$days[] = $now;
$now = strtotime("next $day",$now);
}