Skip to content

Instantly share code, notes, and snippets.

View sergray's full-sized avatar

Sergey Panfilov sergray

View GitHub Profile
@sergray
sergray / awsctx
Created April 13, 2025 12:10
Shell command for setting AWS_PROFILE with awsctx helper function
function awsctx() {
profile=$(aws configure list-profiles | fzf)
eval "export AWS_PROFILE=$profile"
echo "AWS_PROFILE=$(echo $AWS_PROFILE)"
}
@sergray
sergray / async_flask.py
Last active January 27, 2025 21:33
Asynchronous requests in Flask with gevent
"""Asynchronous requests in Flask with gevent"""
from time import time
from flask import Flask, Response
from gevent.pywsgi import WSGIServer
from gevent import monkey
import requests
@sergray
sergray / gist:91f9eb4ca93340d893e36cf007926977
Created November 13, 2020 11:23
test_querycontacts.py
import querycontacts
import dns
import sys
import socket
print('sys.version:', sys.version)
print(querycontacts, getattr(querycontacts, '__version__', None))
print(dns, getattr(dns, '__version__', None))
querycontacts.ContactFinder().find(socket.gethostbyname('google.nl'))
@sergray
sergray / docker_pg_dump.sh
Created December 6, 2018 14:37
dump postgresql DB with specific pg_dump version running in Docker container
#!/bin/bash
pg_version=10.5 pg_user=user db_name=db && \
docker run -it --rm -v /tmp/pgdump:/tmp/pgdump:rw --network=host postgres:$pg_version \
pg_dump -h localhost -U $pg_user -W -f /tmp/pgdump/${db_name}_$(date +%Y%m%d%H%M%S) -Fc -v $db_name
@sergray
sergray / rtl-sdr-rpi-install.md
Last active June 4, 2018 20:12 — forked from floehopper/install.md
Install rtl-sdr on Raspian on Raspberry Pi
jamesmead@floehopper.local:~$ sudo dd bs=1m if=/Users/jamesmead/Downloads/2015-02-16-raspbian-wheezy.img of=/dev/disk2
pi@raspberrypi ~ $ sudo raspi-config
# Choose option 1 to "Expand Filesystem" - Ensures that all of the SD card storage is available to the OS
# Choose Finish & reboot

pi@raspberrypi ~ $ sudo apt-get update

Keybase proof

I hereby claim:

  • I am sergray on github.
  • I am sergray (https://keybase.io/sergray) on keybase.
  • I have a public key whose fingerprint is 8D10 3889 4812 2AC6 FCE4 C2AA 72C7 36F2 8A57 BBFC

To claim this, I am signing this object:

#!/usr/bin/env python
from __future__ import print_function
from datetime import datetime
from subprocess import call
from mercury206 import commands, communications, config
@sergray
sergray / gico
Created September 9, 2014 10:04
checkout git branch by substring
#!/usr/bin/env python
"Checkout git branch with name substring"
from __future__ import print_function
import sys
from subprocess import check_output
@sergray
sergray / mongolyze.py
Created February 21, 2012 19:41
Python script for automated analysis of slow queries in mongodb
"""
Script for automated analysis of profiling data in MongoDB,
gathered by Mongo with db.setProfilingLevel(1).
See <http://www.mongodb.org/display/DOCS/Database+Profiler>
TODO: pass collection and database with profiling data in arguments
TODO: make thread-safe
TODO: handle map-reduce operations
"""
@sergray
sergray / autoscout.js
Created February 8, 2017 21:33
Export Autoscout24 favorites in a JSON list
var favorites = [];
$$('.listItem').forEach(function(it){
favorites.push({
link: it.attributes['data-detailpage'].value,
image: $('.listImage img', it).attr('src'),
price: $('.listItemHeaderPrice', it).text().trim(),
date: $('.listItemHeaderEZ', it).text().trim(),
mileage: $('.listItemHeaderMileage', it).text().trim(),
title: $('span.fontLoud', it).text().trim(),
address: $('span.fontSilent', it).text().trim()