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
@macagua
macagua / complexity.py
Created July 31, 2015 01:22
Cyclomatic complexity for Python code
#!/usr/bin/python
"""
Find the most complex functions/methods in your python code.
This program is offered freely into the public domain by
Gary Wilson (gary.wilson@gmail.com).
This code requires the complexity shell scripts found at
http://journyx.com/curt/complexity.html
@macagua
macagua / convert.sh
Created February 26, 2016 19:41 — forked from wilmoore/convert.sh
convert markdown to reStructured Text (Thanks Doctrine2) - https://github.com/doctrine/dbal-documentation/blob/master/convert.sh
#!/bin/bash
FILES=`find -iname *.txt -print`
for FILE in $FILES
do
# replace the + to # chars
sed -i -r 's/^([+]{4})\s/#### /' $FILE
sed -i -r 's/^([+]{3})\s/### /' $FILE
sed -i -r 's/^([+]{2})\s/## /' $FILE
sed -i -r 's/^([+]{1})\s/# /' $FILE
sed -i -r 's/(\[php\])/<?php/' $FILE
@macagua
macagua / README.md
Last active October 29, 2020 13:15
Install a Bower package with Composer configuration for Yii2 project

Install Bower packages with Composer configuration for Yii2 project

Install two (02) Bower packages like jquery 2.2.4 and pickadate 3.5.6 with Composer configuration for Yii2 project

Installing Composer

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
@macagua
macagua / postgresql.mk
Created August 12, 2016 03:45 — forked from Ignas/postgresql.mk
Set up for a local postgresql database using a Makefile
export PGPORT ?= 4488
PG_PATH ?= $(shell if test -d /usr/lib/postgresql/9.1; then echo /usr/lib/postgresql/9.1; else echo /usr/lib/postgresql/8.4; fi)
PG_DIR = ${PWD}/instance/var
PG_DATA = ${PG_DIR}/data
PG_RUN = ${PG_DIR}/run
PG_LOG = ${PG_DIR}/log
PG_SOCKET = ${PG_RUN}/.s.PGSQL.${PGPORT}
PGPARAMS = -D ${PG_DATA} -o "-F -c unix_socket_directory=${PG_RUN} -c custom_variable_classes='busy' -c busy.active_user=0" -l ${PG_LOG}/pg.log
@macagua
macagua / ndis-fix.sh
Created September 12, 2016 05:20 — forked from Avinash-Raj/ndis-fix.sh
Shell script to fix "Install NDIS driver failed" error while trying to install Huawei modem drivers on linux
#!/bin/bash
# Run the below script only after "Install NDIS driver failed" error while trying to install Huawei modem drivers on linux.
# I checked this script on Ubuntu.
# Detailed explanation of this script was given here(http://askubuntu.com/a/414401/202806).
path="/usr/local/Mobile_Partner/driver"
if [ "$(ls -A $path)" ]; then
tput setaf 6; echo "Huawei modem drivers for linux are already installed on your pc.Please wait for NDIS driver installation."; tput sgr0
perl -i -pe 's#^(\s*dbg \("can.t kmalloc dev"\);)#//$1#' /usr/local/Mobile_Partner/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c
cd $path
@macagua
macagua / PIP_Timeout_Python_Packages.rst
Last active March 30, 2022 22:24
Tip for set the timeout when install Python Packages with PIP

TIP: When there is Internet latency and requires installing python packages, run this command with the parameter enabled timeout:

pip install -r requirements.txt --timeout 120
@macagua
macagua / Python_Cache_Packages_PIP.rst
Last active March 30, 2022 22:25
Tip for set the Cache Directory for Python Packages with PIP

TIP: When there is Internet latency and requires installing python packages by a requeriments file of pip but the installation failed, then you can prevent PIP from re-downloading previously downloaded packages, running this command:

mkdir -p ~/.cache/pip && mkdir ~/.pip && printf '[global]\ndownload_cache = ~/.cache/pip\n' >> ~/.pip/pip.conf
@macagua
macagua / upgrades.py
Created June 30, 2017 12:09 — forked from thet/upgrades.py
Plone / Zope Component Architecture: Unregister all broken persistent utilities
# -*- coding: utf-8 -*-
from zope.component.hooks import getSite
import logging
log = logging.getLogger(__name__)
def unregister_broken_persistent_components(context):
portal = getSite()
sm = portal.getSiteManager()
@macagua
macagua / intro.md
Created December 21, 2017 12:36 — forked from derhuerst/intro.md
Installing Git on Linux, Mac OS X and Windows
@macagua
macagua / gist:235f875138221f2a9032c0adc4144fde
Created February 9, 2018 16:40
[TIP] When there is Internet latency and requires installing python packages by a buildout proyect, for later shared these packages with others buildout proyect, then you can prevent buildout from re-downloading previously downloaded packages, running this command:
mkdir -p $HOME/.buildout/{downloads,eggs,extends,zope} && echo $HOME $HOME $HOME $HOME | awk '{ printf( "[buildout]\neggs-directory = %s/.buildout/eggs\ndownload-cache = %s/.buildout/downloads\nextends-cache = %s/.buildout/extends\nzope-directory = %s/.buildout/zope\nabi-tag-eggs = true\n", $1, $2, $3, $4 ) }' >> ~/.buildout/default.cfg