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 / gist:7150535
Created October 25, 2013 07:07
This is my uploaded cheat sheet to typing.io that I'm using in order to master the most basic of Javascript language declarations. I was told that I should be able to type any one of these fragments in roughly 5 seconds, so I'm aiming for 3 apiece.
//THIS IS MY STUDY SHEET FOR TYPING.IO FOR GETTING INTO HACK REACTOR
//IF ANYONE ELSE EVER SEES THIS< PLEASE BE OK WITH USING IT.
var myFunc = function(arg1, arg2) {
};
for(var i = 0; i< array.length; i++){
};
@MrNice
MrNice / ajumblefun
Last active December 28, 2015 20:09
Dictionary jumble solver, created at Hack Reactor's Biweekly algorithm meetup. This is a recursive, functional version, which aims to be more legible. It's not.
// Functional Jumble Solver in Javascript!
// Nicholas, Mike, William
// https://github.com/MrNice
// https://github.com/mmessing
// https://github.com/oddalot
//Will add tests and timers later. I want to make this //fast//
var fs = require('fs');
var _ = require('underscore');
@MrNice
MrNice / cycle.js
Created March 11, 2014 03:36
Cycle function for sliderSolve
var cycle = function(moveArray, times, direction) {
var i,
j,
length;
times = times || 1;
direction = direction || 'cw';
for( i = 0 ; i < times; i++ ) {
var copy = moveArray.slice();
@MrNice
MrNice / gist:d78fc685532779d9e09f
Created April 30, 2014 22:22
A simple HTML page that has all of Khan Academy's Culture Cow Blurts for easy consumption
<html>
<head>
<title>List of khanacademy culture things</title>
</head>
<body>
<script>
var culturalMsgs = [
"<a href='https://sites.google.com/a/khanacademy.org/forge/for-developers'>Shipping beats perfection</a>.",
"Iterate on ideas before diving into code. <a href='http://www.designstaff.org/articles/product-design-sprint-day-2-diverge-2012-10-26.html'>Design sprints</a> are being organized by Jason and others and work well for both huge projects and small features.",
"Concerned about the hacks in our code? Upset that the product's not good enough? Have no fear, we're getting better fast. Our site used to <a href='https://s3.amazonaws.com/KA-share/old.png'>look like this</a> and it was generated by one big main.py file.",
@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('&');
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 / 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.

@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 / 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 / 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