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
const { AsyncLocalStorage } = require('node:async_hooks') | |
const get = require('lodash/get') | |
const httpStorage = new AsyncLocalStorage() | |
const gqlStorage = new AsyncLocalStorage() | |
const KEY = Symbol('_context') | |
// RESOLVERS // | |
async function resolveAllUsers (context, path) { |
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 logging | |
import threading | |
import time | |
import sshtunnel | |
from sshtunnel import HandlerSSHTunnelForwarderError, SSHTunnelForwarder | |
sshtunnel.DEFAULT_LOGLEVEL = 1 | |
logging.basicConfig(filename='example.log', filemode='w', level=sshtunnel.DEFAULT_LOGLEVEL) | |
logging.warning('Start example! v %s', sshtunnel.__version__) |
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 | |
for v in `docker ps --format '{{.Names}}\t{{.Status}}' | grep postgres | awk '{ print $1 }'` | |
do | |
echo $v | |
NNN=$v | |
docker exec -it $NNN vacuumdb --all -U postgres --full --analyze | |
done |
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
print('class Meta(type)') | |
class Meta(type): | |
@classmethod | |
def __prepare__(mcs, name, bases, **kwargs): | |
print(' Meta.__prepare__(mcs=%s, name=%r, bases=%s, **%s)' % ( | |
mcs, name, bases, kwargs |
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
#!/usr/bin/env bash | |
set -o errexit # always exit on error | |
set -o pipefail # don't ignore exit codes when piping output | |
set -o nounset # fail on unset variables | |
set -o xtrace # print command traces before executing command | |
echo "PWD=$PWD" | |
# # |
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
echo 1.0.0 | python -c "v = input().strip().split('.'); v[-1] = str(int(v[-1]) + 1); print('.'.join(v))" |
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
"""Google spreadsheet related. | |
Packages required: oauth2client, google-api-python-client | |
* https://gist.github.com/miohtama/f988a5a83a301dd27469 | |
""" | |
from oauth2client.service_account import ServiceAccountCredentials | |
from apiclient import discovery | |
def get_credentials(scopes: list) -> ServiceAccountCredentials: |
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 logg(func): | |
def logged_func(*args, **kwargs): | |
print(func.__name__ + '() ...', | |
args, kwargs) | |
return func(*args, **kwargs) | |
logged_func.__doc__ = func.__doc__ | |
logged_func.__name__ = func.__name__ | |
return logged_func | |
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
#!/usr/bin/env python3 | |
class Matrix: | |
def __init__(self, m): | |
self.m = m | |
def __str__(self): | |
return "Matrix(%r)" % self.m | |
def __repr__(self): |
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 functools import wraps | |
def debug(func): | |
print('debug(', func.__qualname__, ')') | |
name = func.__qualname__ | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
print('CALL:', name, args, kwargs) |
NewerOlder