Skip to content

Instantly share code, notes, and snippets.

View paridin's full-sized avatar
🎯
Focusing

Roberto Estrada paridin

🎯
Focusing
View GitHub Profile
@paridin
paridin / insert_or_update
Last active August 29, 2015 14:24
Compare objects list and get a list of object to inserted or updated
"""
Problem You have an input json with which you will create a list of objects, you have to validate that the object will be created if it not exists, if exists determine whether to upgrade or discard depending of they have not undergone any changes.
Solution 1) With the input json will be created the list of objects of the class that we insert or updatee
2) Read all fields in the database, using one of the fields as key to creating a dictionary with the objects in the database
3) Compare the objects and determine if it will be updated, inserted or discarded
Django problem: by default only compares the level objects using the primary key (id). Compare field by field is the solution to determine if the object has changed. hints: The _state field is present in every object, and it will produce a random memory location, You can find cache fields so you need to remove these begins with underscore _. The fields excluded can be fk, and these fields produce field_id, so you will needs to exclude it
@paridin
paridin / install_py3.7.sh
Last active September 5, 2018 17:55
a simple script for install python3.7 on *nix systems
#!/bin/bash
# Copyright (c) 2015, Roberto Estrada
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
@paridin
paridin / guide_install_gem_fgci.md
Last active August 28, 2015 23:10
A helper for install fcgi using ruby in a share hosting.

Some times we have a share hosting without privileges, my goal for today, is set up a redmine instance in my hosting actually I have a instance with a2hosting, but i think it will be the same steps for others because I always work with my home directory

Currently I work with custom struct $HOME/.local for every local install and my custom temp dir is $HOME/.local/tmp

$HOME/.local/share
$HOME/.local/bin
$HOME/.local/lib
$HOME/.local/include
$HOME/.local/tmp
@paridin
paridin / nginx
Created August 29, 2015 07:22
nginx daemon aws updated
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
@paridin
paridin / deploy_aws_from_cero.md
Last active February 6, 2016 13:13
Install on AWS Nginx 1.8 + Passenger 5.0 + Postgresql 9.4 + Python 3.4.3 + Django 1.8.4 + Redmine 3.1

AWS Nginx 1.8 + Passenger 5.0 + Postgresql 9.4 + Python 3.4.3 + Django 1.8.4 + Redmine 3.1

In our aws instance we follow the next steps

$ sudo yum update
$ sudo yum -y groupinstall "Development Tools"
$ sudo yum  -y install memcached memcached-devel ImageMagick ImageMagick-devel openssl openssl-devel libcurl-devel nginx
$ sudo yum -y erase nginx # for fix an error of 403 forbbiden it ocurrs after but doing it all works fine
@paridin
paridin / guide_php_subdomain_a2hosting.md
Last active September 12, 2015 06:39
Allow PHP in a subdomain, after install a project django for domain in a2hosting

Guide

The problem, after install django project in my domain foo.net, i need install a limesurvey in a subdomain, using a2hosting

limesurvey.foo.net

  1. Create a subdomain using a cpanel limesurvey.foo.net
  2. Connect to account using ssh ssh -l user foo.net
  3. Download limesurvey and install it. https://www.limesurvey.com/ for more details
  4. Allow Cross Domain using .htaccess vi limesurvey/.htaccess
@paridin
paridin / django_10_pasos.md
Last active September 14, 2015 16:48
Comienza a desarrollar profesionalmente con django en 10 pasos.

MAC OSX

1.- instalar brew, seguir los pasos de http://brew.sh/

2.- instalar python en su versión 3 apoyada por brew brew install python3

3.- instalar en la instancia de python 3 virtualenv y virtualenvwrapper

pip3 install virtualenv
pip3 install virtualenvwrapper
@paridin
paridin / install_custom_vim_osx.md
Last active September 29, 2015 00:56
The easy way to pimp your vim on OSX

Installing a custom vim version

with support to python 3 and, a beautiful style on iterm2

I hope it helps you to pimp your vim, I try to make this guide as simple as possible, and you will need take a little effort to install vundle, this plugin is used to organize your plugins and its a default manager in vim awesome

font used in this custom

  • Terminus for powerline, You need Download and Double Click and install in your Font Book
@paridin
paridin / install_py3.8.sh
Last active May 5, 2020 19:28
Simple script for installing python 3.8 on environments *.nix
#!/bin/bash
# Copyright (c) 2015-2019, Roberto Estrada
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYR
@paridin
paridin / tablas_verdad.py
Created November 12, 2015 05:48
Ejemplo para representar las tablas de verdad.
"""
Tablas de verdad en python
Replicaremos las tablas de la verdad de la siguiente tabla
https://images.duckduckgo.com/iu/?u=http%3A%2F%2Fhtml.rincondelvago.com%2F000264780.jpg&f=1
para la creación de las tablas para su representación gráfica utilizare pandas
tablas de verdad a programar AND, NAND, OR, NOR, EXOR
Desarrollado 11/11/15
Roberto Estrada