Skip to content

Instantly share code, notes, and snippets.

View MrNice's full-sized avatar

Nicholas van de Walle MrNice

View GitHub Profile
@MrNice
MrNice / Default
Created May 23, 2017 04:02
Default clanlord macros
// This macro file is included for every character by default.
// Use it for general macros that you want available to all characters.
//
"??" "/help " @text "\r"
"aa" "/action " @text "\r"
"gg" "/give " @text "\r"
"ii" "/info " @text "\r"
"kk" "/karma " @text "\r"
"mm" "/money\r"
@MrNice
MrNice / core.cljs
Created February 2, 2016 03:39
Clojure(Script) calculator
(ns calc.core)
(comment
The art of programming is very difficult to explain.
Without concrete examples, explaining programming is
similar to explaining "what does the ocean taste like"
to an alien who cannot taste salt.
The simplest definition of programming is to say it is
simply telling a computer what to do in a very precise way.
@MrNice
MrNice / taxes.md
Last active January 22, 2016 17:41
Increase Transparency, Increase Trust

I live in the United States and work a salaried job.

A full third of my income goes to taxes.

Federal Taxes account for one fourth of that.

Put another way, if all taxes were eliminated, I would make one and a half times more.

However, I don't think paying taxes is a bad thing.

@MrNice
MrNice / api-peek.sh
Created December 2, 2015 18:48
API Peek
# get these into your shell somehow
# apI PeeK: Look at an API response and temp save it
function ipk {
echo "Don't use the output flag from curl as it redirects"
curl "$@" | python -m json.tool | tee "apipeek.json" | less
}
# I PicK UP: rename the peeked api response (just partially applied mv)
function ipkup {
@MrNice
MrNice / blogpost.md
Last active February 17, 2023 09:46
Explain how to think about ansible and how to use it

Ansible

Understanding Ansible

Ansible is a powerful, simple, and easy to use tool for managing computers. It is most often used to update programs and configuration on dozens of servers at once, but the abstractions are the same whether you're managing one computer or a hundred. Ansible can even do "fun" things like change the desktop photo or backup personal files to the cloud. It can take a while to learn how to use Ansible because it has an extensive terminology, but once you understand the why and the how of Ansible, its power is readily apparent.

Ansible's power comes from its simplicity. Under the hood, Ansible is just a domain specific language (DSL) for a task runner for a secure shell (ssh). You write ansible yaml (.yml) files which describe the tasks which must run to turn plain old / virtualized / cloud computers into production ready server-beasts. These tasks, in turn, have easy to understand names like "copy", "file", "command", "ping", or "lineinfile". Each of these turns into shell comma

@MrNice
MrNice / docktest.yml
Created November 21, 2015 01:33
Ansible Mac OS X install app w/ brew and add to the Dock
# TODO: Get version from registering output of brew cask install
- name: "install browser: {{ browser }}"
homebrew_cask: >
name={{ browser }}
state=present
- name: read defaults to know what to add to the dock
shell: defaults read com.apple.dock
register: apple_defaults
@MrNice
MrNice / doWork.js
Created November 20, 2015 23:31
How to work
function work(project) {
project.setup();
while (not(project.finished)) {
try {
project.next();
} catch (unknown) {
reality = think(unknown);
mental-model = visualize(mental-domain-model, project.current-task);
solution = search(difference(mental-model, reality));
project.debug(solution);
@MrNice
MrNice / gist:b64f6b5b98a64433d0b4
Last active August 6, 2019 10:36
Mimic Polymer with Reagent

I enjoy playing with the myriad of frameworks and toolkits which are available for modern web application development. One of the more interesting and practical projects in recent years has been Polymer, a Polyfill runtime to give browser the ability to use web components, today. After Polymer hit 1.0 at Google I/O, I decided that it was worth taking another look.

What I found surprised me - using Polymer is actually quite similar to ClojureScript programming. The main difference is that Polymer draws too much inspiration from imperative programming languages, even though it is essentially a declarative layer atop JavaScript and HTML.

Below, I compare the two in as much detail as I can.

A Polymer Component

Here's one of the advanced examples from the current Polymer site.

Up front, the major differences between CLJS & Polymer versions
1. Polymer version is easier to load asynchronously; it brings its own stylesheet
2. CLJS version uses a `map`, doesn't need special inner template
3. CLJS version data flow is clearer, once one accepts the reagent/atom
4. CLJS version doesn't need the first template, as one simply calls the function as needed
5. Polymer version needs the dom-module tag and an id, CLJS doesn't
6. I have no idea what the performance difference between these components is. Hiccup -> HTML is an extra conversion, but so is HTML -> JS -> HTML.
Altogether, there aren't very many differences between these a Reagent component and a Polymer component.
@MrNice
MrNice / Fun functional object version
Last active August 29, 2015 14:19
QueryString manipulator
// Fun to write an understand version
var R = require('ramda');
function queryToObject(qString) {
// strip ?
// split on &
// split on =
// fromPairs
var noQuestionMark = qString.slice(1);
var kvArray = noQuestionMark.split('&');