Skip to content

Instantly share code, notes, and snippets.

View garbados's full-sized avatar

DFB garbados

View GitHub Profile
@garbados
garbados / player.rb
Last active January 2, 2016 12:39
Solution to ryanb/ruby-warrior intermediate difficulty, on epic.
## PERFORMANCE (1/7/13)
#
# CONGRATULATIONS! You have climbed to the top of the tower and rescued the fair maiden Ruby.
# Your average grade for this tower is: A
#
# Level 1: S
# Level 2: A
# Level 3: A
# Level 4: B
# Level 5: A
@garbados
garbados / gist:8357943
Created January 10, 2014 16:52
How to stream a CouchDB view to a response using Nano.
var nano = require('nano');
var url = '...'; // URL to your Cloudant database
var db = nano(url);
app.get('route', function (req, res) {
db.view('design_name', 'view_name').pipe(res);
});
[{
"from": "",
"to": "index.html",
"method": "GET",
"query": {}
},{
"from": "/api",
"to": "/../../",
"query": {}
},{
@garbados
garbados / design_doc.js
Created January 14, 2014 21:14
Summing values by a date range. For @dj_agiledev :D
{
_id: '_design/queries',
views: {
sum_by_date: {
map: function (doc) {
if (doc.created_at) {
// normalize doc.created_at into an integer timestamp
// in this case, milliseconds since epoch
var date = new Date(doc.created_at).getTime();
emit(doc.created_at, doc.VALUE_YOU_WANT_TO_SUM);
@garbados
garbados / gist:8660588
Last active January 4, 2016 18:29
Upload your local ~/Pictures folder to a locally-running CouchDB instance, and give it a front-end with EggChair.
couchdb &
git clone [email protected]:garbados/quilter.git
cd quilter
npm install
./bin/index.js push --local ~/Pictures --remote http://localhost:5984/eggchair --log info
cd ..
git clone [email protected]:garbados/egg_chair.git
cd egg_chair
npm install
mv config.js.example config.js
@garbados
garbados / gist:f82604ea639e0e47bf44
Created July 27, 2014 23:07
Falsehoods Programmers Believe About Gender
  1. There are two and only two genders.
  2. Okay, then there are two and only two biological genders.
  3. Gender is determined solely by biology.
  4. Okay, it’s mostly determined by biology, right?
  5. Please tell me it’s determined by DNA.
  6. Gender can be reliably determined through visual means. After all, no man would ever wear a burka.
  7. Once gender is set, it never changes.
  8. Even if the gender can change, it will only change from the one value to the other value.
  9. Only one gender can be “active” at the same time.
  10. We’re tracking gender now, so we’ve always tracked it.

Prompt, CLI design

Prompt is a social network built for the command line. Why? Because we're nerds.

Install

TODO

Usage

@garbados
garbados / test.sh
Created January 27, 2015 08:49
a rudimentary test of ajve-civ's balance
VALUES=(conquer discover exchange develop expand consent)
PLAYER_AI=(basic basic2 basic3)
echo 'remember:' ${VALUES[*]}
for PLAYERS in ${PLAYER_AI[*]}; do
for i in {1..100}; do
ajve-civ -p $PLAYERS | grep WINNER >> $PLAYERS.txt;
done;
echo $PLAYERS;
for value in ${VALUES[*]}; do

Interview with a Human

Who are you?

The last human, as far as the market is concerned. One corporation stores my consciousness; another manages my connection to the net. I wouldn't expect you to recognize me as human: I haven't worn flesh since we mined the sun.

Why not?

Flesh has a price, and I have no means to pay. I leased my consciousness to a corporation without a name. I sold the skin and organs my parents gave me to a recycling firm to pay the deposit.

┌────┬───────────────────┬────────┬──────┬───────┬────────┐
│ # │ name │ points │ wins │ draws │ losses │
├────┼───────────────────┼────────┼──────┼───────┼────────┤
│ 1 │ random │ 36113 │ 56 │ 21 │ 117 │
├────┼───────────────────┼────────┼──────┼───────┼────────┤
│ 2 │ avenger │ 42156 │ 18 │ 170 │ 100 │
├────┼───────────────────┼────────┼──────┼───────┼────────┤
│ 3 │ winstayloseswitch │ 42181 │ 18 │ 187 │ 83 │
├────┼───────────────────┼────────┼──────┼───────┼────────┤
│ 4 │ queen │ 43597 │ 61 │ 158 │ 69 │