Skip to content

Instantly share code, notes, and snippets.

View sandys's full-sized avatar

Sandeep Srinivasa sandys

View GitHub Profile
@sandys
sandys / MOTA - Honest Voting.md
Last active January 27, 2023 09:08
MOTA (Many of the Above) or Honest Voting - an application of approval voting in India.

MOTA (Many of the Above) is Honest voting - you dont have to fear about vote wasting

This is very easy to describe to voters: vote for everyone you approve of.
MOTA does one thing very well - it removes any reason to vote against your favorite candidate.

Intuitive Explanation

In any voting system, if there's only ONE candidate - not voting and voting for the candidate are the same.
For TWO candidates - it is better to pick the one you like more.

1. If ur upgrading from an older fedora,
1.1 `sudo dnf remove docker-*`
1.2 `sudo dnf config-manager --disable docker-*`
1.2 please ensure `/etc/default/grub` doesnt contain `systemd.unified_cgroup_hierarchy=0`. If it does contain, then remove it and run `sudo grub2-mkconfig -o /boot/grub2/grub.cfg`
2. reboot
3. set firewall correctly using `sudo firewall-cmd --zone=docker --change-interface=docker0`
4. in `/etc/sysconfig/docker` please ensure `--live-restore` is removed
5. reboot
6. docker should work
@sandys
sandys / Fastapi-sqlalchemy-pydantic-dataclasses-reloadable-logging.md
Last active April 12, 2024 01:38
fastapi with python 3.10 dataclasses - used to create both sqlalchemy and pydantic models simultaneously. And setting up sqlalchemy the right way (without deadlocks or other problems). Additionally, this also takes care of unified logging when running under gunicorn..as well as being able to run in restartable mode.
@sandys
sandys / git_100mb_clean.md
Created April 28, 2020 14:13
how to clean your git repo of all blobs greater than 100M (github friendly)
  1. Download git-filter-repo script
  2. name the file as clean.py
  3. run python /tmp/clean.py --force --strip-blobs-bigger-than 100M --refs
@sandys
sandys / pg-docker.md
Created March 20, 2020 09:27
running postgresql on your laptop without installing it (using docker) . with connections to python

docker network create pg

docker run -it --rm -P -p 5432:5432 --name pg -e POSTGRES_PASSWORD=password -e POSTGRES_USER=postgres -e POSTGRES_DB=production -v pgdata:/var/lib/postgresql/data --network=pg postgres

pgdata is the name of the docker volume. You can check it using docker volume ls and docker volume inspect pgdata. You can delete the docker volume by docker volume rm pgdata and prune all volumes using docker volume prune docker volumes are created in your central docker directory (usually /var/lib/docker/overlay2 ). You generally dont need to care about this.

You can now access it in many ways:

@sandys
sandys / next.config.js
Created February 17, 2020 14:44
next.config.js for superprops
const withPlugins = require('next-compose-plugins');
const withTM = require('next-transpile-modules')(['reusecore', 'common']);
const withOptimizedImages = require('next-optimized-images');
const withFonts = require('next-fonts');
const withCSS = require('@zeit/next-css');
const path = require("path");
module.exports = withPlugins(
[
@sandys
sandys / gridsearchcv.py
Created August 18, 2019 16:26
Gridsearchcv with k-fold cross validation and early stopping
#
... import xgboost.sklearn as xgb
... from sklearn.model_selection import GridSearchCV
... from sklearn.model_selection import TimeSeriesSplit
...
... cv = 2
...
... trainX= [[1], [2], [3], [4], [5]]
... trainY = [1, 2, 1, 2, 1]
@sandys
sandys / pythonhostedissues.md
Last active May 7, 2018 15:43
pythonhosted issues

user@instance-mumbai:~/docker-setup-v2/flask$ dig files.pythonhosted.org A

; <<>> DiG 9.10.3-P4-Ubuntu <<>> files.pythonhosted.org A ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3624 ;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512

@sandys
sandys / datadog.service
Last active March 19, 2023 20:10
Getting Datadog logs to work with Docker Swarm or journald
[Unit]
Description=Datadog Docker Swarm
After=systemd-journald.service
Requires=systemd-journald.service
[Service]
ExecStart=/bin/zsh -c "coproc while true; do ncat --ssl intake.logs.datadoghq.com 10516; done ;journalctl -o json -f | jq -r --unbuffered '\"c441ade4f5f4d04c \" + ({ message:.MESSAGE, service_name:.COM_DOCKER_SWARM_SERVICE_NAME, container:.CONTAINER_NAME, containerid:.CONTAINER_ID_FULL, host:._HOSTNAME,pid:(._PID // \"-\"), timestamp:(.__REALTIME_TIMESTAMP|tonumber/1000000|todate),\"syslog.severity\":((.PRIORITY|tonumber)) }|tostring)' >&p 2>&p"
@sandys
sandys / nvidia-docker-cuda-setup.sh
Created March 3, 2018 09:18
getting nvidia-docker2 with CUDA running on Ubuntu-16.04
wget https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda-repo-ubuntu1604-9-1-local_9.1.85-1_amd64
sudo add-apt-repository ppa:graphics-drivers
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -