Skip to content

Instantly share code, notes, and snippets.

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

Juan Sebastian Ocampo Ospina Capriatto

🏠
Working from home
View GitHub Profile
@n-epifanov
n-epifanov / build-install-libreoffice-py2.sh
Last active May 10, 2019 06:12
A script to build and install LibreOffice 4.4.7.2 with Python 2.7 on Ubuntu Trusty 14.04. To import uno package you'll need to bootstrap it, see https://gist.github.com/nicktime/a35ed52a4b04d6da5b867c6907c825f3
#!/bin/bash -xe
sudo apt-get update
sudo apt-get build-dep libreoffice
sudo apt-get install pkg-config
mkdir libreoffice
cd libreoffice
wget https://downloadarchive.documentfoundation.org/libreoffice/old/4.4.7.2/src/libreoffice-4.4.7.2.tar.xz
wget https://downloadarchive.documentfoundation.org/libreoffice/old/4.4.7.2/src/libreoffice-dictionaries-4.4.7.2.tar.xz
@ilyasProgrammer
ilyasProgrammer / xml_rpc.py
Created November 12, 2017 16:28
Odoo xml rpc example
import xmlrpclib
from datetime import datetime
# url = "http://localhost:8069"
# db = "RAJO"
# username = 'a'
# password = 'a'
url = "https://erp.atlantis-kw.com"
db = "RAJO_TEST"
username = 'api'
@vijoin
vijoin / _name_get.md
Last active June 26, 2019 09:18
Extendiendo _rec_name con el método name_get (Odoo/OpenERP)

#Extendiendo las funcionalidades del atributo _rec_name con el método name_get

Es muy común que tengamos un objeto persona, trabajador, etc, relacionado a un ser humano, el cual tiene (normalmente) dos nombres y dos apellidos. En alguno casos, definimos solo un campo nombres y otro apellidos, nunca se recomienda un solo campo para almacenar todo eso.

En odoo, al recuperar el un registro de un objeto, por ejemplo, al crear un proyecto asignarle un(os) activista(s), el campo Many2one nos traería por defecto el valor del campo 'name', y en caso de no tener ese campo usamos el atributo _rec_name para definir otro campo, por ejemplo: 'nombres'.

Pero esto trae un inconveniente, que al mostrar en la lista desplegable, no nos basta con los nombres solamente; necesitamos los nombres y los apellidos. Para solucionar eso, definimos el método name_get

Ej:

@alexpchin
alexpchin / socket-cheatsheet.js
Created December 15, 2015 16:58
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@thomd
thomd / java-snippets.md
Last active April 29, 2024 18:31
Java code snippets

Java Snippets

Converting Strings to int and int to String

String a = String.valueOf(2); 
int i = Integer.parseInt(a);  

Convert String to Date

@aorborc
aorborc / openerp-Ubuntu-installation
Last active June 26, 2020 02:22
Install OpenERP 7 on Ubuntu
# copied only the scripts from http://www.theopensourcerer.com/2012/12/how-to-install-openerp-7-0-on-ubuntu-12-04-lts/
sudo apt-get install openssh-server denyhosts
sudo apt-get update
sudo apt-get dist-upgrade
sudo adduser --system --home=/opt/openerp --group openerp
sudo apt-get install postgresql
sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt openerp
#Enter password for new role: ********
@mapbutcher
mapbutcher / Postgresql-module-install
Created October 23, 2013 01:48
Notes on how to install a missing module from PostgreSQL
#Notes on how to install a missing module from PostgreSQL
#Download and Postgresql (no need to make install because we already have it..):
#pre-requisites
sudo apt-get install gcc
sudo apt-get install libreadline-dev
sudo apt-get install zlib1g-dev
wget http://ftp.postgresql.org/pub/source/v9.3.0/postgresql-9.3.0.tar.gz
@scaryguy
scaryguy / change_primary_key.md
Last active April 8, 2024 14:23
How to change PRIMARY KEY of an existing PostgreSQL table?
-- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY
ALTER TABLE <table_name> DROP CONSTRAINT <table_name>_pkey;
-- Then change column name of  your PRIMARY KEY and PRIMARY KEY candidates properly.
ALTER TABLE <table_name> RENAME COLUMN <primary_key_candidate> TO id;
@ozh
ozh / new empty git branch.md
Last active May 2, 2024 07:39
Create a new empty branch in Git
$ git checkout --orphan NEWBRANCH
$ git rm -rf .

--orphan creates a new branch, but it starts without any commit. After running the above command you are on a new branch "NEWBRANCH", and the first commit you create from this state will start a new history without any ancestry.

You can then start adding files and commit them and they will live in their own branch. If you take a look at the log, you will see that it is isolated from the original log.

@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});