Skip to content

Instantly share code, notes, and snippets.

@amon-ra
amon-ra / odoo.sh
Created January 22, 2019 18:17
Odoo development startup scripts
#!/bin/sh
# USAGE: odoo.sh 11
# from directory where addons are
# Create a database named odoo_11_db_xxxx
$VOLUME_PATH="/virt/docker"
VERSION=$1
shift
DEV="all"
if [ "$VERSION" == "9" ] || [ "$VERSION" == "8.0" ]; then
@amon-ra
amon-ra / ispconfig-hook
Created May 11, 2018 11:11
ISPCONFIG gitea hook
#!/bin/bash
#
#gitea-ispconfig: https://gist.github.com/amon-ra/3b242d7d1dc829152ca00c92714e42cc
echo "---------------------" >> /tmp/gitea_ispconfig.log
if [ $(git rev-parse --is-bare-repository) = true ]
then
REPOSITORY_BASENAME=$(basename "$PWD")
REPOSITORY_DIR=$PWD
else
@amon-ra
amon-ra / gitea-ispconfig.sh
Last active May 11, 2018 11:11
Sync local gitea repo with ispconfig web host
#!/bin/bash
#https://gist.github.com/amon-ra/3b242d7d1dc829152ca00c92714e42cc
#https://gist.github.com/amon-ra/46409526aa3a4cadb308b67fba68d215
OWNER="$(stat -c "%U:%G" $1)"
git --work-tree=$1 --git-dir=$2 checkout -f
chown -R $OWNER $1/*
<?php
/**
* ISPConfig Icingia2 HTTP Service Plugin for ISPConfig Version 3.1.2 and above.
*
* This class extends ISPConfig's vhost management with the functionality to manage icingia2 HTTP services.
*
* This Plugin requires Icinga2 (https://www.icinga.com/products/icinga-2/)
* The config files add a variable named "vars.http_vhosts" to an existing icinga2 host.
* With the matching icinga2 service configuration a icinga2 service will be added for each entry contained in "vars.http_vhosts".
@amon-ra
amon-ra / gist:6bc0cef0fe9b9db3620bf1104ef4f545
Created April 17, 2018 14:09
Wordpress multisite cron
<?php
global $multisite_hosts;
$multisite_hosts = Array('somosnoticias.dev.entomelloso.oondeo.es','entomelloso.dev.entomelloso.oondeo.es', 'somoscastillalamancha.dev.entomelloso.oondeo.es');
function run_cron(){
global $multisite_hosts;
$host=array_pop($multisite_hosts);
if (!$host)
return;
@amon-ra
amon-ra / multisite_shared_media.py
Created March 24, 2018 15:00
Wordpress convert media ids from multisite shared media, betwen sites
import csv,re
#SELECT post_id,REPLACE(REPLACE(meta_value,';}',''),'a:1:{i:1;i:','') as new_post_id FROM `wp_3_postmeta` WHERE `meta_key` = 'msm_original_file'
d2 = {}
tables = ['wp_2_posts']
with open('media.csv', mode='r') as infile:
with open('media_result.sql',mode='w') as f:
reader = csv.reader(infile)
#rows0: new , rows1: old
for row in reader:
git reset --soft HEAD~i
git commit -a -m "fixed #123, error en los permisos de la carpeta /web"
where i is number of commits
@amon-ra
amon-ra / apt-src-only.sh
Created August 8, 2017 06:46
apt-build hack to install only from source
#!/bin/bash
#USAGE: apt-build -aptget /usr/local/bin/apt-src-only.sh install $package
PARAMS=$*
if [[ $* == *"build-dep"* ]]; then
PACKAGES_TO_BUILD=$(apt-get -s $PARAMS 2> /dev/null | grep -e '^Inst ' | awk -F '[ \(]' '{print $2"="$4}')
apt-build --aptget $0 install $PACKAGES_TO_BUILD
else
apt-get $*
@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();
@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