Skip to content

Instantly share code, notes, and snippets.

View balamuruganky's full-sized avatar

Balamurugan Kandan balamuruganky

View GitHub Profile
@Phaiax
Phaiax / example_dgram.py
Last active February 4, 2025 15:26
Python AF_UNIX socket / socketserver example (datagram and streaming mode)
"""
LICENSE: MIT
Example of using unix socket in SOCK_DGRAM mode.
"""
import socket
import socketserver
import time
@ajelenak
ajelenak / h5-to-zarr.py
Last active March 29, 2025 23:01
Python code to extract HDF5 chunk locations and add them to Zarr metadata.
# Requirements:
# HDF5 library version 1.10.5 or later
# h5py version 3.0 or later
# pip install git+https://github.com/HDFGroup/zarr-python.git@hdf5
import logging
from urllib.parse import urlparse, urlunparse
import numpy as np
import h5py
import zarr
@mowings
mowings / loop.sh
Last active April 6, 2025 17:30
Bash -- sleep until a specific time, like tomorrow midnight
#!/bin/bash
# Sometimes you want to sleep until a specific time in a bash script. This is useful, for instance
# in a docker container that does a single thing at a specific time on a regular interval, but does not want to be bothered
# with cron or at. The -d option to date is VERY flexible for relative times.
# See
# https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html#Relative-items-in-date-strings
# For details
# ALPINE USERS: You will need to install coreutils, as the built-in busybox date does not handle -d correctly.
@erdostom
erdostom / Dockerfile
Last active December 26, 2024 08:25
Good starter Dockerfile + docker-compose.yml for Rails 6.
FROM ruby:2.6.5-alpine
RUN apk add --update --no-cache bash build-base nodejs sqlite-dev tzdata postgresql-dev yarn
RUN gem install bundler:2.1.4
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install --check-files
@lkluft
lkluft / copy_netcdf_group.ipynb
Created December 11, 2018 09:11
Copy a single group from one netCDF to another.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
const closestEnemy = (arr) => {
let player = [];
let enemy = [];
let distance = 0;
let rowLength = arr[0].length;
let board = arr.length;
for (let i = 0; i < board; i++) {
let row = arr[i].split("");
@baiwfg2
baiwfg2 / CMakeLists.txt
Created September 29, 2018 12:42
How to use add_custom_target and add_custom_command correctly in cmake
# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990
# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://blog.csdn.net/gubenpeiyuan/article/details/51096777
cmake_minimum_required(VERSION 3.10)
@JiaweiZhuang
JiaweiZhuang / extract_NetCDF_group.ipynb
Created August 21, 2018 22:52
Extract a group in a NetCDF4 file as a standalone NC file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kizzx2
kizzx2 / docker-compose.yml
Last active April 29, 2025 07:54
Restart a docker container periodically with docker-compose
version: '3'
services:
app:
image: nginx:alpine
ports: ["80:80"]
restart: unless-stopped
restarter:
image: docker:cli
volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
@GrayJack
GrayJack / config.txt
Last active March 30, 2025 13:55
Very complete and documented config.txt file for raspberry pi
# See /boot/overlays/README for all available options
##############################################################################
## Raspberry Pi Configuration Settings
##
## Revision 18, 2018/03/05
##
## Details taken from the eLinux wiki
## For up-to-date information please refer to wiki page.
##
## Wiki Location : http://elinux.org/RPiconfig