Skip to content

Instantly share code, notes, and snippets.

@flux77
flux77 / .gitignore
Created April 23, 2021 15:52 — forked from bradfordw/.gitignore
A n00bs crack at an evolutionary algorithm in Erlang
*.beam
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<unistd.h>
#include<ncurses.h>
#define BLACKJACK 21
#define GAMEPOINTS 3
#define TRUE 1
@flux77
flux77 / bazaar-to-git.md
Created April 6, 2021 13:41 — forked from josejuansanchez/bazaar-to-git.md
How to import the p2psp bazaar repository in GitHub

1. Install bzr and bzr-fastimport

sudo apt-get install bzr
sudo apt-get install bzr-fastimport

2. Get the trunk branch from launchpad

bzr branch lp:p2psp 
@flux77
flux77 / debugger-wannabe.lisp
Created March 25, 2021 13:28 — forked from alexander-yakushev/debugger-wannabe.lisp
Debugging functions for SBCL
(declaim (optimize (debug 2)))
;; Part one.
(defun line-number (fname code-loc)
(let* ((all-offsets (sb-di::debug-source-start-positions code-loc))
;; Get last item from the array, I haven't found anything
;; like 'pop' to do it better.
(offset (aref all-offsets (- (length all-offsets) 1))))
(with-open-file (f fname)
@flux77
flux77 / rose.ml
Created November 28, 2020 16:17 — forked from superbobry/rose.ml
Basic Rose Trees in OCaml
open StdLabels
type 'a tree = Node of ('a * 'a tree list)
let rec make ~f init =
let (label, forest) = f init in
Node (label, (List.map ~f:(make ~f) forest))
and draw ~f (Node (label, forest)) =
let rec inner = function
@flux77
flux77 / print_list.ml
Last active September 13, 2019 18:11
OCaml functions for printing lists of strings, lists of chars, lists of ints, and lists of floats.
(* Functions for printing lists of strings, lists of chars, lists of ints,
* and lists of floats.
* *)
(* Helper function. *)
let print_list to_string l =
let rec loop rem acc =
match rem with
| [] -> acc
| [s] -> acc ^ (to_string s)
@flux77
flux77 / print_binary_bits.c
Last active September 13, 2019 17:48
Prints binary representation of any data type in C (including ints, arrays, structs, etc.)
/* Prints binary representation of any data type in C (including ints, arrays, structs, etc.).
* Assumes big endian.
* Adapted from: https://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format
*
* Example use:
* int i = 123456789;
* print_bits(&i, sizeof i);
* Prints: 00010101 11001101 01011011 00000111
* */
void print_bits(void const * const ptr, size_t const size) {
/* Improved version for https://codereview.stackexchange.com/questions/228979/read-string-of-any-length-in-c */
#include <stdlib.h>
#include <stdio.h>
/* Reads string input up to, but not including, the first newline or EOF.
* Returns a pointer to the string, or NULL on error.
* The pointer to the string must be freed.
*/
char* input() {