Skip to content

Instantly share code, notes, and snippets.

// reds
@material_red_50: #fde0dc;
@material_red_100: #f9bdbb;
@material_red_200: #f69988;
@material_red_300: #f36c60;
@material_red_400: #e84e40;
@material_red_500: #e51c23;
@material_red_600: #dd191d;
@material_red_700: #d01716;
@material_red_800: #c41411;
@kribblo
kribblo / base-url.js
Created August 24, 2016 15:38
Export base URL of current file, for use in dynamic loading etc. Runs once, at load-time.
'use strict';
const scripts = document.getElementsByTagName('script');
const currentScript = scripts[scripts.length - 1];
const baseURL = currentScript.src.substring(0, currentScript.lastIndexOf('/'));
module.exports = baseURL;
@kribblo
kribblo / size-helper.js
Last active September 25, 2016 20:08
Helper to fit a given size into another, preserving aspect ratio
'use strict';
/**
* @exports sizeFactory
* @private
*
* @param {{width: number, height: number}} size
* @returns {sizeHelper}
*/
function sizeFactory(size) {
@kribblo
kribblo / CamelCase.velocity
Last active February 15, 2017 19:15
IntelliJ File & Code Templates
## Inspired by https://gist.github.com/Pencroff/69ebdd4d57ad11b2eaba
## file name transformation
## file-name => FileName
## Sources:
## http://stackoverflow.com/questions/6998412/velocity-string-function
## http://stackoverflow.com/questions/21288687/using-velocity-split-to-split-a-string-into-an-array-doesnt-seem-to-work
## http://velocity.apache.org/engine/releases/velocity-1.7/apidocs/org/apache/velocity/util/StringUtils.html#split(java.lang.String, java.lang.String)
## File and Code Templates -> Includes -> Save as "CamelCase"
#set( $camelCaseName = "" )
@kribblo
kribblo / SiteLocalIp.java
Last active May 10, 2019 02:30
Get site local ip in Java, skipping loopback, docker etc
package io.github.kribblo.ip;
import java.net.*;
import java.util.Collections;
public class SiteLocalIp {
public static String getSiteLocalIp() throws SocketException, UnknownHostException {
return Collections.list(NetworkInterface.getNetworkInterfaces()).stream()
.filter(SiteLocalIp::isValidInterface)
.flatMap(i -> Collections.list(i.getInetAddresses()).stream())
@kribblo
kribblo / git-pull-all.sh
Last active October 31, 2018 14:14
Shell script to pull all git repositories in one directory or workspace
#!/bin/sh
/usr/bin/find ~/Workspace -mindepth 1 -maxdepth 1 -type d -print -exec /usr/bin/git -C {} pull --ff-only --all \;
@kribblo
kribblo / scale-css.pl
Created September 20, 2017 15:03
Quick one-off hack in Perl to scale some CSS properties
perl -pi -e 's/(width|height|margin-?\w*|padding-?\w*|font-size): ([\d+\.])(vw|vh|%|px)/"$1: ".sprintf("%.2f", $2*(1\/0.85)).$3/e' file.css
@kribblo
kribblo / npm-unpublish-range.sh
Created March 19, 2018 10:09
npm unpublish a range of versions
# Example: npm unpublish the-package from 0.5.31 to 0.5.41
for i in $(seq 31 41); do npm unpublish "the-package@0.5.$i"; done
# list available versions of the-package:
npm show the-package versions
@kribblo
kribblo / cbz.sh
Created February 5, 2019 14:28
CBZ a bunch of directories (Chapter[01-21]) to comic archives
for i in {01..21}; do zip -j -r "ComicName$i.cbz" "Chapter$i"; done
@kribblo
kribblo / check-size.js
Last active February 27, 2019 12:40
Check minimum size of a file on command line (node) or in npm run scripts
#!/usr/bin/env node
const fs = require('fs');
if(process.argv.length < 4) {
console.error('Usage:', 'node check-size.js file size');
process.exit(1);
}
const file = process.argv[2];