docker exec -t (docker ps -q --filter name="name") pg_dumpall -U db_user -c > dump-(date +%d-%m-%Y"_"%H_%M_%S).psql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten_array(array): | |
""" | |
flattens multi-dimensional array/list to one dimensional | |
Args: | |
array (list): multi-dimensional list | |
Returns: | |
list: resultant one-dimensional list | |
>>> flatten_array([1, 2, 3, 4, [7, 8, 9]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while true | |
do | |
echo "checking connection" | |
if [ -n "$(nmcli -p d | grep cdma)" ]; then | |
echo "modem is connected" | |
if ! [ "$(ping -c 1 -W 30 google.com)" ]; then | |
nmcli nm wwan off | |
nmcli nm wwan on | |
# nmcli con up id "evdo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.decorators import login_required | |
from django.conf import settings | |
from re import compile | |
from django.http import HttpRequest, HttpResponse | |
from core.models import ActivityLog | |
from core.utils import get_ip_address | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
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
.
OlderNewer