Skip to content

Instantly share code, notes, and snippets.

View nicerobot's full-sized avatar
๐Ÿค–
โ˜ฏ๏ธ โ˜ฎ๏ธ ๐Ÿถ ๐Ÿพ ๐Ÿ‘พ ๐ŸŽฎ ๐ŸŽผ ๐ŸŽถ ๐Ÿ•บ ๐ŸŽง ๐ŸŒป ๐ŸŒฑ ๐Ÿž ๐ŸŒŠ ๐ŸŒ” ๐ŸŒŽ

nicerobot

๐Ÿค–
โ˜ฏ๏ธ โ˜ฎ๏ธ ๐Ÿถ ๐Ÿพ ๐Ÿ‘พ ๐ŸŽฎ ๐ŸŽผ ๐ŸŽถ ๐Ÿ•บ ๐ŸŽง ๐ŸŒป ๐ŸŒฑ ๐Ÿž ๐ŸŒŠ ๐ŸŒ” ๐ŸŒŽ
View GitHub Profile
@nicerobot
nicerobot / co.reasoning.scala
Last active August 7, 2022 16:35
Scala generics, "simplified", covariance and contravariance.
// This is an example of how to reason about covariance vs contravariance.
// Between the two co*.reasoning.scala examples, the following compiles but meaning is slightly different due to the class hierarchy.
type SHORT = A[SMALL]
type INT = A[MEDIUM]
type LONG = A[LARGE]
val s:SHORT = new SHORT()
val i:INT = s
@nicerobot
nicerobot / README.md
Last active December 12, 2015 09:28
An Akka 2.1 simplified from the PiCalculation example.
@nicerobot
nicerobot / README.md
Last active December 13, 2015 20:18
Hmm, personally, what's needed is for compilers to provide nice graphs of the structure of the code.

Let's say i want to apply functions a, b, c, and d to each element of a list, xs, such that the result of a is passed to b who's result is passed to c who's result is passed to d. It's:

xs.map(a).map(b).map(c).map(d)

or

xs.map(d(c(b(a(_)))))

To me, that's clear (assuming the naming is clearly defined), but it probably doesn't read well since, at least in english, we read left to right, not inside-out (nor right to left).

@nicerobot
nicerobot / install.sh
Last active December 14, 2015 08:39
Heroku-like
#!/bin/bash
# http://www.readability.com/read?url=http://pynash.org/2013/02/25/Heroku-Like-Deploys-on-AWS.html
# http://stackoverflow.com/questions/5009324/node-js-nginx-and-now
app=${1:-app${RANDOM}}
cd
# TODO provision
@nicerobot
nicerobot / README.md
Last active January 18, 2016 19:21
pkg-config for gdal to allow go-gdal to build
@nicerobot
nicerobot / README.md
Last active December 15, 2015 04:39
Simple Scala DI

In Scala, "DI" should stand for "Default/Implicit".

curl -ks  https://gist.githubusercontent.com/nicerobot/5203624/raw/di.sh | bash -

A simple type of dependency injection can be accomplished with default parameters. It is enhanced further with implicits.

It's not perfect. For example, implicits don't seem to cascade so the ones to inject have to be explicitly defined each time. But the primary reason for DI is to decouple code (while costing simplicity). I think this approach accomplishes the goal and with less complexity because it doesn't require any framework and relies on rudimentary Scala features.

@nicerobot
nicerobot / gist:5207637
Last active December 15, 2015 05:18
csv2tsv in python
#!/bin/bash
csv2tsv() {
local tsv=$(dirname ${1})/$(basename ${1} .csv).tsv
python -c "import csv; csv.writer(file('${tsv}', 'w+'), delimiter='\t').writerows(csv.reader(open('${1}')))"
}
@nicerobot
nicerobot / usage.sh
Created March 24, 2013 21:12
How to incorporate usage into sh
#!/bin/bash
grep "^## " "$0" | cut -c 4- | groff -Tascii -man | more
## .TH USAGE 1 "March 24 2013" "Version 1.0" "USER COMMANDS"
## .\" strings
## .ds ex \fIexpr\fR
## .SH NAME
## usage \- example of incorporating usage
## .SH SYNOPSIS
@nicerobot
nicerobot / README.md
Last active December 15, 2015 08:49
d3 gist post-ready updater. For example, including a gist in tumblr blogs.

Add before /body:

<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//gist.googlecode.com/svn/trunk/kares/script.js"></script>
<script src="//gist.googlecode.com/svn/trunk/nicerobot/5233890/replacegista.js"></script>

You can then just add normal markdown references to a gist like this gist and it'll find them and replace them with the embedded gist. Example tumblr post.

I looked at soemarko/1395926 but I didn't want to have to use a div since Markdown already inserts a link. Also, it degrades nicely in case something with the scripts breaks. Lastly, D3 is much more fun than jQuery :P

@nicerobot
nicerobot / README.md
Last active December 15, 2015 12:19
sqlalchemy test
curl -ks https://gist.github.com/nicerobot/5259643/raw/run.sh | bash -

Python code swiped from this stackoverflow.