Skip to content

Instantly share code, notes, and snippets.

@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
@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.
-->
@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)
@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
@Genovo
Genovo / strictMode.sh
Created September 13, 2017 18:40
Bash "Strict Mode"
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
@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();
}
})();
@judoole
judoole / .gitignore
Created April 14, 2016 07:23
gitignore IntelliJ share runConfigurations
.idea/*
!.idea/runConfigurations/
@ryzy
ryzy / haproxy.cfg
Created March 13, 2016 00:20
HAProxy conf with SSL termination and HTTP/2 support
global
#debug
chroot /var/lib/haproxy
user haproxy
group haproxy
pidfile /var/run/haproxy.pid
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
@kmassada
kmassada / README.md
Last active September 4, 2021 12:22
Vagrant and KVM(QEMU) on Centos7

Libvirt

yum group install -y "Development Tools"
yum -y install qemu-kvm libvirt virt-install bridge-utils libvirt-devel  libxslt-devel libxml2-devel libvirt-devel libguestfs-tools-c
echo "net.ipv4.ip_forward = 1"|sudo tee /etc/sysctl.d/99-ipforward.conf
sysctl -p /etc/sysctl.d/99-ipforward.conf
@wunki
wunki / anonymous-gist.org
Created October 14, 2015 08:53
Run Ubuntu with iohyve

Setup new server

  • iohyve create ubuntuguest 8G
  • iohyve set ubuntuguest loader=grub-bhyve
  • iohyve set ubuntuguest os=debian
  • iohyve set ubuntuguest ram=512M
  • iohyve set ubuntuguest cpu=2
  • iohyve set ubuntuguest con=nmdm1
  • iohyve install ubuntuguest ubuntu-14.04.3-server-amd64.iso
  • Drop in the console: iohyve console ubuntuguest