Skip to content

Instantly share code, notes, and snippets.

View carld's full-sized avatar
🔜

Carl carld

🔜
View GitHub Profile

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
@carld
carld / take even elements from list
Created August 2, 2021 12:04
Take the even elements from a list using Racket
(define (take-even lst)
(letrec [(taker (lambda (lst-rem result)
;(printf "~a ~a" lst-rem result)
(if (< (length lst-rem) 2)
result
(cons (car (cdr lst-rem)) (taker (cdr (cdr lst-rem)) result)))))]
(taker lst '())))
@carld
carld / match regexp
Created August 2, 2021 11:36
Using Scheme's match with regexp in Racket
; ISIN, e.g. US0378331005
(define Apple-ISIN "US0378331005")
; ISO6166 International Securities Identification Number (ISIN)
; ISO3166-2 plus National Securities Identifying Number (NSIN)
(match Apple-ISIN
[(regexp #px"^([A-Z]{2})([0-9]{9})([0-9])$" (list _ country NSIN check))
(list country NSIN check)])
@carld
carld / app.rkt
Created July 2, 2020 10:52 — forked from RyanKung/app.rkt
Demo: A simple MVC-web-framework implementation with PLT Scheme (Racket)
;;By Jhen Kung, [email protected]
;;app.rkt
#lang racket(require web-server/servlet
web-server/servlet-env
"router.rkt")
(serve/servlet mordor
#:port 8080
#:servlet-path "/"