Skip to content

Instantly share code, notes, and snippets.

View curlup's full-sized avatar

Pavel T curlup

  • Knowledge Systems @ DFCI
View GitHub Profile

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

import logging
import boto3
from botocore.exceptions import ClientError, BotoCoreError
import requests
from requests import RequestException
def get_instance_name():
try:
@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
@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
@acolyer
acolyer / service-checklist.md
Last active January 30, 2024 17:39
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@pmeenan
pmeenan / user-timing-rum.js
Last active January 18, 2024 23:46
Support routine for adding W3C user timing events to a site. Includes some basic polyfill support for browsers that don't support user timing or navigation timing (though the start time for non-navigation timing support could be improved with IE < 9 to use IE's custom start event).
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
package systemd
import (
"os"
"strconv"
"syscall"
)
const (
listenFdsStart = 3
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 6, 2024 12:37
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@majek
majek / README.md
Created April 26, 2012 15:15
Passing TCP socket descriptors around

Passing TCP socket descriptors around

In linux, normally, it is impossible to "bind()" to the same TCP port twice. If you try to bind to the same port from second proces unix processes you'll see:

socket.error: [Errno 98] Address already in use

#!/usr/bin/env python
# encoding: utf-8
"""
Changes the format specifier on SSTables **IN PLACE**
e.g. change
TwitterUserHistoricalValues-h-20983-Data.db
to be
TwitterUserHistoricalValues-g-20983-Data.db