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 / 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 / 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 / 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;
@joubertnel
joubertnel / gist:1f0233cb0a290950f2d4b8fafcd2979c
Created February 19, 2019 14:30
darwin-nat.c variable shadowing
darwin-nat.c: In function 'int darwin_decode_exception_message(mach_msg_header_t*, inferior**, darwin_thread_t**)':
darwin-nat.c:690:21: error: declaration of 'kret' shadows a previous local [-Werror=shadow=compatible-local]
kern_return_t kret;
^~~~
darwin-nat.c:626:17: note: shadowed declaration is here
kern_return_t kret;
^~~~
darwin-nat.c: In function 'ptid_t darwin_decode_message(mach_msg_header_t*, darwin_thread_t**, inferior**, target_waitstatus*)':
darwin-nat.c:1128:14: error: declaration of 'res' shadows a previous local [-Werror=shadow=compatible-local]
pid_t res;
Rebol []
forever [
data: input
if data = "!quit" [break]
print data
]
@joubertnel
joubertnel / echo.red
Created July 23, 2016 20:11
echo.red
Red []
forever [
msg: input
if msg = "!quit" [break]
print msg
]
@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_