Skip to content

Instantly share code, notes, and snippets.

import org.joda.time.LocalDate;
import org.joda.time.Years;
public class DateTest {
public static void main(String[] args) {
LocalDate start = LocalDate.parse("2012-01-28"); // leap year
LocalDate end = LocalDate.parse("2013-01-27");
LocalDate end2 = LocalDate.parse("2013-01-28");
System.out.println(end.isBefore(start.plus(Years.ONE))); // true
System.out.println(end2.isBefore(start.plus(Years.ONE))); // false
@Yogu
Yogu / rtc.js
Created September 30, 2014 12:02
Simple RTCDataChannel setup
var RTCPeerConnection = window.mozRTCPeerConnection || window.webkitRTCPeerConnection || window.RTCPeerConnection;
var RTCSessionDescription = window.mozRTCSessionDescription || window.webkitRTCSessionDescription || window.RTCSessionDescription;
var RTCIceCandidate = window.mozRTCIceCandidate || window.webkitRTCIceCandidate || window.RTCIceCandidate;
var RTC_CONFIGURATION = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}]};
var MEDIA_CONSTRAINTS = {optional: [{internalSctpDataChannels: true},{DtlsSrtpKeyAgreement: true}]};
function errorCallback(error) {
console.log(error);
}
@Yogu
Yogu / find.js
Created February 7, 2014 13:54
Recursively find string in DOM
function find(object, search, cache, path) {
if (!cache)
cache = [];
if (!path)
path = '';
if (cache.indexOf(object) >= 0)
return;
cache.push(object);
for (var key in object) {