Skip to content

Instantly share code, notes, and snippets.

@tecywiz121
tecywiz121 / gist:782081
Created January 16, 2011 19:46
Versioned Database
-- Base class for all versioned models
CREATE TABLE `VersionedModel` (
`BlobId` INTEGER(11) NOT NULL,
`VersionId` BINARY(64) NOT NULL,
`IsTip` BOOLEAN NOT NULL,
PRIMARY KEY (`BlobId`,`VersionId`),
KEY `model_tip_index` (`BlobId`,`IsTip`)
) ENGINE=InnoDB;
-- Tracks changes to models
@tecywiz121
tecywiz121 / mitigate-xss.js
Created August 24, 2012 17:52
Mitigate XSS client side
/*
* A proof of concept client-side XSS mitigation library with minimal server side requirements.
*
* Installation:
*
* Insert this script immediately following the opening tag of the body element.
*
* Strip every instance of </noscript> and </iframe> before the output leaves
* your server.
*/
@tecywiz121
tecywiz121 / GlobBuilder.java
Created August 9, 2013 13:49
Java class that implements a state machine for converting glob-like patterns into regular expressions
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.File;
public final class GlobBuilder {
private static final String PATTERN_STAR;
private static final String PATTERN_STAR_STAR = ".*";
private static final String PATTERN_QUESTION = ".";
@tecywiz121
tecywiz121 / Metadata.java
Created February 7, 2017 22:32
Quick tool to print imageio metadata adapted from: http://johnbokma.com/java/obtaining-image-metadata.html
import java.io.File;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.stream.ImageInputStream;
import org.w3c.dom.NamedNodeMap;
@tecywiz121
tecywiz121 / commands.vim
Created October 26, 2017 18:49
Sequence of commands demonstrating loss of nomodifiable
let my_buf=bufnr('banana', 1)
call nvim_buf_set_lines(my_buf, 0, 0, v:true, ['this is a line'])
call nvim_buf_set_option(my_buf, 'modifiable', v:false)
execute ":buffer " . my_buf
execute "normal! oTyped after modifiable=False\<esc>"
@tecywiz121
tecywiz121 / example.rs
Created January 24, 2018 00:58
How do I
#[derive(Deserialize)]
struct Demo {
d1: Demo<i32>,
d2: Demo<String>,
d3: Demo<String>,
}
enum DemoEnum<T> {
A,
B,