Skip to content

Instantly share code, notes, and snippets.

@ippa
ippa / .screenrc
Created May 30, 2014 06:58
a .screenrc with colored tabs navigated with ctrl+arrowkeys
startup_message off
scrollback 5000
termcapinfo rxvt-unicode ti@:te@ #enable SHIFT-PGUP / SHIFT-PGDOWN scroll
terminfo rxvt-unicode ti@:te@:
term screen-256color
setenv LC_CTYPE en_US.UTF-8
defutf8 on
setenv DISPLAY ':0'
nonblock on
vbell off
@ippa
ippa / gist:5605152
Last active December 17, 2015 11:49
rethinkdb braindump

Comming from raw SQL and then activerecord (ruby) this was my first impressions/thoughts on RethinkDB. It's just a quick braindump so take it for what it is :).

  • why not have RethinkDB::RQL#inspect call run() so I can play around easier in irb. Constructing queries and see the results directly. How useful is it really to have the query I just constructed printed again?

  • I was running 1.4.5 and "apt-get update" got me 1.5 and suddenly my database wasn't working. The package was released before the blogpost with migration-instructions. Edgecase, but I managed to get bitten by it :P. The log-entry could contain the url with migrations-instructions?

  • Why not just order() instead of order_by(), you don't have filter_by() or replace_with(). Maybe I'm colored by active record in this case.. but less is usually more. Hard to confuse a simpler order() with anything else.

  • r.connect should take a hash/json argument. Then I could do r.connect(db: "heroes"), host would default to localhost and port to 28015 as n

@ippa
ippa / gist:965662
Created May 11, 2011 00:14
svetlo-modified
// Modified: http://www.vcarrer.com/2011/04/svetlo-one-line-javascript-selector.html
function $(selector){
var elements = Array.prototype.slice.call( document.querySelectorAll(selector) )
var items = selector.split(" ")
return (items[items.length-1][0] == "#") ? elements[0] : elements // Return single element if fetching an ID
}
Sprite.prototype.createInDOM = function() {
this.dom_element = this.image
this.dom_element.style.position = "absolute"
document.body.appendChild(this.dom_element)
this.updateDOM()
}
Sprite.prototype.updateDOM = function() {
this.dom_element.style.left = this.x + "px"
this.dom_element.style.top = this.y + "px"
# client
@ip = "127.0.0.1"
@socket = UDPSocket.new
@socket.connect(@ip, SERVER_PORT)
def send_to_server(data = {})
packed = Marshal.dump(data)
@socket.send(packed, 0)
end
#
# Draws an unfilled circle, thanks shawn24!
#
CIRCLE_STEP = 10
def draw_circle(cx,cy,r,color)
0.step(360, CIRCLE_STEP) do |a1|
a2 = a1 + CIRCLE_STEP
$window.draw_line cx + Gosu.offset_x(a1, r), cy + Gosu.offset_y(a1, r), color, cx + Gosu.offset_x(a2, r), cy + Gosu.offset_y(a2, r), color, 9999
end
end
require 'gosu'
require 'teplay'
class Window < Gosu::Window
def initialize
super(500, 500, false, 20)
@image = Gosu::Image.new(self, "map.png")
from_x = 1022