Skip to content

Instantly share code, notes, and snippets.

View marcomorain's full-sized avatar

Marc O'Morain marcomorain

View GitHub Profile
public class Promise<T> {
private final AtomicReference<T> ref = new AtomicReference<T>();
private final CountDownLatch latch = new CountDownLatch(1);
public final void deliver(T object) {
if (this.ref.compareAndSet(null, object)) {
latch.countDown();
}
}
fun <T> Capture(block: () -> T): T {
try {
return block.invoke()
} catch (e: Exception) {
Sentry.captureException(e)
throw e
}
}
Capture {
package flipdish
import android.content.Context
import android.provider.Settings
import com.joshdholtz.sentry.Sentry
import java.util.Collections
import android.util.Log
import android.widget.Toast
import java.util.concurrent.atomic.AtomicReference
@marcomorain
marcomorain / flakey.py
Last active February 21, 2016 14:23
Find Flakey Tests
#!/usr/bin/env python
import requests
import os
import sys
import pprint
import re
from sets import Set
from collections import defaultdict, Counter
from urlparse import urlparse
package com.swrve.babble;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import org.glassfish.jersey.uri.UriTemplate;
public class UrlTemplate {
@marcomorain
marcomorain / gist:8357744
Last active January 2, 2016 20:38
I tried to use Rust today....

Rust

My first idea: clone the comm commandline tool.

use std::io::buffered::BufferedReader;
use std::io::stdin;
use std::os;
use std::io::File;

fn lines(path: ~str) -> ~[~str] {
@marcomorain
marcomorain / csgo crast
Created January 2, 2014 13:59
Every time I quit CS:GO
Process: csgo_osx [50248]
Path: /Users/USER/Library/Application Support/Steam/*/csgo_osx
Identifier: csgo_osx
Version: ???
Code Type: X86 (Native)
Parent Process: bash [50245]
Responsible: bash [354]
User ID: 501
Date/Time: 2014-01-02 13:59:11.710 +0000
package com.swrve.push_system;
import com.google.common.util.concurrent.RateLimiter;
import com.relayrides.pushy.apns.ApnsEnvironment;
import com.relayrides.pushy.apns.ApnsPushNotification;
import com.relayrides.pushy.apns.PushManager;
import java.security.KeyStore;
import java.util.Collection;
import scala.actors.threadpool.Arrays;
@marcomorain
marcomorain / wat?
Last active December 28, 2015 00:19
Depending on how you call Date, the type changes.
parts = [1982, 5, 29]
// => [1982, 5, 29]
// This is my birthday.
new Date(parts)
// => Sat May 29 1982 00:00:00 GMT+0100 (IST)
// Month is 1-based (5 = May)
new Date(parts[0], parts[1], parts[2])
// => Tue Jun 29 1982 00:00:00 GMT+0100 (IST)
import time
import requests
import json
import base64
from flask import Flask
from flask import jsonify
from flask import Response
consumer_key = 'CONSUMER KEY FOR YOUR APP'
consumer_secret = 'CONSUMER SECRET FOR YOUR APP'