Skip to content

Instantly share code, notes, and snippets.

View juanje's full-sized avatar

Juanje Ojeda juanje

View GitHub Profile
@juanje
juanje / pushover_handler.rb
Created January 3, 2013 20:33
Example of Chef hanfler for sending run fails to Pushover (notifications to iPhone and Android) https://pushover.net/
# cookbook/files/default/pushover_handler.rb
require "net/https"
module MyOrg
class PushOver < Chef::Handler
def initialize(config={})
@config = config
end
@juanje
juanje / Berksfile
Last active April 10, 2017 07:27
Simplified Vagrant config for setting up a logstash server with Chef solo
cookbook 'apt'
cookbook 'monit'
cookbook 'logstash', git: 'git://github.com/lusis/chef-logstash.git'
@juanje
juanje / winrm_setup.bat
Last active March 4, 2023 21:34
Batch script for activating the remote administration on Windows vía WinrRM
@ECHO ON
REM This batch script is almost identical to http://code.can.cd/winrm_setup.bat
REM To use this from powershell on windows in a one liner:
REM (New-Object System.Net.WebClient).DownloadFile('https://gist.github.com/juanje/8496054/raw/winrm_setup.bat','winrm_setup.bat') ; .\winrm_setup.bat
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm quickconfig -transport:http
cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
@juanje
juanje / gist:9603938
Created March 17, 2014 17:20
Install gem before to require it at Test-Kitchen

Install gem before to require it at Test-Kitchen

Context

I was trying some TDD with [Tesk-Kitchen][1] and [ServerSpec][2] when I found myself in the following case scenario:

I have a integration test like this:

# cookbook_webtest/test/integration/default/serverspec/localhost/webtest_spec.rb
@juanje
juanje / Description.md
Last active November 30, 2023 19:29
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
 }
@juanje
juanje / index.html
Last active August 29, 2015 14:04
Testing cartodb.js with Chart.js
<!doctype html>
<html>
<head>
<title>Testing cartodb.js with Chart.js with some random data</title>
<script src="http://www.chartjs.org/assets/Chart.js"></script>
<meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<style>
canvas{
}
@juanje
juanje / index.html
Last active August 29, 2015 14:04
Playas con bandera azul en España, por regiones
<!doctype html>
<html>
<head>
<title>Playas con bandera azul en España, por regiones</title>
<script src="http://www.chartjs.org/assets/Chart.js"></script>
<meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<style>
canvas{
}
@juanje
juanje / index.html
Last active August 29, 2015 14:04
Las playas más cercanas
<html>
<head>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.ie.css" />
<![endif]-->
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<style>
html, body {width:100%; height:100%; padding: 0; margin: 0;}
#map { width: 100%; height:90%; background: black;}
@juanje
juanje / test_web.py
Last active April 22, 2020 19:58
Smoke tests for a web server with TestInfra
import requests
def test_website_1(host):
"""Check if the website is recheable from outside the managed host,
using the standar Python's library Requests.
It also check for the website content.
"""
host_ip = host.interface("eth0").addresses[0]
result = requests.get(f'http://{host_ip}')
@juanje
juanje / shell.sh
Created April 13, 2020 15:26
Check what makes your Docker image fat
# The command to see the space used under each directory is `du -sh /*`
# The `2> /dev/null` at the end is to avoid get lost with a lot of minor errors.
# For the example 'mydockerimage' is the name of the Docker image to be checked.
# Another way is to use Dive (https://github.com/wagoodman/dive), a really nice tool for this.
docker run --rm -u root --entrypoint "" mydockerimage du -sh /* 2> /dev/null