Skip to content

Instantly share code, notes, and snippets.

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
#
# 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
# 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
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"
@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
}
@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 / .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 / .vimrc
Last active February 29, 2016 02:07
.vimrc
autocmd FileType html setlocal indentkeys-=*<Return>
let g:html_indent_inctags = "html,body,head,tbody"
set bs=2
set smartindent autoindent smarttab
set shiftwidth=2
set background=dark
set ru
set tabstop=2
set expandtab
@ippa
ippa / rails.screenrc
Last active August 29, 2015 14:02
start some rails-specific screen tabs
# load base-settings
source .screenrc
# create rails-specific tabs
screen -t guard /bin/bash -i -c "guard && bash"
screen -t logs /bin/bash -i -c "tail -f log/* && bash"
screen -t models /bin/bash -i -c "cd app/models && bash"
screen -t views /bin/bash -i -c "cd app/views && bash"
screen -t controllers /bin/bash -i -c "cd app/controllers && bash"
screen -t css /bin/bash -i -c "cd app/assets/stylesheets && bash"
@ippa
ippa / gist:0b7ea8692f1ae94e5722
Created June 23, 2014 07:41
rvm as normal user (non-root) Dockerfile
FROM ubuntu:trusty
MAINTAINER ippa
ENV DEBIAN_FRONTEND noninteractive
RUN unset HISTFILE
# required by RVM
RUN apt-get -y update
RUN apt-get -y install patch gawk g++ gcc make libc6-dev patch libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev
RUN apt-get -y install curl