Skip to content

Instantly share code, notes, and snippets.

View ceving's full-sized avatar
💭
Ejaculating

ceving

💭
Ejaculating
View GitHub Profile
@omegatakuma
omegatakuma / cps.scm
Created March 20, 2012 10:25
[Scheme]CPS
;default
(define (fact lst)
(if (null? (cdr lst))
(car lst)
(begin
(print lst)
(* (car lst) (fact (cdr lst))))))
;CPS
(define (fact/cps lst cont)
(cond
@jlongster
jlongster / gist:2323373
Created April 6, 2012 22:00
LiSP Ch.5: CPS conversion
;; outlet: https://github.com/jlongster/outlet
(define-macro (case c . variants)
`(cond
,@(map (lambda (exp)
(if (== (car exp) 'else)
exp
`((list-find ',(car exp) ,c)
,@(cdr exp))))
variants)))
@UnkindPartition
UnkindPartition / parsec.scm
Created October 17, 2012 07:58
Simple parser combinators in Scheme
(define (return v) (lambda (s ks kf) (ks v s)))
(define fail (lambda (s ks kf) (kf)))
; >>=
(define (bind a f)
(lambda (s ks kf)
(a s
(lambda (av s1) ((f av) s1 ks kf))
kf)))
@dginev
dginev / BasicAmbiguity.pl
Created September 3, 2013 02:41
Basic Math ambiguity - sin vs division
#!/usr/bin/env perl
use Marpa::R2;
use warnings;
use strict;
my $basic_math_grammar =
Marpa::R2::Scanless::G->new({
action_object => 'BasicMath',
default_action => '::first',
source => \(<<'END_OF_RULES'),
@rickhull
rickhull / .emacs
Last active January 27, 2016 09:33
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; use setq-default so modes that want tabs can enable this
(setq-default indent-tabs-mode nil)
(defun rick-sh-mode ()
"2 space indent"
(interactive)
(setq sh-basic-offset 2
sh-indentation 2))
(add-hook 'sh-mode-hook 'rick-sh-mode)
@james-d
james-d / AnimationTimerTest.java
Last active May 28, 2023 08:02
Experiment to see how smooth animation is in JavaFX using an AnimationTimer to update the view on each pulse. This simulates 300 balls of various sizes bouncing (with perfect elasticity) off each other and the edges of the Pane in which they're contained. It could easily be extended to a simulation where the pressure on each wall was measured by…
import static java.lang.Math.PI;
import static java.lang.Math.cos;
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;
import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.paint.Color.BLUE;
import static javafx.scene.paint.Color.BROWN;
import static javafx.scene.paint.Color.GREEN;
import static javafx.scene.paint.Color.PINK;
import static javafx.scene.paint.Color.RED;
@rothgar
rothgar / main.yml
Last active March 8, 2024 07:16
Generate /etc/hosts with Ansible
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
@denji
denji / golang-tls.md
Last active May 18, 2024 16:33 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@samhocevar
samhocevar / gist:00eec26d9e9988d080ac
Last active January 13, 2024 23:40
Configure sshd on MSYS2 and run it as a Windows service
#!/bin/sh
#
# msys2-sshd-setup.sh — configure sshd on MSYS2 and run it as a Windows service
#
# Please report issues and/or improvements to Sam Hocevar <sam@hocevar.net>
#
# Prerequisites:
# — MSYS2 itself: http://sourceforge.net/projects/msys2/
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights
#
@ktakashi
ktakashi / cps.scm
Created April 29, 2016 12:26
CPS conversion
;; expression must already be expanded by expander
;; so it shall only have the following syntaxes:
;; - define
;; - lambda
;; - set!
;; - quote
;; - if
;; - begin
;; NB: by this point, all of the optimisation in Scheme level
;; must be done. (e.g. constant folding)