Skip to content

Instantly share code, notes, and snippets.

View curlup's full-sized avatar

Pavel T curlup

  • Knowledge Systems @ DFCI
View GitHub Profile
@miohtama
miohtama / gist:34a83d870a14aa7e580d
Last active October 31, 2021 13:21
Safe evaluation of math expressions in Python, using byte code verifier and eval()
""""
The orignal author: Alexer / #python.fi
"""
import opcode
import dis
import sys
import multiprocessing
@NikolayS
NikolayS / 00_slowest_queries_full.sql
Last active November 28, 2023 19:06
Useful Postgres Queries
-- In pg_stat_statements, there is a problem: sometimes (quite often), it registers the same query twice (or even more).
-- It's easy to check in your DB:
--
-- with heh as (
-- select userid, dbid, query, count(*), array_agg(queryid) queryids
-- from pg_stat_statements group by 1, 2, 3 having count(*) > 1
-- ) select left(query, 85) || '...', userid, dbid, count, queryids from heh;
--
-- This query gives you "full picture", aggregating stats for each query-database-username ternary
import logging
import boto3
from botocore.exceptions import ClientError, BotoCoreError
import requests
from requests import RequestException
def get_instance_name():
try:

Using SLURM cluster GPU's on Google Colab

This document describe how to start a jupyter session on a SLURM cluster GPU node and, optionnaly, using it from Google Collab.

Using google Collab is optional and can pose serious security risks, please carrefully read the Google local runtime documentation and ask your system administrator for permission before connecting Google Colab to a local server.

1. First time setup