Skip to content

Instantly share code, notes, and snippets.

View conorgriffin's full-sized avatar

Conor Griffin conorgriffin

View GitHub Profile
@conorgriffin
conorgriffin / AdTableViewCell.swift
Last active August 29, 2015 14:25 — forked from delba/AdTableViewCell.swift
MoPub iOS sdk with Swift
import UIKit
class AdTableViewCell: UITableViewCell {
// MARK: Subviews
// Add subviews and constraints...
}
@conorgriffin
conorgriffin / SparkGrep.scala
Created January 8, 2016 09:49 — forked from mhausenblas/SparkGrep.scala
Scala Spark skeleton implementing grep
package spark.example
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
object SparkGrep {
def main(args: Array[String]) {
if (args.length < 3) {
System.err.println("Usage: SparkGrep <host> <input_file> <match_term>")

Keybase proof

I hereby claim:

  • I am conorgriffin on github.
  • I am conorgriffin (https://keybase.io/conorgriffin) on keybase.
  • I have a public key ASCObXLCZ4WviMwabz9-5lHEfbRyBf9Dy5gH77jhxDHGFAo

To claim this, I am signing this object:

@conorgriffin
conorgriffin / Deflater.java
Created December 18, 2019 15:33
java.util.zip.Deflater native methods
private static native void initIDs();
private native static long init(int level, int strategy, boolean nowrap);
private native static void setDictionary(long addr, byte[] b, int off, int len);
private native int deflateBytes(long addr, byte[] b, int off, int len,
int flush);
private native static int getAdler(long addr);
private native static void reset(long addr);
private native static void end(long addr);
@conorgriffin
conorgriffin / Bug.java
Last active December 18, 2019 15:42
Bug creating Deflater
outputStream = new DeflaterOutputStream(outputStream, new Deflater(), BLOCK_SIZE);
@conorgriffin
conorgriffin / DeflaterOutputStream.java
Created December 18, 2019 15:48
DeflaterOutputStream constructor with default Deflater
/**
* Creates a new output stream with a default compressor and buffer size.
*
* <p>The new output stream instance is created as if by invoking
* the 2-argument constructor DeflaterOutputStream(out, false).
*
* @param out the output stream
*/
public DeflaterOutputStream(OutputStream out) {
this(out, false);
@conorgriffin
conorgriffin / DeflaterOutputStream.java
Created December 18, 2019 15:50
DeflaterOutputStream with custom buffer size
/**
* Creates a new output stream with the specified compressor and
* buffer size.
*
* <p>The new output stream instance is created as if by invoking
* the 4-argument constructor DeflaterOutputStream(out, def, size, false).
*
* @param out the output stream
* @param def the compressor ("deflater")
* @param size the output buffer size
@conorgriffin
conorgriffin / DeflaterOutputStream.java
Created December 18, 2019 15:53
DeflaterOutputStream close method
/**
* Writes remaining compressed data to the output stream and closes the
* underlying stream.
* @exception IOException if an I/O error has occurred
*/
public void close() throws IOException {
if (!closed) {
finish();
if (usesDefaultDeflater)
def.end();
@conorgriffin
conorgriffin / Deflater.java
Created December 18, 2019 15:56
Deflater finalize method
/**
* Closes the compressor when garbage is collected.
*/
protected void finalize() {
end();
}
@conorgriffin
conorgriffin / Bug.java
Created December 18, 2019 16:21
The Bug
outputStream = new DeflaterOutputStream(outputStream, new Deflater(), BLOCK_SIZE);