Skip to content

Instantly share code, notes, and snippets.

View inkel's full-sized avatar
:shipit:
The floating head with a beard

Leandro López inkel

:shipit:
The floating head with a beard
View GitHub Profile
@inkel
inkel / openvz_lowmem.sh
Created October 21, 2010 15:10
OpenVZ lower memory utilization
# OpenVZ lower memory utilization, according to
# http://wiki.openvz.org/UBC_systemwide_configuration#.E2.80.9CLow_memory.E2.80.9D_.28x86_32_specific.29
#
# AWK script to calculate lower memory utilization
lowmem() {
awk '$1 ~ /kmemsize|tcprcvbuf|tcpsndbuf|dgramrcvbuf|othersockbuf/ { M+=$2 } END { print M / (0.4 * 832 * 1024 * 1024 ) }' $*
}
# Reading user bean counters, low mem usage is: 0.137789
@inkel
inkel / chat.rb
Created December 14, 2011 12:57 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
_gs_ps1() {
[[ -z $GS_NAME ]] || echo "[$GS_NAME] "
}
export PS1="\n\[\033[01;32m\]\w \[\033[1;33m\]\$(_gs_ps1)\[\033[01;31m\]\$(__git_ps1 \"(%s) \")\[\033[01;36m\]>>\[\033[00m\] "
export PS1="\[\033[G\]$PS1"
@inkel
inkel / timed.rb
Created May 21, 2012 21:14
Protest Timed reporter
module Protest
class Reports::TimedTest < Report
include Utils::Summaries
include Utils::ColorfulOutput
attr_reader :stream
attr_reader :slowest
attr_reader :max_time
def initialize(stream=STDOUT)
@inkel
inkel / application.sass
Last active October 5, 2015 07:18
GitStaticAssets
.arrow
background: asset_path('/images/arrow_small_white.png') no-repeat 14px center
@inkel
inkel / cachipulis.rb
Created July 27, 2012 14:06
Números cachipulis
#!/usr/bin/env ruby
param = ARGV.first
class Fixnum
def is_cachipulis?
length = self.to_s.length
digits = self.to_s.split('').map(&:to_i)
return false if digits.inject(&:+) != length
@inkel
inkel / README.md
Created August 13, 2012 20:00
Dæmons

Hay un montón de cambios para hacer, cosas por mejorar, etc, pero básicamente anda :)

@inkel
inkel / gist:3690584
Created September 10, 2012 12:11
Monit Redis
check process redis-server
with pidfile "/var/run/redis.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if 2 restarts within 3 cycles then timeout
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
{"completed_in":0.033,"max_id":252706291179466752,"max_id_str":"252706291179466752","next_page":"?page=2&max_id=252706291179466752&q=RubyConfAR","page":1,"query":"RubyConfAR","refresh_url":"?since_id=252706291179466752&q=RubyConfAR","results":[{"created_at":"Mon, 01 Oct 2012 09:47:29 +0000","from_user":"apotonick","from_user_id":286312129,"from_user_id_str":"286312129","from_user_name":"Nick Sutterer","geo":null,"id":252706291179466752,"id_str":"252706291179466752","iso_language_code":"en","metadata":{"result_type":"recent"},"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1321475137\/poser_normal.jpg","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1321475137\/poser_normal.jpg","source":"&lt;a href=&quot;http:\/\/twitter.com\/&quot;&gt;web&lt;\/a&gt;","text":"Any surfer at @RubyConfAR who could guide me to spots after the conf?","to_user":null,"to_user_id":0,"to_user_id_str":"0","to_user_name":null},{"created_at":"Fri, 28 Sep 2012 23:05:41 +0000","from_user":"alfrenovsky","from