Skip to content

Instantly share code, notes, and snippets.

View joubertnel's full-sized avatar

Joubert Nel joubertnel

  • Netflix
  • Los Angeles, CA
View GitHub Profile
@joubertnel
joubertnel / csp-channels-with-semaphores
Created May 31, 2015 16:37
CSP channels implementation with semaphores
CMSC 421 Operating Systems Lecture Notes
(c) 1994 Howard E. Motteler
Message Passing
================
The goal of critical sections, monitors, etc. is to allow
processes to _communicate_
@joubertnel
joubertnel / gist:870190
Last active July 8, 2023 12:52
HTML5 Canvas - Rendering of Text on high-DPI screens
<html>
<head>
<script src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
</head>
<body>
<h2>Naive canvas</h2>
<canvas id="naive" width="400" height="50"></canvas>
<h2>High-def Canvas</h2>
@joubertnel
joubertnel / rmchars.icn
Created December 27, 2022 15:25
solution to the rmchars string scanning challenge on slide 182 of Unicon Programming Fundamentals
# learning Unicon/Icon.
# here's my initial solution to the rmchars string scanning challenge on slide 182 of Unicon Programming Fundamentals
# http://www2.cs.uidaho.edu/~jeffery/courses/210/UniconFundamentals.pdf
procedure main(args)
local t := "For both the structures described."
write(rmchars(t, 'sed'))
@joubertnel
joubertnel / gist:d31328d6db838a4d978a1c20e8d16e40
Created January 23, 2021 21:09
Nim: compile for Apple M1 / macOS
# based on information from: https://github.com/nim-lang/Nim/issues/16211
git clone https://github.com/nim-lang/Nim
cd Nim
git clone -q --depth 1 https://github.com/nim-lang/csources_v1.git sources
./build_all.sh
@joubertnel
joubertnel / list_threads
Created January 25, 2013 20:24
List threads, including PID, TID, and priority
#!/bin/sh
# A (b)ash script replacement for ps showing threads and other helpful stuff.
# Especially useful for Busybox based systems which has a very simple ps applet
#
# License: GPLv2
# Copyright 2009 Chris Simmonds, 2net Ltd
# chris@2net.co.uk
show_details ()
@joubertnel
joubertnel / thrice.pas
Last active January 4, 2021 21:49
Pascal - generic function example
{ FreePascal: Generic function example prompted by StackOverflow question:
"Does Free Pascal have type variable like Haskell?"
https://stackoverflow.com/questions/7799037/does-free-pascal-have-type-variables-like-haskell }
{$mode objfpc}
program Thrice;
uses sysutils;
@joubertnel
joubertnel / nesting_loops.jl
Created November 8, 2020 19:48
multiple nested for loops combined in a single outer loop, forming the cartesian product of the iterables
for i = 1:5, j = 1:2
println((i, j))
end
# yields:
# (1, 1)
# (1, 2)
# (2, 1)
# (2, 2)
# (3, 1)
@joubertnel
joubertnel / example_keyword_varargs.jl
Created November 8, 2020 19:13
Julia keyword varargs
# define a function, g, which takes an arbitrary number of keyword arguments and
# prints the keys and values of the arguments passed to it.
g(;kwargs...) = (println ∘ collect)(kwargs)
# for more about varargs, optional arguments, and keyword arguments in Julia
# see https://docs.julialang.org/en/v1/manual/functions/
@joubertnel
joubertnel / echo.red
Created July 23, 2016 20:11
echo.red
Red []
forever [
msg: input
if msg = "!quit" [break]
print msg
]
@joubertnel
joubertnel / darwin-nat.c
Last active February 23, 2019 23:06
darwin-nat.c variable shadowing diff
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 8c34aa8a3f..d36e23b450 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -687,7 +687,6 @@ darwin_decode_exception_message (mach_msg_header_t *hdr,
/* Not a known inferior. This could happen if the child fork, as
the created process will inherit its exception port.
FIXME: should the exception port be restored ? */
- kern_return_t kret;
mig_reply_error_t reply;