Skip to content

Instantly share code, notes, and snippets.

https://codesandbox.io/s/elastic-water-u7njqk?file=/src/App.js
@mmmcorpsvit
mmmcorpsvit / do.bash
Created December 2, 2021 17:53
Nginx Postgres Proxy
sudo echo '
stream {
upstream postgres {
server localhost:5432;
}
server {
listen 5432 so_keepalive=on;
proxy_pass 999.999.999.999:5432;
}
@mmmcorpsvit
mmmcorpsvit / html
Created July 31, 2021 11:19
Django HTML snippest simple breadcrumb (one level, adapted for Bootstrap 5)
{#Example of use:#}
{#def render_my_page(request, mark_id)#}
{# context = {#}
{# 'breadcrumb': [ # This it!#}
{# ("Все Марки:", reverse('cars')), # with url#}
{# (f"Марка: {data['name']}",) # simple text#}
{# ],#}
{# 'id': mark_id, # custom id#}
{# }#}
{# return render(request, 'pages/my_page.html', context=context)#}
@mmmcorpsvit
mmmcorpsvit / Dockerfile
Created July 20, 2021 21:38
Docker for: Postgres 13.3 + ZomboDB 3000 (build from sources), danger: very long build time!!!
FROM postgres:13.3
COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance
RUN chmod +x /usr/local/bin/maintenance/*
RUN mv /usr/local/bin/maintenance/* /usr/local/bin \
&& rmdir /usr/local/bin/maintenance
ARG DEBIAN_FRONTEND=noninteractive
ARG ES_VERSION=7.13.2
@mmmcorpsvit
mmmcorpsvit / Dockerfile
Created April 19, 2021 11:42
Postgres 13.2 + mongo_fdw 5.2.8 + opendatacam 3.0.1 + mongo + mongo-express + pgadmin4 + adminer
FROM postgres:13.2
ARG MONGO_FDW_VERSION=5_2_8
ARG MONGO_FDW_URL=https://github.com/EnterpriseDB/mongo_fdw/archive/REL-${MONGO_FDW_VERSION}.tar.gz
ARG SOURCE_FILES=tmp/mongo_fdw
RUN apt-get update
RUN apt-get install -y --no-install-recommends wget ca-certificates make gcc cmake pkg-config postgresql-server-dev-13 libssl-dev libzstd-dev libtool
RUN mkdir -p ${SOURCE_FILES} && wget -O - ${MONGO_FDW_URL} | tar -zx --strip-components=1 -C ${SOURCE_FILES}
RUN cd ${SOURCE_FILES} && ./autogen.sh --with-master
{$IFDEF FPC}
{$mode delphi}
{$ENDIF}
unit KOLHTTPDownload;
{
("`-''-/").___..--''"`-._
`6_ 6 ) `-. ( ).`-.__.`)
(_Y_.)' ._ ) `._ `. ``-..-'
_..`--'_..-_/ /--'_.' ,'
@mmmcorpsvit
mmmcorpsvit / gist:3614e2396f94fb7bdc555e3b61ec6202
Created September 4, 2020 03:40
Cookiecutter Django, use Postgres + PostGis
You can easy add PostGis following few simple steps:
1. add to `compose\production\django` samewhere in `RUN apt-get update \`
```bash
&& apt-get install -y gdal-bin \
```
2. edit `compose\production\postgres`
change
`FROM postgres:12.3`
@mmmcorpsvit
mmmcorpsvit / chrome_browder_dowanloads_status.js
Last active July 14, 2019 07:52
Function for get status active downloads (dont forget open chrome://downloads/)
// Tested on Chrome 75
function donwloads_status() {
let tag = document.querySelector('downloads-manager').shadowRoot;
let item_tags = tag.querySelectorAll('downloads-item');
let items_count = item_tags.length;
let progress_lst = [];
for (let i = 0; i < items_count; i++) {
@mmmcorpsvit
mmmcorpsvit / smslike.ru.sql
Last active April 3, 2018 11:41
Postgres With statements build style with transaction
WITH avaliable_phones AS (
SELECT
pn.id as id,
-- rank() over (partition by pn.id order by pn.id) as rank,
count(pn.id) over (partition by pn.id order by pn.id) as phones_count,
-- getprice(c.id, s.id) price,
c.id as country_id,
c.slug as country_slug,
@mmmcorpsvit
mmmcorpsvit / postgres_join_if_condition.sql
Last active March 7, 2018 16:14
Postgres, "JOIN table if execute condition" in single query
set session my.vars.user_id = 0; -- not entered
set session my.vars.user_id = 1;-- entered, user.id=1
select
*
from
services sv
-- favorite, (join only if user.id > 0)
LEFT JOIN