Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@noonat
noonat / gevent_thread_wait.py
Created February 23, 2017 19:16
Spawn a thread and make the greenlet wait for it to exit.
from __future__ import print_function
import time
import gevent
from gevent import hub, _threading
def ticker():
while True:
@noonat
noonat / gevent_threads.py
Created February 19, 2017 04:43
gevent + threads
"""This is an example of cooperating between a gevent hub and normal threads."""
import gevent
import socket as _socket
from gevent import hub, socket, _threading
conns = _threading.Queue()
package main
import (
"flag"
"log"
"os"
"os/signal"
"strings"
"github.com/Shopify/sarama"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css">
body {
margin: 0;
padding: 0;
}
canvas {
@noonat
noonat / cube.go
Created September 15, 2015 14:24
package main
import (
"fmt"
"math"
"github.com/go-gl/mathgl/mgl32"
"github.com/gopherjs/gopherjs/js"
"github.com/gopherjs/webgl"
)
@noonat
noonat / webrtc-data-channels.js
Last active April 11, 2022 18:02
WebRTC Data Channels
// This is a bare bones example of creating a data channel between two WebRTC
// peers. Let's imagine two peers trying to connect to each other. We'll call
// one the "offer peer", and the other the "answer peer". The offer peer will
// be the one initiating a connection, and the answer peer will be the one
// responding to it.
//
// The two peers must use a separate connection to negotiate their connection.
// A websocket connection to a shared server is often used for this negotiation.
// They will exchange offers and answers using the websocket. Each peer will
// also attempt to discover more details about themselves (ICE), such as their
@noonat
noonat / coreos-virtualbox.md
Last active February 10, 2023 22:00
Installing CoreOS on VirtualBox
  • Download and install VirtualBox.
  • Download the CoreOS ISO
  • Create a new VM in VirtualBox
    • For the OS, Other Linux, 64-bit should be fine
    • Give the VM 1gb of memory, like your physical hardware has.
    • Create a disk of whatever size you want. I made a VMDK file that could expand dynamically up to 8gb.
  • Mount the ISO in the VM
    • Right click on the VM and click settings
  • Go to the storage tab

Keybase proof

I hereby claim:

  • I am noonat on github.
  • I am noonat (https://keybase.io/noonat) on keybase.
  • I have a public key whose fingerprint is 280C D0D7 B06E ACF3 FD86 058A 0905 62AD 94AC 5A83

To claim this, I am signing this object:

Understanding Accessor Methods in Ruby

Accessing properties of an object in Ruby are a bit different than they are in JavaScript. In JavaScript, if you defined an object constructor like so:

function Foo() {
  this.x = 1;
  this.y = 2;
}