Skip to content

Instantly share code, notes, and snippets.

View jnoortheen's full-sized avatar

Noorhteen Raja NJ jnoortheen

  • Software developer
  • Chennai, India
View GitHub Profile
@jnoortheen
jnoortheen / explain II - addition of hashjoin off.txt
Last active April 26, 2023 09:05
I - distributed query with -
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0) (actual time=176101.644..176102.085 rows=25 loops=1)
Task Count: 1
Tuple data received from nodes: 34 kB
Tasks Shown: All
-> Task
Tuple data received from node: 34 kB
Node: host=localhost port=5432 dbname=parkpow_distributed
-> Limit (cost=1.31..110.89 rows=25 width=1864) (actual time=176034.509..176054.118 rows=25 loops=1)
import asyncio
import sys
import time
def EXITED():
# Did app terminate
pass
class PatchableStderrStream(object):
def __init__(self):
@jnoortheen
jnoortheen / experiments.md
Created December 18, 2020 05:38
dbus and activities

print all available qdbus api

  • Note: wait for some time before it finishes
for x in $(qdbus | sed '/^:/d'); do
  for y in $(qdbus $x); do
    qdbus $x $y | sed "s~^~$x $y ~"
 done
@jnoortheen
jnoortheen / ..xonsh-setup-readme.md
Last active November 20, 2020 07:32
# My Xonsh setup

My Xonsh setup

I use this following directory structure to install and use xonsh with ease. It enables adding new xontribs easily and keep the user packages in single place in a maintainable way.

My xonsh config folder - ~/.config/xonsh looks like this

~/.config/xonsh                                                                              🤖noor🖥firefist 🕰️ 12:36:51P 
 🐍xonsh $ tree -L 1 -a                                                                                                       
.
import importlib.resources as ires
import xonsh
def xontrib_metadata_json():
"""Loads and returns the xontribs.json file."""
import json
with ires.open_text("xonsh", "xontribs.json") as f:
md = json.load(f)
@jnoortheen
jnoortheen / django-bulk-insert.py
Created March 5, 2020 11:49
django bulk inserter
class ModelBulkCreator:
def __init__(self, cap=100):
self.Model: Model = None
self.cap = cap
self._objects = []
def add(self, obj):
if not self.Model:
self.Model = type(obj)
self._objects.append(obj)

dump

docker exec -t (docker ps -q --filter name="name") pg_dumpall -U db_user -c > dump-(date +%d-%m-%Y"_"%H_%M_%S).psql

import

In case of running service, stop the services using db container

@jnoortheen
jnoortheen / unique.py
Created January 2, 2019 15:15
GAE datastore/anom unique fields
from anom import Model, Key, transactional, delete_multi
from models.exceptions import IntegrityError
class Unique(Model):
"""A model to store unique values.
The only purpose of this model is to "reserve" values that must be unique
within a given scope, as a workaround because datastore doesn't support
the concept of uniqueness for entity properties.
@jnoortheen
jnoortheen / django_bulk_insert.py
Created November 19, 2018 06:20
Bulk Insert with Ignore for Django ORM
from collections import namedtuple
import enum
from django.db import connection, transaction
from django.db.models import Model, Subquery, IntegerField, Sum, Func
from django.db.models.sql import InsertQuery
from typing import List, Type, Dict, Any, Union, NamedTuple, Tuple
from . import signals
@jnoortheen
jnoortheen / install.sh
Last active November 24, 2017 04:42 — forked from jamiecollinson/install.sh
Installing OpenVBX on Ubuntu 16.04 EC2 instance
# check for updates
sudo apt-get update
sudo apt-get upgrade
# for installation doc https://github.com/twilio/OpenVBX/blob/master/INSTALL.markdown
# step1 download OpenVBX
wget -O openvbx.tgz https://github.com/twilio/OpenVBX/tarball/master
tar xf openvbx.tgz
sudo cp -r twilio-OpenVBX-bc9b3d6/* /var/www/html/