Skip to content

Instantly share code, notes, and snippets.

View mvrilo's full-sized avatar
🌳

Murilo Santana mvrilo

🌳
View GitHub Profile
@mvrilo
mvrilo / ggl.sh
Created March 28, 2010 00:27
Google url shortener bash script
#!/bin/bash
# Author: Murilo Santana
# Google url shortener bash script
# For information about the url shortener app:
# http://ggl-shortener.appspot.com/instructions/
app='http://ggl-shortener.appspot.com/?url='
url="$1"
protocol=`echo "$1" | sed -e "/^http:\/\//g"`
# node.js app under nginx
upstream node {
server 127.0.0.1:8001;
}
server {
listen 80;
server_name node;
// setTimeout Looping
function loop(fn,time){
setTimeout(fn(),time);
loop(fn(),time);
}
#!/usr/bin/env node
console.log("output string 'test' encrypted");
var crypto = require('crypto');
function md5(str) {
var hash = crypto.createHash('md5');
hash = hash.update(str);
hash = hash.digest('hex');
var buffer = require('buffer').Buffer;
function base64(str) {
new buffer(str).toString('base64');
}
# simple example with Sinatra
require 'rubygems'
require 'sinatra'
class Example
get '/' do
haml :index
end
end
mvrilo@ruf-home:~$ ssh -vvv node@mvrilo.no.de
OpenSSH_5.3p1 Debian-3ubuntu4, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to mvrilo.no.de [72.2.126.114] port 22.
debug1: Connection established.
debug1: identity file /home/mvrilo/.ssh/identity type -1
debug3: Not a RSA1 key file /home/mvrilo/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
require 'rubygems'
require 'eventmachine'
class Example < EventMachine::Connection
def receive_data data
send_data "EventMachine minimal server\n\n-----\n#{data}-----\n#{request(data).inspect}"
puts request(data).inspect
close_connection_after_writing
end
@mvrilo
mvrilo / gist:725274
Created December 2, 2010 13:18 — forked from mrdoob/gist:718743
<!DOCTYPE html>
<html>
<head>
<title>html5 javascript canvas</title>
</head>
<body>
<script>
var canvas, context, mouse = { x: 0, y: 0 };
function onDocumentMouseDown(event) {
require 'eio/eventmachine'
TMPFILE = File.expand_path(File.join(File.dirname(__FILE__), "test"))
EM.run do
EIO.eventmachine_handler
EIO.open(TMPFILE, EIO::RDWR) do |fd|
EIO.read(fd) do |buf|
data = "#{buf} ok"
EIO.write(fd, data) do |data|