Skip to content

Instantly share code, notes, and snippets.

@jexp
jexp / neo_datatable.js
Last active January 30, 2017 15:05
Bookmarklet to zoom and pan Neo4j graph viz and query plans, Hold "Alt" to zoom & pan.
javascript: (function() {
var createTable = function() { $("neo-table > table.table.data:not(datatable)").addClass("datatable").DataTable(); };
if ($("#style-datatable").length == 0) {
$("body").append($('<link id="style-datatable" rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">'));
$.getScript('//cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js',createTable);
} else {
createTable();
}
})();
@Genovo
Genovo / strictMode.sh
Created September 13, 2017 18:40
Bash "Strict Mode"
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
@gvlx
gvlx / unit.sh
Last active October 5, 2018 05:47 — forked from tvlooy/unit.sh
Bash test: get the directory of a script
#!/bin/bash
# Following stackoverflow discussion, from https://gist.github.com/tvlooy/cbfbdb111a4ebad8b93e (rev7)
function test(){
local __MESSAGE__="$1"
local __RECEIVED__="$2"
local __EXPECTED__="$3"
if [ "${__RECEIVED__}" == "${__EXPECTED__}" ]; then
@WebReflection
WebReflection / json-channel.js
Last active July 29, 2022 12:01
A GJS WebKit JSON Communication Channel Example
const JSONChannel = (Private => class JSONChannel {
// (c) Andrea Giammarchi - @WebReflection (ISC)
constructor(secret=Array.from(
crypto.getRandomValues(new Uint8Array(8))
).map(i => i.toString(36)).join('')) {
const listener = e => this.emit('message', null, e.detail);
document.addEventListener(`${secret}:gjs`, listener);
Private.set(this, {
secret, listener,
fn: Object.create(null)
@ebidel
ebidel / feature_detect_es_modules.js
Last active September 4, 2023 13:56
Feature detect ES modules: both static import and dynamic import()
<!--
Complete feature detection for ES modules. Covers:
1. Static import: import * from './foo.js';
2. Dynamic import(): import('./foo.js').then(module => {...});
Demo: http://jsbin.com/tilisaledu/1/edit?html,output
Thanks to @_gsathya, @kevincennis, @rauschma, @malyw for the help.
-->
@sinclairtarget
sinclairtarget / bernoulli.c
Created August 17, 2018 20:22
Lovelace's Note G Program in C
#include <stdio.h>
/*
* Calculates what Ada Lovelace labeled "B7", which today we would call the 8th
* Bernoulli number.
*/
int main(int argc, char* argv[])
{
// ------------------------------------------------------------------------
// Data