Skip to content

Instantly share code, notes, and snippets.

@leandrosilva
leandrosilva / xsp4-stop.sh
Created November 5, 2012 18:45
Kill xsp4 if it's running
kill `ps aux | grep xsp4.exe | grep -v grep | awk '{print $2}'`
@leandrosilva
leandrosilva / .gitignore
Created September 14, 2012 01:59
Lots of C# "free codes"
.DS_Store
*.dll
*.exe
@leandrosilva
leandrosilva / ErrorLogger.cs
Created September 14, 2012 01:51
Task parallelization with C# and Mono
using System;
using System.Collections.Generic;
namespace TaskParallelization
{
class ErrorLogger
{
private readonly IList<string> _messages;
public ErrorLogger()
@leandrosilva
leandrosilva / .gitignore
Created September 14, 2012 01:25
Mono + C# + NUnit
.DS_Store
*.dll
*.xml
@leandrosilva
leandrosilva / .gitignore
Created September 14, 2012 01:19
Embedded IronRuby - Hello World!!!
.DS_Store
*.exe
@leandrosilva
leandrosilva / klogd.py
Created September 6, 2012 20:12
My dumb Python script to stream Syslog messages to a Kafka server
# ==========================
# Getting Started with klogd
# ==========================
#
# Klogd is a dumb script to stream Syslog messages to a Kafka server.
#
# 1) Make sure you have all dependencies installed properly
#
# - Twisted
# - PyParsing
@leandrosilva
leandrosilva / README
Last active March 17, 2023 19:05
Parsing Syslog files with Python and PyParsing
$ python xlog.py sample.log
{'appname': 'test.app', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '68898', 'priority': '132', 'message': 'bla bla bla warn'}
{'appname': 'test.app', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '68902', 'priority': '131', 'message': 'bla bla bla error'}
{'appname': 'Dock', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '154', 'priority': '11', 'message': 'CGSReleaseWindowList: called with 5 invalid window(s)'}
{'appname': 'WindowServer', 'timestamp': '2012-09-06 15:19:32', 'hostname': 'codezone.local', 'pid': '79', 'priority': '11', 'message': 'CGXSetWindowListAlpha: Invalid window 0'}
$ python xlog.py sample.log | grep test.app
{'priority': '132', 'timestamp': '2020-03-04 12:42:40', 'hostname': 'codezone.local', 'appname': 'test.app', 'pid': '68898', 'message': 'bla bla bla warn'}
@leandrosilva
leandrosilva / Create user and databases
Created August 26, 2012 12:27
Reminders on Postgres
$ psql -h 127.0.0.1 -d postgres
postgres=# CREATE USER fulano SUPERUSER;
postgres=# CREATE DATABASE fulano_development OWNER fulano;
postgres=# CREATE DATABASE fulano_test OWNER fulano;
postgres=# \q
@leandrosilva
leandrosilva / ClientApp.java
Created June 7, 2012 07:01
My MessagePack-RPC sample: Clojure Server & Java Client
package msgpack.rpc.sample.client;
import org.msgpack.rpc.Client;
import org.msgpack.rpc.loop.EventLoop;
public class ClientApp {
private static class SpawnRequest {
private SpawnRequest(final int clientCount, final int requestCount, final RPCInterface iface) {
new Thread(new Runnable() {
public void run() {
@leandrosilva
leandrosilva / README.md
Created June 4, 2012 20:03
Wapijure Command - This is the script to generate a Compojure project to build a Web API

wapijure command

Wapijure Command is the script to generate a Compojure project to build a Web API.

Usage

$ wget https://raw.github.com/gist/2870539/wapijure
$ chmod +x wapijure
$ ./wapijure new awesomeapi

$ cd awesomeapi