Skip to content

Instantly share code, notes, and snippets.

@gnarmis
gnarmis / racket_quick_intro.rkt
Created January 2, 2019 23:11
A playful introduction to Racket (<60 min activity), with example usage of quickcheck (property based testing)
;; This is a playful introduction to Racket, using the in-built app
;; Dr. Racket, intended for a <60 min session.
;; Racket is a polygot-friendly, language designer friendly, beginner friendly
;; multi-paradigm general purpose programming language.
;; Install Racket and then open this little tutorial using Dr. Racket, by
;; saving it as a "racket_quick_intro.rkt" text file.
;; Download link for Racket: https://download.racket-lang.org
@gnarmis
gnarmis / minmaxheap.py
Created January 27, 2013 10:01
min max heap implementation in python
from math import log, floor, pow
class MinMaxHeap(object):
"""an implementation of min-max heap using an array,
which starts at 1 (ignores 0th element)
"""
def __init__(self, array=[]):
super(MinMaxHeap, self).__init__()
@gnarmis
gnarmis / sensor_loop.xml
Created April 24, 2018 21:57
NEPO program: sensor_loop
<export xmlns="http://de.fhg.iais.roberta.blockly"><program><block_set xmlns="http://de.fhg.iais.roberta.blockly" robottype="ev3" xmlversion="2.0" description="" tags=""><instance x="178" y="45"><block type="robControls_start" id="KF=O@fUtUJy5HXbAjbK(" intask="true" deletable="false"><mutation declare="false"></mutation><field name="DEBUG">FALSE</field></block><block type="robControls_loopForever" id="c30IgWEeP/O-?U4y%vW^" intask="true"><statement name="DO"><block type="robControls_ifElse" id="J[`1E#d%TdTWPv{Km`jh" intask="true"><mutation else="1"></mutation><repetitions><value name="IF0"><block type="logic_compare" id="+Jrku0q15]7@2eB.gHxk" intask="true"><field name="OP">LT</field><value name="A"><block type="robSensors_colour_getSample" id="mN_gllFh2X~)x*7gD17D" intask="true"><mutation mode="LIGHT"></mutation><field name="MODE">LIGHT</field><field name="SENSORPORT">3</field><field name="SLOT"></field></block></value><value name="B"><block type="math_number" id="k=Xc?r[Ty1[.Ovv6E,k-" intask="true"><field nam
@gnarmis
gnarmis / simple_loop.xml
Created April 24, 2018 21:55
NEPO program: simple_loop
<export xmlns="http://de.fhg.iais.roberta.blockly"><program><block_set xmlns="http://de.fhg.iais.roberta.blockly" robottype="ev3" xmlversion="2.0" description="" tags=""><instance x="178" y="45"><block type="robControls_start" id="KF=O@fUtUJy5HXbAjbK(" intask="true" deletable="false"><mutation declare="false"></mutation><field name="DEBUG">FALSE</field></block><block type="robActions_motorDiff_on_for" id="hKd3voniAqPp!8a%}:FS" intask="true"><field name="DIRECTION">FOREWARD</field><value name="POWER"><block type="math_number" id="L`91X?qsI]!R;D%CgIB9" intask="true"><field name="NUM">30</field></block></value><value name="DISTANCE"><block type="math_number" id="b;FkGdy7.O1Uikrp5K.]" intask="true"><field name="NUM">25</field></block></value></block><block type="robActions_motorDiff_turn_for" id="2EKf?d!oGV3Bq/VNSZS[" intask="true"><field name="DIRECTION">LEFT</field><value name="POWER"><block type="math_number" id="PY2+{ds4_(5s1xk3/x_r" intask="true"><field name="NUM">30</field></block></value><value name="DEGRE
@gnarmis
gnarmis / nodesource_setup_8
Created April 2, 2018 21:16
copy of https://deb.nodesource.com/setup_8.x, but without the atrocious ssl cert related error preventing secure `curl`s
#!/bin/bash
# Discussion, issues and change requests at:
# https://github.com/nodesource/distributions
#
# Script to install the NodeSource Node.js v8.x LTS Carbon repo onto a
# Debian or Ubuntu system.
#
# Run as root or insert `sudo -E` before `bash`:
#
@gnarmis
gnarmis / experiments.rb
Created September 21, 2012 09:13
Experimenting with bastardized functional-ness in Ruby
#ruby1.9.3
def defn name, &b
Object.send :define_method, name, &b
end
# this also works (surprisingly), albeit with a warning
# def defn name
# Object.send(:define_method, name)
# end
@gnarmis
gnarmis / Preferences.sublime-settings
Created April 5, 2017 21:37
my sublime text user settings
{
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme",
"ensure_newline_at_eof_on_save": true,
"trim_trailing_white_space_on_save": true,
"font_size": 14,
"ignored_packages":
[
"Vintage"
],
"tab_size": 2,

Setting up Emacs daemon on OS X

Tired of waiting for emacs to start on OS X? This step by step guide will teach you how to install the latest version of emacs and configure it to start in the background (daemon mode) and use emacsclient as your main editor.

Install Homebrew

First you'll need to install the [Homebrew package manager][brew] if yo haven't already. It is amazing.

{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* To use: copy this file to ~/Library/KeyBindings/
* after that any Cocoa applications you launch will inherit these bindings
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
@gnarmis
gnarmis / yummly-api.clj
Last active December 14, 2015 17:59
Yummly API
(defn yummly-api [auth]
{:endpoint "http://api.yummly.com/v1"
:resources {:recipe-search "/api/recipes"}
:params ["q", "requirePictures", "allowedIngredient[]", "excludedIngredient[]",
"allowedDiet[]", "allowedAllergy[]", "allowedCuisine[]",
"allowedCourse[]", "allowedHoliday[]", "excludedCuisine[]",
"excludedCourse[]", "excludedHoliday[]", "maxTotalTimeInSeconds",
"nutrition.ATTR.{min|max}", "maxResult", "start",
"flavor.ATTR.{min|max}", "facetField[]"]
:auth {"_app_id" (:app-id auth),