Skip to content

Instantly share code, notes, and snippets.

View codecop's full-sized avatar

Peter Kofler codecop

View GitHub Profile
@jolod
jolod / exceptional.py
Last active November 25, 2024 08:58
Demonstration of how to (not) use exceptions and try/catch to do control flow and assignment.
# Copyright © 2024 Johan Lodin
# License: CC BY-SA 4.0
# This is a demonstration of how to (not) use exceptions and try/catch to do control flow.
# - Essentially `try` and `except` make up a match construct.
# - Instead of `return`ing the result is `raise`d.
# - Instead of assigning the result from a function call, the function is `try`ed and the result is caught.
# - The `interpret` function takes an "exceptional" result into Python data (only here is `return` used as we leave the world of exceptions).
class List(Exception): pass
@FedericoPonzi
FedericoPonzi / not_expected_to_understand_this.md
Created December 18, 2016 11:38
Line 2238 Unix V6 Comment: You are not expected to understand this.

Here is the famous line 2238 of Unix V6 which is part of some of the most delicate parts of the kernel, context switching.

This comment received huge publicity and just may be the the most famous source code comment in computing history.

2230	/*
2231	 * If the new process paused because it was
2232	 * swapped out, set the stack level to the last call
3333	 * to savu(u_ssav).  This means that the return
2235	 * actually returns from the last routine which did

2236 * the savu.

package com.spun.triangles.test;
import static org.junit.Assert.assertEquals;
import java.util.Random;
import org.junit.Test;
/**
* Theory based kata
@jonelf
jonelf / random_fizzbuzz.rb
Last active October 3, 2017 21:32
A "random" FizzBuzz in Ruby. This is just for fun.
c = ('a'..'z').to_a
srand(1792579 * 1800)
f = (0..3).map { c[rand(26)] }
b = (0..3).map { c[rand(26)] }
a = [f, b].map {|s| s.join.capitalize }
srand(s = 93113 * 19243)
puts (0..99).map{|i| [a[0], a[0] + a[(srand(s) if i%15 < 1) || 1].to_s, a[1], i+1][rand(4)] }
@lyuboraykov
lyuboraykov / printjenkins.groovy
Last active May 14, 2025 11:42
Print to console in Jenkins Groovy system script
def out
def config = new HashMap()
def bindings = getBinding()
config.putAll(bindings.getVariables())
out = config['out']
out.println "Printed do Jenkins console."