Skip to content

Instantly share code, notes, and snippets.

View yassinelachgar's full-sized avatar

Lachgar yassinelachgar

View GitHub Profile
@shingonoide
shingonoide / cleanup_odoo_session.sh
Last active August 30, 2023 14:27
Simple script to clean up Odoo session files
#!/bin/sh
# example
# add this to crontab -e of odoo user
# curl -sL https://gist.github.com/shingonoide/1947a97e3c00168372e950a6788ce9ad/raw/cleanup_odoo_session.sh > /tmp/cleanup_sessions.sh && sh /tmp/cleanup_sessions.sh 4
HOW_OLDER=${1:-6}
VERBOSE=${2:-0}
SESSION_FOLDER="$HOME/.local/share/Odoo/sessions"
TOTALFILES=$(find $SESSION_FOLDER -name '*.sess' | wc -l)
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active December 8, 2024 22:08
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import json
from lxml import etree
from openerp import _, api, fields, models, SUPERUSER_ID
from openerp.osv import expression
class RestrictFieldAccessMixin(models.AbstractModel):
@herval
herval / rds_to_docker.md
Last active April 18, 2025 00:25
Moving a Postgres db from RDS to a Docker container

Make a backup from RDS

pg_dump -h <rds host> -p 5432 -F c -O -U <rds user> <db name> > db.dump

Restore the backup into a Docker container

docker run --rm --interactive --link <postgres container id>:postgres --volume $PWD/:/tmp/ postgres:latest /bin/bash -c 'pg_restore --verbose --clean --no-acl --no-owner -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres -d <db name> /tmp/db.dump'

Retina Macbook Pro

Fresh Mavericks OS X Install

Run Software Update…

- OS X Update 10.9.1, iBooks, iTunes, etc.
- Install / Update Apple Programs (Optional)
	- iWork (Pages, Numbers, Keynote)
	- iLife (iMovie, iPhoto, Garageband)
@mbj
mbj / config
Created January 13, 2012 12:35
systemctl status check
radon# cat /etc/systemd/system/mongodb.service
[Unit]
Description=MongoDB Server
Wants=network.target
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/mongod --config /etc/mongodb.conf
User=mongodb