Skip to content

Instantly share code, notes, and snippets.

View lessandro's full-sized avatar

Lessandro Mariano lessandro

View GitHub Profile
16:03 < saml> that's fun
16:03 < saml> SQL is a fun language
16:03 < saml> structured query language
16:03 < saml> it's pretty nice... you get to query relational databases
16:03 < saml> relations are superset of functions
16:04 < saml> so, in a way SQL is querying categories
16:04 < quanticle> saml: SQL is Haskell? :D
16:04 < saml> natural transmorphism endofunctors some might say
16:05 < lzm> saml: cant tell if trolling or way too smart
‎13:57 < lzm> saml: also, why are sql databases natural transmorfism endofunctors?
13:59 < saml> you know relation/
13:59 < saml> relation
13:59 < saml> relation is a pair or tuple
13:59 < saml> (a,b) a is related to b
14:00 < saml> and database table is a collection of those tuples
14:00 < saml> so a table can represent a function (like truth table, for example)
14:01 < saml> now, if you go up one category, you can store functions (tables) in columns of a table
14:01 < saml> for practicality, you store table ids
14:01 < saml> (table_id_1, table_id_2, ...) that's a row of this meta table
<!-- gist -->
<div class="alert gist"><div class="body"><span class="mini-icon mini-icon-gist"></span>
<div class="title">
<a href="/saml">saml</a> <span>created</span> <a href="https://gist.github.com/2854398">gist: 2854398</a>
<time class="js-relative-date" datetime="2012-06-01T19:00:27Z" title="2012-06-01 19:00:27">a day ago</time>
</div>
<div class="details">
<div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/ed429134d47c8baa4a9a419ed4c4eeeb?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30"></div>
Tracing route to newark1.linode.com [207.192.68.6]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.20.1
2 11 ms 9 ms 9 ms 177.17.88.1.static.host.gvt.net.br [177.17.88.1]
3 12 ms 10 ms 8 ms corporativo.host.gvt.net.br [189.115.192.1]
4 26 ms 23 ms 23 ms gvt-ge-5-0-0-rt01.rjo.gvt.net.br [189.59.244.230]
5 20 ms 24 ms 23 ms TenGigabitEthernet7-4.ar1.GIG1.gblx.net [64.214.130.113]
6 143 ms 143 ms 144 ms te2-1-10G.asr1.EWR2.gblx.net [67.16.136.230]
7 149 ms 151 ms 148 ms xe-1-0-2.ar2.ewr1.us.nlayer.net [69.31.94.133]
@lessandro
lessandro / gist:2426130
Created April 20, 2012 05:00
puzzle #3 (ugly code (also wrong))
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstring>
#define foreach(x) for (typeof((x).begin()) it = (x).begin(); it != (x).end(); ++it)
using namespace std;
vector<pair<int, int> > ateam, bteam, *teams, *oldteams;
@lessandro
lessandro / gist:2425458
Created April 20, 2012 02:44
puzzle #2
import sys
import math
# yes, stolen from wikipedia.
def binomialCoefficient(n, k):
if k < 0 or k > n:
return 0
if k > n - k: # take advantage of symmetry
k = n - k
@lessandro
lessandro / gist:2425452
Created April 20, 2012 02:43
puzzle #1. <algorithm> is just awesome.
#include <algorithm>
#include <cstdio>
#include <cstring>
#define BUFSIZE (sizeof("aa/bb/cccc"))
using namespace std;
bool leap(int year)
{
@lessandro
lessandro / hack.sh
Created April 16, 2012 15:21 — forked from dforsyth/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@lessandro
lessandro / gist:2399422
Created April 16, 2012 15:21 — forked from dforsyth/gist:2392783
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@lessandro
lessandro / gist:2324048
Created April 6, 2012 23:44
Yet another DCPU16 assembler
#include <stdio.h>
#include <string.h>
unsigned short out[100], *curr, *next;
const char *regs[] = {
"a", "b", "c", "x",
"y", "z", "i", "j"
};