Skip to content

Instantly share code, notes, and snippets.

View imidsac's full-sized avatar

SACKO Idriss imidsac

View GitHub Profile
@imidsac
imidsac / nginxproxy.md
Created February 6, 2024 18:47 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

select name, unit_price, sum(quantity), unit_price*sum(quantity)
from order_items
inner join products p on p.id = order_items.product_id
inner join orders o on o.id = order_items.order_id
group by unit_price, name, product_id, order_type having product_id = 1 and order_type = 'Purchase';
select name, unit_price, sum(quantity) qty, sum(total_price) amount, (sum(total_price))-(1800*sum(quantity)) benefice
from order_items
inner join products p on p.id = order_items.product_id
inner join orders o on o.id = order_items.order_id
INSERT INTO public.brands (id, brand_name, brand_name_short, created_at, updated_at) VALUES (2, 'Sanily', null, '2020-10-11 08:16:18.000000', '2020-10-11 08:16:23.000000');
INSERT INTO public.brands (id, brand_name, brand_name_short, created_at, updated_at) VALUES (3, 'Djakarta', null, '2020-10-11 08:16:27.000000', '2020-10-11 08:16:30.000000');
INSERT INTO public.brands (id, brand_name, brand_name_short, created_at, updated_at) VALUES (4, 'CG', null, '2020-10-11 08:16:32.000000', '2020-10-11 08:16:34.000000');
INSERT INTO public.brands (id, brand_name, brand_name_short, created_at, updated_at) VALUES (5, 'Haoujue', null, '2020-10-11 08:16:36.000000', '2020-10-11 08:16:38.000000');
INSERT INTO public.brands (id, brand_name, brand_name_short, created_at, updated_at) VALUES (6, 'X-one', null, '2020-10-11 08:16:39.000000', '2020-10-11 08:16:41.000000');
INSERT INTO public.brands (id, brand_name, brand_name_short, created_at, updated_at) VALUES (7, 'Nokia', null, '2020-10-11 08:16:43.000000', '2020-10-11 08:16:45
# Odoo servers
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
# HTTP -> HTTPS
UPDATE enrollments
SET
(training_id, level_id, filiere_id, cycle_id) = (school_years.training_id, school_years.level_id, school_years.filiere_id, school_years.cycle_id) FROM
school_years
WHERE enrollments.school_year_id = school_years.id;
@imidsac
imidsac / Install Odoo 12 Instructions.md
Created February 4, 2020 11:51 — forked from doopz/Install Odoo 12 Instructions.md
Install Odoo 12 on Ubuntu 18.04 with Nginx and Letscrypt

Install Odoo 12 Instructions

Update OS

sudo apt update && sudo apt upgrade
sudo apt autoremove

Install Postgress

CREATE OR REPLACE FUNCTION f_insert_date_series_of_bookingItems(BIGINT, DATE, DATE, CHARACTER VARYING, DECIMAL)
RETURNS INTEGER
LANGUAGE plpgsql
AS $_$DECLARE
r RECORD;
s NUMERIC;
BEGIN
-- s = $2;
FOR r IN SELECT generate_series($2 :: DATE, $3, $4::INTERVAL) :: DATE AS mdate
OFFSET 1
@imidsac
imidsac / Mali.sql
Created January 4, 2020 10:32
Regions, Cercles, Communes et Quartiers de Mali
This file has been truncated, but you can view the full file.
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.5
-- Dumped by pg_dump version 10.5
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
@imidsac
imidsac / rails-jsonb-queries
Created September 28, 2019 19:47 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@imidsac
imidsac / certificate.rb
Created September 1, 2019 08:44 — forked from fnando/certificate.rb
Create PDF using Prawn
require "prawn"
class Certificate
attr_accessor :path
PDF_OPTIONS = {
:page_size => "A5",
:page_layout => :landscape,
# :background => "public/images/cert_bg.png",
:margin => [40, 75]