Skip to content

Instantly share code, notes, and snippets.

@crazy4groovy
crazy4groovy / copyToClipboard.html
Last active September 25, 2018 16:36 — forked from lgarron/copyToClipboard.html
Copy any text to clipboard
<script>
// A simple function to copy a string to clipboard.
// This works in most modern browsers, although you won't be able to tell if the copy command succeeded.
// See https://github.com/lgarron/clipboard-polyfill for a more robust solution.
function copyToClipboard(str) {
function listener(e) {
e.preventDefault();
e.clipboardData.setData("text/plain", str);
}
document.addEventListener("copy", listener);
/*
* Archives
* A compressed collection of data.
*/
a[href$=".7z"],
a[href$=".cab"],
a[href$=".gz"],
a[href$=".lzh"],
a[href$=".rar"],
a[href$=".tar"],
@crazy4groovy
crazy4groovy / dashboard.yml
Last active February 11, 2019 20:16 — forked from kantord/dashboard.yml
Simple Online Dashboard Chart tool (https://github.com/kantord/just-dashboard)
dashboard "Food crazy4groovy":
- h1 text: Food 2
- h2 text: By caloric content
- 3 columns:
- rows:
- h3 text: Bananas
- pie chart: {
"columns": [
["Protein", 5], ["Sugar", 10], ["Other carbs", 40], ["Fat", 1]
]
@crazy4groovy
crazy4groovy / JS-Quiz-Solutions.js
Created October 27, 2016 18:21 — forked from say2joe/JS-Quiz-Solutions.js
My solutions to former employer's JS quiz for new employees
// Please save all your work in https://jsfiddle.net/
// Return the link to your work
// Answer five out of the seven questions
// Use test data when provided, however your functions should work with any similiarly structured data
// Use any additional libraries you like
// 1: Refactor this function to make it scalable.
var goto = function(evt, where, project, scenario, item, id){
if (evt && evt.stopPropagation){ evt.stopPropagation(); }
@crazy4groovy
crazy4groovy / build.gradle
Created July 26, 2016 15:52 — forked from ysb33r/build.gradle
HOWTO ignore spock tests when gradle is run offline
// Check whether --offline was passed to gradle and set it in the test configuration's system properties
test {
if(gradle.startParameter.isOffline()) {
systemProperties 'TESTS.ARE.OFFLINE' : '1'
}
}
@crazy4groovy
crazy4groovy / tree.md
Created June 27, 2016 03:11 — forked from kiy0taka/tree.md
A one-line tree in Groovy

One line Tree in Groovy

The other day, I saw Harold Cooper's One-line tree in Python via autovivication, and wondered if the same thing was possible in Groovy.

The answer is yes! But you need to define the variable tree before you can assign it to the self-referential withDefault closure, hence with Groovy, it's a two-line solution ;-)

Anyway, given:

def tree = { [:].withDefault{ owner.call() } }
@crazy4groovy
crazy4groovy / nstime.js
Created May 18, 2016 19:05 — forked from ericelliott/nstime.js
Convert Node's process.hrtime() return values to nanoseconds
const nsTime = (hrtime) => hrtime[0] * 1e9 + hrtime[1];
@crazy4groovy
crazy4groovy / 0_reuse_code.js
Created April 20, 2016 15:33
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@crazy4groovy
crazy4groovy / HelloSpec.groovy
Last active March 8, 2016 16:06 — forked from pmlopes/HelloSpec.groovy
Spock and Vertx3
import io.vertx.core.Vertx
import spock.lang.Shared
import spock.lang.Specification
import spock.util.concurrent.BlockingVariable
class HelloSpockSpec extends Specification {
@Shared
def Vertx vertx = Vertx.vertx()
@crazy4groovy
crazy4groovy / spark.groovy
Last active December 18, 2015 17:07 — forked from mattn/spark.groovy
@Grab('com.sparkjava:spark-core:2.1')
import static spark.Spark.*
import groovy.json.JsonBuilder
Object.metaClass.asJson = {
def builder = new JsonBuilder(delegate);
builder.toString()
}