Skip to content

Instantly share code, notes, and snippets.

View geekq's full-sized avatar
🎯
Hacking

Vladimir Dobriakov geekq

🎯
Hacking
View GitHub Profile
@geekq
geekq / app_zabbix.py
Created September 5, 2018 17:34
ansible lookup_plugin to generate a multihost zabbix expression
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
# Run with `python app_zabbix.py` to execute doctests
import sys
from ansible.plugins.lookup import LookupBase
try:
from __main__ import display
except ImportError:
@geekq
geekq / watchf
Created July 5, 2017 11:53
Watch for source code files to change and rerun the command, supports colors
#!/usr/bin/ruby
require 'rubygems'
require 'rake'
KNOWN_FILE_TYPES = %w(rb txt py yaml erb pp feature j2)
# Based on work by Mike Clark.
#
# From http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/StakingOutFileChanges.rdoc
# Modified (with permission) by Geoffrey Grosenbach to call growlnotify for
@geekq
geekq / watchf
Created January 6, 2016 08:45
Runs a user-defined command when files are modified
#!/usr/bin/ruby
require 'rubygems'
require 'rake'
KNOWN_FILE_TYPES = %w(rb txt py yaml erb pp)
# Based on work by Mike Clark.
#
# From http://www.pragmaticautomation.com/cgi-bin/pragauto.cgi/Monitor/StakingOutFileChanges.rdoc
# Modified (with permission) by Geoffrey Grosenbach to call growlnotify for
@geekq
geekq / gist:3215678
Created July 31, 2012 09:57
Start simple web server in the current folder
ruby -r webrick -e "s = WEBrick::HTTPServer.new(:Port => 3001, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start"
@geekq
geekq / check_puppet_syntax.sh
Created July 30, 2012 13:29
script to syntax-check puppet .pp and .erb files
#!/bin/bash
#Script to test puppet files have valid syntax.
#Intended for use with hudson/jenkins.
set -e
set -u
fail=0
#TODO: Run these in parallel - we have 4 cores.
#TODO: Control the environment (through the config dir?).
@geekq
geekq / Rakefile
Created February 10, 2010 19:39
Modify a pragprog's epub archive to use more suitable fonts on Sony eBook Reader
# Modifies a pragprog's epub archive to use more suitable fonts on Sony
# PRS-505 eBook Reader.
task :default => :help
def in_filename
ENV['input']
end
def out_filename
# Demonstrates a secure usage of sessions in Sinatra
# for authentication and notices.
require 'rubygems'
require 'sinatra'
configure :production, :test do
use Rack::Session::Cookie,
:key => 'rack.session',
:domain => '.example.com', # use a wildcard with leading
# dot and at least two dots in total
# Check the impact of Nokogiri builder / HAML engine caching
require 'benchmark'
require 'sinatra-nokogiri-menu.rb'
require 'haml'
def render_with_haml(current = nil)
@engine ||= Haml::Engine.new <<here
%ul
- MENU_ITEMS.each do |item|
- opts = {}
# Helps to organize and structure your tests with
# * human readable test names
# * flagging tests as pending
# * structuring the test implementation with blocks
# Please see the documentation of single methods below.
# Written by Vladimir Dobriakov
# See http://blog.geekq.net/2009/11/25/minimalist-testing-ruby/ for explanation
require 'minitest/unit'
class String