Skip to content

Instantly share code, notes, and snippets.

@jasonrobot
jasonrobot / gist:0955d9ea0e81c9fe925ec1725d4742f4
Created December 19, 2018 17:27
Code documentation guidelines
Every command, function, or variable intended for users to know about should have a documentation string.
An internal variable or subroutine of a Lisp program might as well have a documentation string. Documentation strings take up very little space in a running Emacs.
Format the documentation string so that it fits in an Emacs window on an 80-column screen. It is a good idea for most lines to be no wider than 60 characters. The first line should not be wider than 67 characters or it will look bad in the output of apropos.
Use blank lines between sections if the documentation string is long.
The first line of the documentation string should consist of one or two complete sentences that stand on their own as a summary. M-x apropos displays just the first line, and if that line's contents don't stand on their own, the result looks bad. In particular, start the first line with a capital letter and end it with a period.
;;; General form
;;; CL has two fundamental pieces of syntax: ATOM and S-EXPRESSION.
;;; Typically, grouped S-expressions are called `forms`.
10 ; an atom; it evaluates to itself
:thing ; another atom; evaluating to the symbol :thing
t ; another atom, denoting true
(+ 1 2 3 4) ; an s-expression
'(4 :foo t) ; another s-expression
@jasonrobot
jasonrobot / game.fnl
Created October 8, 2018 16:57
Basic loading for fennel files in lua/love
(fn love.draw []
(love.graphics.print "Hello World!" 400 300))
@jasonrobot
jasonrobot / disable.rb
Last active October 6, 2018 07:21
Disable all youtube notifications for all channels
# So recently I noticed that I was getting notifications on YouTube for channels that I had not enabled any notifications for.
# I checked in the youtube settings (see the url in this script), and realized that for some reason they had ALL been
# enabled. I wanted to disable them all, but I have several hundred channels that I sub to, and didn't want to go through
# all of them and click the option.
#
# Selenium to the rescue!!!
#
# So, you need to somehow get in to a session with your account signed in. I just started the driver, put a 40 second sleep,
# then signed in manually. Then the next time I ran this script, the driver was in my session. I dunno, not used to it working
# like that.
@jasonrobot
jasonrobot / br.pl
Last active July 6, 2018 19:41
Make a break in your terminal without clearing the screen! Give it an arg for how many lines you want (default 3).
#! /usr/bin/env perl
use strict;
my $default = 3;
my $lines = @ARGV[0] || $default;
$lines = 3 if $lines < 0;
for( my $i = $lines; $i > 0; $i-- ) {
if ( $i == ($lines / 2) ||
$i == (($lines + 1) / 2) ) {
(in-package :cl-user)
(defpackage :hello-world-system
(:use :asdf))
(in-package :hello-world-system)
(defsystem "hello-world"
:version "0.1.0"
:author "Jason"
:license "LLGPL"
:description "Say hi."
@jasonrobot
jasonrobot / test-ng-deps.java
Created May 15, 2018 23:45
Z runs, Y runs and fails, X skips, W goes anyways, but after Y.
public class TestTestDeps
{
@Test(alwaysRun = true)
public void testZ()
{
System.out.println("z is running");
assertEquals(1, 1);
}
@Test(dependsOnMethods = "testZ")
@jasonrobot
jasonrobot / timer.lisp
Created May 8, 2018 22:58
Simple command line invoked timer. I plan to add some way of notifying.
#!/usr/bin/sbcl --script
;;; Documentation:
;;; Commentary:
;;; Code:
(defun timer-tick ()
"Waits for 1 second"
<project name="MyProject" default="dist" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<target name="init">
@jasonrobot
jasonrobot / sequence-functions.lisp
Last active December 28, 2018 07:06
Common lisp, why no have common sequence functions!?! >:-|
(defun all (seq fn)
"Immediately return NIL if FN returns NIL for any item in SEQ."
(loop for i in seq
always (funcall fn i)))
(all '(1 2 3) (lambda (x) (< x 5)))
;; => T
(all '(1 2) (lambda (x) (= x 1)))
;; => NIL