Skip to content

Instantly share code, notes, and snippets.

View bseib's full-sized avatar

Broc Seib bseib

View GitHub Profile
@bseib
bseib / vue-datatables-example.html
Created December 13, 2017 13:48
Vue + DataTables + load once
<!DOCTYPE html>
<html>
<head>
<title>Example Vue + DataTables</title>
<!-- I happened to be using the bootstrap styling w/ DataTables. You may not need this. -->
<link rel="stylesheet" href="/path/to/datatables/DataTables-1.10.16/css/dataTables.bootstrap4.min.css">
</head>
<body>
<div id="example-page">
@bseib
bseib / gradle-wrapper-upgrade.sh
Last active April 6, 2018 22:03
update version of gradle wrapper
#!/bin/sh
# from https://gradle.org/install/
#
# Upgrade with the Gradle Wrapper
# If your existing Gradle-based build uses the Gradle Wrapper, you can easily upgrade by
# running the wrapper task, specifying the desired Gradle version:
## update gradlew
./gradlew wrapper --gradle-version=4.6
@bseib
bseib / README.md
Last active April 18, 2018 19:35
adobe-desktop-service-fivestars-cert-fail

Description

This is a screenshot of Adobe Desktop Service.exe, whose process owns the Security Alert window.

The security alert is saying that the certificate's name for "*.fivestars.com" does not match the site that your program is trying to connect to.

It seems to pop up about every five minutes. Really annoying.

@bseib
bseib / breakout.java
Created October 4, 2018 21:08
using break in nested loops
// from https://stackoverflow.com/questions/12393231/break-statement-inside-two-while-loops/12393289#12393289
void example1() {
outer: while(a) {
while(b) {
if(b == 10) {
break outer;
}
}
}
@bseib
bseib / invalid.js
Last active October 27, 2018 02:08
VueJS directive to inject 'is-invalid' class on element based on a value
// Register a global custom directive called `v-invalid`
Vue.directive('invalid', (function() {
var setInvalidClass = function(el, isInvalid) {
var isActWhenUntouched = el['_isActWhenUntouched'];
var isTouched = el['_isTouched'];
if ( isActWhenUntouched || isTouched ) {
if ( isInvalid ) {
el.classList.add('is-invalid');
}
else {
@bseib
bseib / ServiceWorkerManager.ts
Created November 11, 2019 01:53
Manage service worker installation and monitor for updates
interface InstalledWorkers {
waitingWorker: ServiceWorker | null;
activeWorker: ServiceWorker | null;
}
type ListenerCallback = (waitingWorker: ServiceWorker | null) => any;
export default class ServiceWorkerManager {
@bseib
bseib / README.md
Last active November 24, 2023 17:08
Webpack + JSP

Webpack + JSP

These snippets were created after reading the following article on how to use webpack to build code bundles for individual JSP pages, and specifically how to get those JSP pages to refer to the correct filename + hash.

https://medium.com/@jsilvax/introducing-webpack-into-an-existing-java-based-web-app-ff53f14d37ec

There was no actual code, but the description of the approach was enough to put something together. jsilvax just posted some code here: https://medium.com/p/510d859b9f36/responses/show

@bseib
bseib / MyAuthenticationStrategy.ts
Created January 29, 2020 14:44
loopback 4 authentication authorization example
import {inject} from '@loopback/core';
import {
AuthenticationStrategy,
AuthenticationBindings,
AuthenticationMetadata,
} from '@loopback/authentication';
import {UserProfile} from '@loopback/security';
import {MyMachineUserService} from './services';
import {
MyAuthenticationStrategyBindings,
@bseib
bseib / CountDownLatch.spec.ts
Created February 29, 2020 15:04
CountDownLatch in typescript
import {describe, it} from 'mocha';
import {equal, throws } from 'assert';
import { CountDownLatch } from './CountDownLatch';
describe('CountDownLatch usage suite', () => {
it('fails correctly with a negative starting count', () => {
throws(() => {
new CountDownLatch(-1);
}, 'should have thrown an error with a negative start count');
@bseib
bseib / scope-functions.kt
Created March 21, 2020 14:32
Kotin Scope Function Examples
fun main() {
println("--- let ---")
//yo().let { println(this) } // compile error
yo().let { println(it) } // AAA(greeting=hello)
println(yo().let { it.greeting + " world" }) // hello world
println("\n--- run ---")
yo().run { println(this) } // AAA(greeting=hello)
yo().run { println(greeting.length) } // 5
println(yo().run { "high " + greeting.length }) // high 5