Skip to content

Instantly share code, notes, and snippets.

View deepanshu17's full-sized avatar
💭
God problem requires God solution

Deepanshu Jain deepanshu17

💭
God problem requires God solution
View GitHub Profile
@rolisz
rolisz / gpu_monitoring.py
Created November 21, 2018 13:07
Script to send GPU monitoring data obtained with nvidia-smi to Stackdriver.
from subprocess import Popen, PIPE
import os
import time
import sys
def compute_stats():
all_gpu = []
all_mem = []
for i in range(10):
p = Popen(["nvidia-smi","--query-gpu=utilization.gpu,utilization.memory", "--format=csv,noheader,nounits"], stdout=PIPE)
@P7h
P7h / Stopwatch.scala
Created May 12, 2017 11:11
DateTime difference between 2 timestamps. Granularity from centuries to nanos.
import java.time.LocalDateTime
import scala.annotation.tailrec
object Stopwatch {
def main(args: Array[String]): Unit = {
val from = LocalDateTime.of(2001, 9, 11, 8, 46, 40, 250)
val to = LocalDateTime.now()
@wojteklu
wojteklu / clean_code.md
Last active March 19, 2026 21:26
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@perrygeo
perrygeo / base64_padding.md
Last active December 9, 2025 17:50
Avoiding TypeError: Incorrect padding with Python's base64 encoding

Avoiding padding errors with Python's base64 encoding

>>> import base64
>>> data = '{"u": "test"}'
>>> code = base64.b64encode(data)
>>> code
'eyJ1IjogInRlc3QifQ=='