Skip to content

Instantly share code, notes, and snippets.

View sysupgrade.patch
Index: sysupgrade.sh
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.26
diff -u -p -r1.26 sysupgrade.sh
--- sysupgrade.sh 14 Oct 2019 06:58:53 -0000 1.26
+++ sysupgrade.sh 15 Oct 2019 19:30:14 -0000
@@ -25,7 +25,7 @@ umask 0022
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
View quantum-box.py
#!/usr/bin/env python3
"""
Animation of the Schrodinger equation for a particle in a 1D box
-∂²/x² ψ(x,t) = i/t ψ(x,t) (natural units)
for a non-eigenstate initial state ψ, with boundary conditions
ψ(0,t) = ψ(1,t) = 0.
View bitfields.rs
#![feature(macro_rules)]
#![feature(globs)]
use std::fmt::*;
macro_rules! bitfield(
{ $name:ident: $repr:ty,
$(($getter:ident, $setter:ident): $width:expr),+ } => (
#[packed]
#[deriving(Show)]
struct $name($repr);
View MapMacro.rs
#![feature(macro_rules)]
use std::collections::HashMap;
macro_rules! map(
{ $T:ident $($args:tt)* } => {
{
let mut m = $T::new();
map_insert! { m $($args)* }
}
@joedavis
joedavis / singleton.hh
Created Jan 1, 2014
Singleton with statically allocated storage, useful for embedded systems, operating system kernels and driver development.
View singleton.hh
// Singleton with statically allocated storage, useful for embedded systems,
// operating system kernels and driver development.
/*
* Written in 2014 by Joe Davis <joe.davis512@gmail.com>
*
* To the extent possible under law, the author(s) have dedicated all copyright
* and related and neighboring rights to this software to the public domain
* worldwide. This software is distributed without any warranty.
*
@joedavis
joedavis / let-example.c
Created Dec 27, 2010
"Let" special form, in C
View let-example.c
/* Example usage of "let" */
#include "let.h"
int
main (int argc, char *argv[])
{
let ((x, 42),
(y, 3.14159))
{
@joedavis
joedavis / foreach.h
Created Oct 18, 2010
Foreach loop in C
View foreach.h
/* Foreach loop in GNU C, released in the public domain by Joe Davis.
* Credit would be nice ;)
*/
#ifndef FOREACH_H_
#define FOREACH_H_
#include <stdbool.h>
#include <string.h>