Skip to content

Instantly share code, notes, and snippets.

@sawanoboly
sawanoboly / fluentd-source-haproxy.conf
Created July 13, 2012 01:10
syslog-ng setting for haproxy. Divide logs between accesslog and systeminfo.
<source>
type tail
format /(?<c_ip>[\w\.]+):(?<c_port>\d+) \[(?<a_date>.+)\] (?<f_end>[\w-]+) (?<b_end>[\w-]+)\/(?<b_server>[\w-]+) (?<tw>\d+)\/(?<tc>\d
+)\/(?<tt>\d+) (?<bytes>\d+) (?<t_state>[\w-]+) (?<actconn>\d+)\/(?<feconn>\d+)\/(?<beconn>\d+)\/(?<srv_conn>\d+)\/(?<retries>\d+) (?<
srv_queue>\d+)\/(?<backend_queue>\d+)/
time_format %d/%B/%Y:%H:%M:%S
path /var/log/haproxy/haproxy_access.log
pos_file /opt/fluentd/var/pos/haproxy_access.pos
tag haproxy.access
</source>
@commandodev
commandodev / req_req.py
Created June 26, 2012 10:04
Handling REQ/REP syncronization in eventlet
from eventlet.pools import Pool
from eventlet.timeout import Timeout
class SocketPool(Pool):
"""A pool of sockets connected to a component
If a socket times out in use, simply close if before handing it back to the
pool and it will be discarded and a replacement inserted into the pool."""
def __init__(self, address, **kwargs):
define (require) ->
ChartableObject = require "./ChartableObject"
class School extends ChartableObject
constructor: (@enrollment) ->
super
@lancejpollard
lancejpollard / index.md
Created May 23, 2012 22:30
Sublime vs. Textmate Notes

In TextMate, I could press CTRL-OPTION-SHIFT-<some letter> and a popup would appear showing the languages starting with that letter. So if I pressed CTRL-OPTION-SHIFT-J, javascript, java, and json would be choices, and I could press 1 to get javascript, etc. This made it so, even if the file was a .md markdown file, I could quickly switch to javascript to get some syntax highlighting as I wrote some sample code.

In Sublime Text 2 I can do vertical block selection, but I can't do it the way vim does, and this feature has been requested before:

http://sublimetext.userecho.com/topic/61014-vintage-mode-requests/

In vim you can do CTRL-V then navigate up/down to select a block, then insert some text, for example:

Vertical Text Selection in Vim

@cllunsford
cllunsford / meteor-oauth-client.js
Created May 4, 2012 15:05
Oauth using Meteor and Backbone
var AUTH_URL = "https://api.glitch.com/oauth2/authorize?response_type=code&client_id=000yourclientid000&redirect_uri=http://yoursitehere/oauth/&scope=identity";
var Auth_Router = Backbone.Router.extend({
routes: {
"": "root",
"oauth/?code=:code": "auth"
},
root: function () {},
auth: function (code) {
Meteor.call('authenticate', code, function (error, result) {
@jacobian
jacobian / pip-cache-install.py
Created May 1, 2012 05:22
Install a package from your local pip download cache without touching the 'net.
#!/usr/bin/env python
"""
Install a package from your local pip download cache without having to touch
the 'net at all.
You'll need to be using a pip download cache; that is, you'll need the
following in your ~/.pip/pip.cfg:
[install]
@rodionmoiseev
rodionmoiseev / gist:2484934
Created April 25, 2012 00:41
Setting up Play 2.0 in build.gradle
apply plugin: 'java'
apply plugin: 'scala'
// For those using Eclipse or IntelliJ IDEA
apply plugin: 'eclipse'
apply plugin: 'idea'
def findPlay20(){
def pathEnvName = ['PATH', 'Path'].find{ System.getenv()[it] != null }
for(path in System.getenv()[pathEnvName].split(File.pathSeparator)){
for(playExec in ['play.bat', 'play.sh', 'play']){
@Akkuma
Akkuma / application.coffee
Created April 20, 2012 14:19
Tower.js Passport Example
passport = require 'passport'
googOID = require('passport-google').Strategy
steamOID = require('passport-steam').Strategy
passport.use new steamOID
returnURL: 'http://localhost:3000/auth/steam/return'
, realm: 'http://localhost:3000'
, () -> console.log arguments
passport.use new googOID
@varavut
varavut / a.sh
Created April 15, 2012 14:01
testmongo
sudo apt-get update
sudo apt-get install openjdk-6-jre-headless -f
sudo apt-get install curl
sudo apt-get install unzip
sudo apt-get install openssh-server
sudo curl -OL http://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.8.zip
sudo unzip elasticsearch-* && rm elasticsearch-*.zip
cd elasticsearch-0.19.8
sudo mkdir /usr/local/elasticsearch
@tsuna
tsuna / mysqlpool.scala
Created March 30, 2012 00:15
MySQL JDBC connection pool for Scala + Finagle
// Copyright (C) 2012 Benoit Sigoure
// Copyright (C) 2012 StumbleUpon, Inc.
// This library is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or (at your
// option) any later version. This program is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
// General Public License for more details. You should have received a copy
// of the GNU Lesser General Public License along with this program. If not,