Skip to content

Instantly share code, notes, and snippets.

View macagua's full-sized avatar
🏠
Working from home

Leonardo J. Caballero G. macagua

🏠
Working from home
View GitHub Profile
@vanpelt
vanpelt / upsert.py
Created March 20, 2018 06:33
Flask SqlAlchemy MySQL ON DUPLICATE KEY UPDATE returning auto increment id UPSERT HOTNESS
from app import db
from sqlalchemy import func
from sqlalchemy.dialects.mysql import insert
def upsert(model, insert_dict):
"""model can be a db.Model or a table(), insert_dict should contain a primary or unique key."""
inserted = insert(model).values(**insert_dict)
upserted = inserted.on_duplicate_key_update(
id=func.LAST_INSERT_ID(model.id), **{k: inserted.inserted[k]
for k, v in insert_dict.items()})
@joseconti
joseconti / Embed-Gist-Github-en-WordPress.php
Last active June 29, 2019 06:36
Embed Gist Github WordPress
<?php
wp_embed_register_handler( 'gist', '/https?:\/\/gist\.github\.com\/([a-z0-9]+)\/([a-z0-9]+)?/i', 'joseconti_embed_gist' );
function joseconti_embed_gist( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<script src="https://gist.github.com/%1$s/%2$s.js"></script>',
esc_attr( $matches[1] ),
esc_attr( $matches[2] )
);
@zopyx
zopyx / gist:dd94316653b9adb89a34adea7c02df30
Created March 9, 2018 12:53
Plone 4 -> Plone 5.1 migration via plone.restapi
import os
import sys
import yaml
import pprint
import base64
import requests
import plone.api
from requests.auth import HTTPBasicAuth
from Testing.makerequest import makerequest
[options]
#
# WARNING:
# If you use the Odoo Database utility to change the master password be aware
# that the formatting of this file WILL be LOST! A copy of this file named
# /etc/odoo/openerp-server.conf.template has been made in case this happens
# Note that the copy does not have any first boot changes
#-----------------------------------------------------------------------------
# Odoo Server Config File - TurnKey Linux
@styblope
styblope / docker-api-port.md
Last active May 8, 2025 16:00
Enable TCP port 2375 for external connection to Docker

Enable TCP port 2375 for external connection to Docker

See this issue.
Docker best practise to Control and configure Docker with systemd.

  1. Create daemon.json file in /etc/docker:

     {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
    
@mamigot
mamigot / edx_version.sh
Created November 15, 2017 16:52
See which version of the Open edX platform you're running
root@openedx:/edx/app/edxapp/edx-platform$ git tag | grep "open-release" | tail -1
open-release/ginkgo.1rc1
@defclass
defclass / pipe_to_docker_examples
Created October 19, 2017 03:14 — forked from ElijahLynn/pipe_to_docker_examples
How to pipe to `docker exec` examples
# These examples assume you have a container currently running.
# 1 Pipe from a file
sudo docker exec --interactive CONTAINER_NAME /bin/bash < the_beginning.sh | tee the_beginning_output.txt`
#2a Pipe by piping
echo "echo This is how we pipe to docker exec" | sudo docker exec --interactive CONTAINER_NAME /bin/bash -
/*
* Ejemplo de tipo abstracto para gestionar lista de alumnos
* Cada alumno tiene un nombre y una edad
*/
// Internamente se representan como una sola lista
let alumnos = [];
// Se inicializan un par de valores
alumnos.push({ "nombre": "pepe", "edad": 23 });
@abdulhalim-cu
abdulhalim-cu / odoo_install_script.sh
Created October 7, 2017 12:57
Odoo Community & Enterprise Installation Script
#!/bin/bash
################################################################################
# Script for installing Odoo V10 on Ubuntu 16.04, 15.04, 14.04 (could be used for other version too)
# Author: Yenthe Van Ginneken
#-------------------------------------------------------------------------------
# This script will install Odoo on your Ubuntu 14.04 server. It can install multiple Odoo instances
# in one Ubuntu because of the different xmlrpc_ports
#-------------------------------------------------------------------------------
# Make a new file:
# sudo nano odoo-install.sh
@radamhu
radamhu / odoo_calculate_workers.sh
Last active June 3, 2021 20:12
Analyzes the characteristics of the server and helps calculate the number of workers and memory for each
#!/bin/bash
# CONST 1GB
CONST_1GB="1024*1024*1024"
# VARIABLE WORKERS
CMD_W=0