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 / fibo.php
Created April 18, 2011 12:56
fib(30) in Ruby & PHP
<?php
function fib($n) {
return ($n > 1) ? fib($n - 2) + fib($n - 1) : $n;
}
echo fib(30);
@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