Skip to content

Instantly share code, notes, and snippets.

@maxsu
maxsu / Circle Packing Script
Created July 17, 2015 06:57
A circle packing script in rhinoscript, for rhino 3d 4.0 only.
Option Explicit
'Script written by Steven Janssen
'Script copyrighted by Steven Janssen
'Script version Sunday, 18 May 2008 11:34:18 AM
Call Main()
Sub Main()
Dim arrPoint(), arrRadius(), intCircleNumber, arrInputR, arrSide(2)
Dim strCurrentCircleID, R, intCurrentCentre, k
Dim dblCosA, dblRotA
(import '(java.awt Point Graphics Frame) '(java.awt.geom AffineTransform))
(def minpoint (doto (Point.) (.setLocation 0 0)))
(def maxpoint (doto (Point.) (.setLocation 1000 1000)))
(defn draw [pts #^Frame w]
(doseq [[x y] pts] (.fillRect (.getGraphics w) x y 1 1)))
(let [w (doto (Frame. "Bitmap") (.setSize 600 700) (.setVisible true))] ())
@maxsu
maxsu / changes
Created July 12, 2012 12:09
A basic changelog writing, note taking script. Notice the bugs.
#!/bin/dash
logdir=~/logs
log=$logdir/changelog
echo '\n' >> $log
date >> $log
nano $log
@maxsu
maxsu / changes
Created July 13, 2012 12:21
Changelog record finder
# Looks for pattern PATTERN in file input.tex.
# Returns an empty-line delimited block of text surrounding the pattern.
awk
-v "pattern=PATTERN"
-v "bold=$(tput bold)"
-v "sgr0=$(tput sgr0)"
-v RS=
-v 'ORS=\n\n'
@maxsu
maxsu / ggg.pl
Created July 21, 2013 10:23 — forked from avar/ggg.pl
#!/usr/bin/env perl
use v5.10;
use warnings FATAL => "all";
use Dancer;
use URI::Escape qw(uri_escape_utf8);
# This is all the search engine does
get '/search' => sub {
given (param("q")) {
when (/^(?:!(?:ducky)?\s+|\\)(.*)/) { redirect 'http://www.google.com/search?btnI=1&q=' . uri_escape_utf8 $1 }

Working With Github Pages

The FAQ maintained by Github covers most stumbling blocks, some other tips and tricks supplied here.

Gitignore

Add _site to .gitignore. The generated site should not be uploaded to Github since its gets generated by github.

Working With Code Partials

@maxsu
maxsu / Coffee.rb
Last active December 20, 2015 10:39
Rasberry Pi: I Require only the finest Bean
#####################################################################
#
# Author: Max Suica
#
# License: CC-BY-SA
#
# Description: This is some ruby code that will allow a Rasberry Pi
# to make coffee after receiving a command from Siri.
#
# Dependencies:
@maxsu
maxsu / f
Last active December 20, 2015 12:09
Find Script
#!/bin/bash
# usage: myfind [-d DIR] STRING [...]
# finds all files matching any given STRING in DIR, or the current working
# directory if DIR is not provided
arg=.
args=.
dir=.
#!/bin/sh
if [ $# -ne 1 ]; then
echo "usage: $0 [raspbian image]"
exit 1
elif [ ! -f $1 ]; then
echo "Error: File $1 not found." >&2
exit 1
fi