Skip to content

Instantly share code, notes, and snippets.

View tedyoung's full-sized avatar

Ted M. Young tedyoung

View GitHub Profile
@MWDelaney
MWDelaney / .eleventy.js
Last active April 21, 2024 08:49
Tag-friendly pagination for Eleventy
...
postsByTag: function (eleventyConfig) {
let _ = require("lodash");
eleventyConfig.addCollection("postsByTag", function(collection) {
// Get unique list of tags
let tagSet = new Set();
collection.getAllSorted().map(function(item) {
if( "tags" in item.data ) {
@gregorriegler
gregorriegler / SuggestFlywayMigration.java
Last active June 15, 2023 06:55
Generates Flyway Migration Scripts Automatically using Hibernate Schema Updater and Testcontainers
package org.acme;
import com.microsoft.sqlserver.jdbc.SQLServerDriver;
import org.flywaydb.core.Flyway;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.schema.TargetType;
import org.reflections.Reflections;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
@jed
jed / progress.js
Last active March 11, 2016 08:37
Using template strings as progress bars
"use strict"
function progress(strs, current, total) {
let str = `${strs[0]}${current}${strs[1]}${total}${strs[2]}`
let ratio = Math.min(Math.max(current / total, 0), 1)
let length = Math.floor(ratio * str.length)
let pattern = new RegExp(`^.{${length}}`)
return str.replace(pattern, "\x1b[4m$&\x1b[0m")
}
@mrserverless
mrserverless / DropwizardJettyCrossOriginIntegrationTest.java
Last active January 19, 2018 22:09
Dropwizard 0.8.0 and 0.9.0 Jetty CORS Filter with Unit Tests. To prove this works once and for all
import io.dropwizard.Application;
import io.dropwizard.Configuration;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.setup.Environment;
import io.dropwizard.testing.junit.DropwizardAppRule;
import org.assertj.core.data.MapEntry;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.junit.ClassRule;
import org.junit.Test;
@amoawad
amoawad / Java8FeaturesDemo.java
Last active March 28, 2021 15:36
A brief introduction to some of the basic Java 8 new features.
/* Class definition ommitted */
public void run(){
List<Integer> list = Arrays.asList(5, 9, -1, 60, 10, 2, 9);
// region <lambdas> ---------------------------------------------------------------------------┐
list.sort ((a, b) -> b - a);
list.forEach(i -> System.out.print(i + " ")); // output: 60 10 9 9 5 2 -1
// ┌-----------> Note the empty parenthesis, this lambda has no input
@PiiXiieeS
PiiXiieeS / Insert a progress bar to Powerpoint presentation .md
Last active January 17, 2024 13:12
Insert a progress bar to Powerpoint presentation

Intro

To view the progress of a Powerpoint presentation, a progress bar can be displayed at the bottom of the slide show.

How to proceed

Once the slideshow is complete, go to Tools > Macro > Visual Basic Editor.

In the new window, select Insert > Module and copy this text in the blank page:

Sub AddProgressBar()
    On Error Resume Next
@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet
public void removeJsonProcessingExceptionMapper(Environment environment) {
Set<Object> singletons = environment.getJerseyResourceConfig().getSingletons();
List<Object> singletonsToRemove = Lists.newArrayList();
for (Object s : singletons) {
if (JsonProcessingExceptionMapper.class.isAssignableFrom(s.getClass())) {
singletonsToRemove.add(s);
}
}
for (Object s : singletonsToRemove) {
singletons.remove(s);