Skip to content

Instantly share code, notes, and snippets.

Przemek Matylla matylla

Block or report user

Report or block matylla

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View GLSL-color.md

RGB - YUB

mat3 yuv2rgb = mat3(1.0, 0.0, 1.28033, 1.0, -0.21482, -0.38059, 1.0, 2.12798, 0.0);
mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722, -0.09991, -0.33609, 0.43600, 0.615, -0.5586, -0.05639);

RGB - HSV

@matylla
matylla / config-haproxy.sh
Created Jul 23, 2012 — forked from jsermeno/config-haproxy.sh
Node.js server and Web Sockets on Amazon EC2 with Express.js and Socket.IO - http://catchvar.com/nodejs-server-and-web-sockets-on-amazon-ec2-w
View config-haproxy.sh
# HAProxy config
mkdir /etc/haproxy
cat > /etc/haproxy/haproxy.cfg << EOF
global
maxconn 4096
defaults
mode http
@matylla
matylla / iot.md
Created Jul 19, 2012 — forked from asciidisco/iot.md
Image optimization tools (losless)
View iot.md

I want your lossless image optimization tool knowlegde:

Note: I´am looking for cmd tools (preferred running on mac/linux/win - but it´s not a must) Online services are welcome as well. If you have a good article, stackoverflow post or smth. else on image optimization (with statistics & stuff), i would appriciate if you could share that, too.

Already suggested:

@matylla
matylla / interval.js
Created Feb 22, 2012 — forked from gengkev/interval.js
Accurate Javascript setInterval replacement
View interval.js
function Interval(func,duration){
if(typeof func !== "function") throw new TypeError("Expected function");
else if(typeof duration !== "number") throw new TypeError("Expected number");
this.func = func;
this.duration = duration;
this.baseline = +new Date();
(function(_this){
_this.timer = setTimeout(function(){
@matylla
matylla / snippet.js
Created Jan 16, 2012 — forked from christopherdebeer/snippet.js
Node.js Express - Mobile detection
View snippet.js
app.get('/', function(req, res){
var ua = req.header('user-agent');
if(/mobile/i.test(ua)) {
res.render('mobile.html');
} else {
res.render('desktop.html');
}
});
@matylla
matylla / nginx + node setup.md
Created Jan 6, 2012 — forked from joemccann/nginx + node setup.md
Set up nginx as a reverse proxy to node.js.
View nginx + node setup.md

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@matylla
matylla / pubsub.md
Created Oct 29, 2011 — forked from addyosmani/pubsub.md
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)
View pubsub.md

#Four Ways To Do Pub/Sub With jQuery 1.7 and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

View post-receive.rb
#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
@matylla
matylla / cron-test.js
Created Jun 7, 2011 — forked from onewland/cron-test.js
simple cron API for node.js
View cron-test.js
var cron = require('./cron'), sys = require('sys');
cron.Every((2).seconds(), function() { sys.puts('Working!'); });
@matylla
matylla / gist:987455
Created May 23, 2011
node js get client ip
View gist:987455
function getClientAddress(req) {
return req.headers['x-forwarded-for'] || req.connection.remoteAddress;
}
You can’t perform that action at this time.