Skip to content

Instantly share code, notes, and snippets.

@twuni
twuni / google-maps-decode-polyline-obfuscated.js
Created November 11, 2013 09:27
The obfuscated version of the Google Maps JavaScript API v3's implementation of their Encoded Polyline Algorithm Format (https://developers.google.com/maps/documentation/utilities/polylinealgorithm).
function (a) {
for (var b = H(a), c = ea(l[gb](a[D] / 2)), d = 0, e = 0, f = 0, g = 0; d < b; ++g) {
var h = 1,
n = 0,
r;
do r = a[Kc](d++) - 63 - 1, h += r << n, n += 5; while (31 <= r);
e += h & 1 ? ~(h >> 1) : h >> 1;
h = 1;
n = 0;
do r = a[Kc](d++) - 63 - 1, h += r << n, n += 5; while (31 <= r);
@twuni
twuni / URLEncoderTest.java
Created July 27, 2013 07:52
Some basic unit tests for URLEncoder.java.
import org.junit.Assert;
import org.junit.Test;
public class URLEncoderTest extends Assert {
public static void assertCharSequenceEquals( CharSequence expected, CharSequence actual ) {
for( int i = 0; i < expected.length(); i++ ) {
assertEquals( "at position " + i, expected.charAt( i ), actual.charAt( i ) );
}
}
@twuni
twuni / URLEncoder.java
Created July 27, 2013 07:46
A secure, high performance, thread-safe URL encoder implementation in Java. It's intended to be a drop-in replacement for java.net.URLEncoder that uses mutable CharSequences instead of Strings, for applications which require thorough mutability for sensitive data.
import java.nio.CharBuffer;
import java.util.BitSet;
public class URLEncoder {
private static final char [] IGNORED_BY_DEFAULT = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!*()-_'.~".toCharArray();
private static final char [] HEX = "0123456789ABCDEF".toCharArray();
private static final URLEncoder DEFAULT = new URLEncoder();
public static CharSequence encode( CharSequence s ) {
@twuni
twuni / CryptoHelper.java
Last active February 18, 2022 19:09
A basic example of how to perform symmetric key encryption/decryption using AES and Java's cryptography API.
import java.security.Key;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import org.apache.commons.codec.binary.Base64;
@twuni
twuni / evy-notes
Created April 20, 2012 04:47
Evy development notes
A node has access to its ancestors, but not to its siblings.
Each node has a symbol table.
@ event a
print "In the subscriber for the event, the symbol 'a' should be accessible in the parent's symbol table, set to the value of 123."
event a=123
print "After triggering the event, the symbol 'a' should be accessible in the parent's symbol table, set to the value of 123."
event a
print "This should resolve the symbol 'a' prior to publishing the event. If 'a' cannot be resolved, then use it only as a matcher for subscribers."
After publishing a non-subscriber event, publish its children.