Skip to content

Instantly share code, notes, and snippets.

View Tombarr's full-sized avatar
:octocat:
Coding

Tom Barrasso Tombarr

:octocat:
Coding
View GitHub Profile
package com.tombarrasso.android;
/*
* Copyright (c) 2014. Thomas James Barrasso
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
package me.barrasso.android.volume.ui;
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@Tombarr
Tombarr / input-reset.css
Last active May 10, 2021 09:01
CSS to remove input pseudo-elements and normalize input styling cross-browser
/* All of our custom controls should be what we expect them to be */
input,
textarea {
-webkit-box-sizing:content-box;
-moz-box-sizing:content-box;
box-sizing:content-box;
}
/*
Show overflow in Edge
@Tombarr
Tombarr / Trie.js
Last active June 25, 2023 21:48 — forked from tpae/Trie.js
Trie.js - super simple JavaScript implementation
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// From https://gist.github.com/tpae/72e1c54471e88b689f85ad2b3940a8f0
// Modified to support key -> value mapping for quick object retrieval,
// using an ES6 Map instead of plain JS object, and optional case insensitivity.
// Values are automatically converting to arrays to support multiple values
// mapped to a single tree leaf.
// Example:
@Tombarr
Tombarr / Interval & Timeout Tracker
Last active April 6, 2018 15:47
Track Global Timeouts and Intervals
(() => {
let timeouts = [];
let intervals = [];
const _setTimeout = window.setTimeout;
const _setInterval = window.setInterval;
const _clearTimeout = window.clearTimeout;
const _clearInterval = window.clearInterval;
window.setTimeout = (func, delay) => {
@Tombarr
Tombarr / TrappedWater.java
Last active August 8, 2018 00:55
Trapped Water Algorithm
import java.util.stream.IntStream;
import java.util.Arrays;
// O(n^2) solution to the Trapped Water Problem
// @see https://techdevguide.withgoogle.com/paths/advanced/volume-of-water/
public class TrappedWater {
public static void main(String args[]) {
int[] sampleTopography = { 1,3,2,4,1,3,1,4,5,2,2,1,4,2,2 };
int trappedWaterVolume = getTrappedWater(sampleTopography);
@Tombarr
Tombarr / TrappedWaterFast.java
Last active August 8, 2018 00:56
Trapped Water Problem O(n)
import java.util.stream.*;
import java.util.Arrays;
// O(n) solution to the Trapped Water Problem
// @see https://techdevguide.withgoogle.com/paths/advanced/volume-of-water/
public class TrappedWater {
public static void main(String args[]) {
int[] sampleTopography = { 1,3,2,4,1,3,1,4,5,2,2,1,4,2,2 };
int trappedWaterVolume = getTrappedWater(sampleTopography);
@Tombarr
Tombarr / LastWorkingDay.java
Last active September 11, 2018 14:30
TemporalAdjuster for adjusting a date to the last working business day
public static TemporalAdjuster LAST_WORKING_DAY = TemporalAdjusters.ofDateAdjuster(lastDayOfMonth -> {
int daysToSubtract = Math.max(0, lastDayOfMonth.getDayOfWeek().getValue() - DayOfWeek.FRIDAY.getValue());
return lastDayOfMonth.minusDays(daysToSubtract);
});
// Example Usage
LocalDate.now().with(LAST_WORKING_DAY);
@Tombarr
Tombarr / method_chaining.js
Created January 8, 2019 01:29
Javascript method chaining
"war".toUpperCase().split("").reverse().join("");
@Tombarr
Tombarr / pipe_operator.exs
Created January 8, 2019 01:31
Pipe operator in Elixir
"war"
|> String.upcase
|> String.split("")
|> Enum.reverse
|> Enum.join("")