Skip to content

Instantly share code, notes, and snippets.

View alco's full-sized avatar
🇺🇦

Oleksii Sholik alco

🇺🇦
View GitHub Profile
@alco
alco / zmq_websocket_gateway.py
Created April 24, 2012 08:25 — forked from saghul/zmq_websocket_gateway.py
A ZeroMQ - WebSocket gateway
# coding=utf8
# Copyright (C) 2011 Saúl Ibarra Corretgé <saghul@gmail.com>
#
import hashlib
import os
import re
import socket
import struct
@alco
alco / producer_multicast.py
Created April 24, 2012 08:25 — forked from saghul/producer_multicast.py
ZMQ multicast producer example
# producer
import zmq
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.setsockopt(zmq.LINGER, 0) # discard unsent messages on close
socket.connect('epgm://239.192.1.1:5000')
while True:
@alco
alco / index.html
Created April 24, 2012 08:25 — forked from saghul/index.html
Simple HTML WebSocket client for the ZeroMQ gateway
<html>
<head>
<title>ZWS Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
<script language='javascript'>
$(document).ready(function() {
var ws = new WebSocket("ws://localhost:9999/test");
ws.onmessage = function(evt) {
$('#output').append(evt.data+'<br />');
@alco
alco / ResourceManager.h
Created June 3, 2012 13:04
Resource manager rudiments
#define FILE(file) \
([[NSBundle mainBundle] pathForResource:file \
ofType:nil])
#define FILE_IN_DIR(file, dir) \
([[NSBundle mainBundle] pathForResource:file \
ofType:nil \
inDirectory:dir])
@alco
alco / whirl.frag
Created July 8, 2012 11:23
A whirl effect in GLSL
// simple fragment shader
// 'time' contains seconds since the program was linked.
uniform float time;
uniform sampler2D tex;
float radius = .5;
void main()
@alco
alco / ripple.frag
Created July 8, 2012 11:52
Ripple effect for GLSL
// simple fragment shader
// 'time' contains seconds since the program was linked.
uniform float time;
uniform sampler2D tex;
uniform sampler2D tex2;
float radius = .5;
@alco
alco / gist:3731366
Created September 16, 2012 07:03 — forked from james4k/gist:3730918
package main
import "fmt"
import "math"
func FastInvSqrt(x float32) float32 {
xhalf := float32(0.5) * x
i := math.Float32bits(x)
i = 0x5f3759df - i>>1
x = math.Float32frombits(i)
@alco
alco / Rust.go
Created September 27, 2012 18:12
Rust vs Go
/*
This is a complete working program, equivalent to the Rust program.
*/
package main
import (
"fmt"
"math/rand"
"time"
)
~/home/go/
λ go get
# _/Users/alco/home/go
./dynamic_new.go:17: main redeclared in this block
previous declaration at ./crawl.go:47
./fastinvsqrt.go:15: main redeclared in this block
previous declaration at ./dynamic_new.go:17
./fib.go:17: main redeclared in this block
previous declaration at ./fastinvsqrt.go:15
./find.go:22: main redeclared in this block
@alco
alco / file.ex
Last active December 15, 2015 08:09
@doc """
Get list of files and directories in `dir`.
"""
def listdir(dir) do
F.list_dir(dir)
end
@doc """
Get list of files and directories in `dir`.