Skip to content

Instantly share code, notes, and snippets.

View justinmeiners's full-sized avatar

Justin Meiners justinmeiners

View GitHub Profile
(use srfi-1)
(define (advance ls n)
(if (< n 1)
ls
(advance (cdr ls) (- n 1))))
(define (subset ls start count)
(define (build-cell it i)
(if (= i count)
@justinmeiners
justinmeiners / sqrt.py
Last active June 10, 2019 18:16
I explained to a friend how sqrt can be implemented.
import math
def sqrt(x_0, guess, tol):
x = guess
while math.fabs(x*x - x_0) > tol:
x = (x*x - x_0) / (2.0 * x)
return x
print(sqrt(2.0, 2.0, 0.0001))
(define (eval-html templ env)
(define (lookup-var key env)
(let ((pair (assoc key env)))
(if (pair? pair)
(cdr pair)
'())))
(define (tag? templ)
# Created By: Justin Meiners (2012)
# This was really useful at one point. I doubt it still is.
from pymel.all import *
import pymel
selection_list = pymel.core.ls(type="transform", selection=True)
for node in selection_list:
node.centerPivots()
point = node.getRotatePivot(space="world")
@justinmeiners
justinmeiners / parenscript-first-trial.lisp
Created July 15, 2018 01:41
Playing around with ParenScript.
; ParenScript experiment
; https://common-lisp.net/project/parenscript/reference.html
; https://gitlab.common-lisp.net/parenscript/parenscript
; typical functions
(defun fib (n)
(cond ((= n 0) 0)
((= n 1) 1)
(t (+ (fib (- n 1)) (fib (- n 2))))))
@justinmeiners
justinmeiners / dutch_auction.sol
Last active September 15, 2018 05:53
Dutch auction smart contract for a presentation.
// Created By: Justin Meiners (2018)
pragma solidity ^0.4.24;
// https://en.wikipedia.org/wiki/Dutch_auction
contract DutchAuction {
uint public askingPrice;
address public auctioneer;
address public winner;
address public seller;
@justinmeiners
justinmeiners / teaching_python.py
Last active September 15, 2018 05:23
Examples from python lessons I taught.
# Created By: Justin Meiners (2017)
# simple calculations
# -------------------------------
import math
def volume_cone(radius, height):
volume = math.pi * (radius**2.0) * (height / 3.0)
return volume
@justinmeiners
justinmeiners / learn_you_a_haskell.md
Last active April 3, 2019 21:47
My notes from reading "Learn You a Haskell for Great Good". I needed to crunch some haskell for a work project.

Learn You a Haskell Notes

Learn You a Haskell For Great Good

I tried going through this book a few times when I was younger, but lacked the mathematical knowledge to understand a lot of what was going on. Now the functional ideas and type system are a breeze but lazinesss is still very new and mysterious.

Haskell Overview

Referential transparency: if a function is called multiple times with the same inputs, it will produce the same outputs.

@justinmeiners
justinmeiners / write_struct.c
Created October 30, 2018 03:28
How to copy a struct into a byte buffer.
// how to write a struct to a buffer.
typedef struct {
int version;
int count;
char id[8];
} FileInfo;
FileInfo info;