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 / 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

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@ippa
ippa / hackforswedenhelp
Created March 14, 2015 17:38
access platsbanken api from nodejs/iojs
/*
* on cmdline 'npm install superagent'
*/
var superagent = require("superagent");
var url = "http://api.arbetsformedlingen.se/platsannons/soklista/kommuner?lanid=10"
superagent.get(url)
.set("Accept", "application/json")
.set("Accept-Language", "sv-SE,sv")
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
}