Skip to content

Instantly share code, notes, and snippets.

@carld
carld / promisemonad.js
Created April 22, 2025 09:03
promise/monad example in javascript
<html>
<head>
<style>
html * {
font-family: monospace;
}
</style>
</head>
<body>
<form onsubmit="return run();">
JSCLASS_PATH = 'build/min';
require('./' + JSCLASS_PATH + '/loader');
JS.require('JS.Deferrable');
Promise = new JS.Class({
include: JS.Deferrable,
initialize: function(value) {
if (value !== undefined) this.succeed(value);
@carld
carld / graph.html
Created February 2, 2025 08:55
Graph
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
<title>Compound nodes</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.30.4/cytoscape.min.js"></script>
<style>
body {
font: 14px helvetica neue, helvetica, arial, sans-serif;

Mounting VirtualBox shared folders on Ubuntu Server 18.04 LTS (Bionic Beaver)

This guide will walk you through the steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest.

Prerequisites

This guide assumes that you are using the following setup:

You could still make this guide work with other setups (possibly with some modifications to the commands and whatnot).

@carld
carld / commit-author.sh
Created June 27, 2023 08:15 — forked from raineorshine/commit-author.sh
Set git commit author for a single repository
git config user.name "ShapeShift-Public"
git config user.email "[email protected]"
https://help.github.com/articles/setting-your-username-in-git/#setting-your-git-username-for-a-single-repository
@carld
carld / sh
Created June 12, 2023 11:53
git tag sort config
git config --global tag.sort version:refname
@carld
carld / lazy_reduce.rb
Created April 12, 2023 01:08 — forked from sharplet/lazy_reduce.rb
Lazy `#reduce` and `#join` in Ruby
require "rspec/autorun"
class Enumerator::Lazy
def reduce(*)
Lazy.new([nil]) do |yielder, _|
yielder << super
end
end
def join(separator="")
@carld
carld / .rubocop.yml
Created June 28, 2022 04:22 — forked from jhass/.rubocop.yml
My preferred Rubocop config
AllCops:
RunRailsCops: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
@carld
carld / simple.rb
Created April 19, 2022 23:36
Ruby Fibres example
class Engine
def initialize
@tick = 0
@event_count = 0
@queue = []
@fibre = Fiber.new do |arg|
loop do
@tick += 1
e = @queue.pop
@carld
carld / gist:f8977d6244eebd0c9ff51ac6c871b268
Created April 17, 2022 22:56 — forked from robertsosinski/gist:2691813
Testing Postgres Listen/Notify using EventMachine
require 'rubygems'
require 'pg'
require 'eventmachine'
module Subscriber
def initialize(pg)
@pg = pg
end
def notify_readable