Skip to content

Instantly share code, notes, and snippets.

@amon-ra
amon-ra / gist:1514950
Created December 23, 2011 18:05 — forked from ohadlevy/gist:674623
script to automate creation of machines, including dns, dhcp, tftp, foreman and puppet
#!/usr/bin/ruby
require "rubygems"
require "rest_client"
require "json"
require "uri"
fqdn = ARGV[0] || raise("Must define a fqdn")
mac = ARGV[1] || raise("Must define a mac")
@amon-ra
amon-ra / attrs.sql
Last active August 20, 2019 17:04 — forked from leek/_Magento1_DeleteTestData.md
Clean magento database, maybe must revision categories and attributes default ids
DELETE eav_attribute_option_value FROM eav_attribute_option,eav_attribute_option_value WHERE eav_attribute_option.attribute_id > 133 and eav_attribute_option.option_id = eav_attribute_option_value.option_id;
DELETE FROM eav_attribute WHERE attribute_id > 133;
DELETE FROM eav_attribute_label WHERE attribute_id > 133;
DELETE FROM eav_attribute_option WHERE attribute_id > 133;
DELETE FROM eav_attribute_group WHERE attribute_set_id > 25;
@amon-ra
amon-ra / stdasyncio.py
Created May 6, 2014 11:39
Python non-blocking read-write
class StdAsyncIOt():
"""Implementes Non blocking readads compatible with windows"""
def _worker_reader_t(self):
#print ("Hilo")
while self.run and not self.err:
try:
data=os.read(self.fd, self.BUFSIZE)
#print (self.BUFSIZE,data)
#if data == '' and self.process.poll() != None: raise "Null Data Readed"
@amon-ra
amon-ra / Vagrant Salt debian wheezy
Created May 7, 2015 08:42
Vagrant salt provision fix with debian wheezy
config.vm.provision "shell" do |s|
s.inline = "echo 'deb http://debian.saltstack.com/debian wheezy-saltstack main' > /etc/apt/sources.list.d/salt.list"
s.inline = "wget -q -O- 'http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key' | apt-key add -"
s.inline = "apt-get update;apt-get install -y salt-minion"
end
@amon-ra
amon-ra / clean.bat
Created May 19, 2015 09:56
Clean windows event log an user temp
for /f %%a in ('WEVTUTIL EL') do WEVTUTIL CL "%%a"
timeout 30
del /s /q %TEMP%\*
@amon-ra
amon-ra / docker-iptables.sh
Created April 8, 2016 10:36
Script to insert custom rules before docker processing.
#!/usr/bin/env bash
# Usage:
# timeout 10 docker_iptables.sh
#
# Use the builtin shell timeout utility to prevent infinite loop (see below)
IPTABLES_FILE="rules"
if [ ! -x /usr/bin/docker ]; then
exit
echo 172.31.0.2 odoo.oondeo.es >> /etc/hosts
Being the local ip of your local proxy
@amon-ra
amon-ra / kube-install.sh
Created July 18, 2016 11:53
Kubernetes with network policy one node install.
#!/bin/bash
#/etc/modules
# af_packet xt_set ip6_tables ipip overlay xt_REDIRECT xt_nat xt_comment nft_reject_ipv4 nft_reject nf_tables xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 xt_addrtype iptable_filter br_netfilter nf_nat bridge stp
#/etc/conf.d/docker
# DOCKER_OPTS="-g /mnt/docker --insecure-registry=10.0.0.0/8 --iptables=false --bridge=none --ip-masq=false --userland-proxy=false --mtu=9000"
#/etc/init.d/docker
# mkdir -p /var/lib/kubelet
# mount -o bind /var/lib/kubelet /var/lib/kubelet
# mount --make-shared /var/lib/kubelet
@amon-ra
amon-ra / mysqlfifo.py
Last active May 13, 2021 00:00
PyMYSQL example fifo queue
#!/usr/bin/python
#pyinstaller mysql-python
#
import signal
import time
import logging
import pymysql
import sys
@amon-ra
amon-ra / example.php
Created June 29, 2017 10:26
PHP simpliest profiling
<?php
prof_flag("Start");
include '../lib/database.php';
include '../lib/helper_func.php';
prof_flag("Connect to DB");
connect_to_db();