Skip to content

Instantly share code, notes, and snippets.

View rshk's full-sized avatar
😎
Being awesome

Samuele Santi rshk

😎
Being awesome
  • Tampa, Florida
View GitHub Profile
"""
Fade IN/OUT some text..
"""
import sys
import time
import pygame
## Show some text fade in/out
@rshk
rshk / db.sh
Last active December 15, 2021 12:41
#!/bin/bash
CONTAINER_NAME=my-postgres-database
VOLUME_NAME="${CONTAINER_NAME}-data"
POSTGRES_PASSWORD=mysecretpassword
POSTGRES_IMAGE=postgres:14
case "$1" in
start)
@rshk
rshk / solardata.py
Created July 27, 2017 15:31
Get solar data from hamqsl.com XML
from collections import namedtuple
import re
import itertools
from datetime import datetime
import lxml.etree
import requests
WIDTH = 40
DATA_URL = 'http://www.hamqsl.com/solarxml.php'
@rshk
rshk / generate_sine_table.py
Created December 19, 2012 16:54
Sine table generation using Python
#!/usr/bin/env python
## Generate sine table
import math
def rescale(X,A,B,C,D,force_float=False):
retval = ((float(X - A) / (B - A)) * (D - C)) + C
if not force_float and all(map(lambda x: type(x) == int, [X,A,B,C,D])):
return int(round(retval))
@rshk
rshk / kibana-apache-logs.json
Created May 6, 2014 16:16
Kibana: analyze Apache logs
{
"title": "Apache logs",
"services": {
"query": {
"list": {
"0": {
"query": "*",
"alias": "",
"color": "#7EB26D",
"id": 0,
@rshk
rshk / lipsum.js
Created September 4, 2017 16:01
Simple Lorem Ipsum generation in Javascript.
// Some stuff from https://github.com/knicklabs/lorem-ipsum.js
const WORDS = [
'ad', 'adipisicing', 'aliqua', 'aliquip', 'amet', 'anim', 'aute',
'cillum', 'commodo', 'consectetur', 'consequat', 'culpa',
'cupidatat', 'deserunt', 'do', 'dolor', 'dolore', 'duis', 'ea',
'eiusmod', 'elit', 'enim', 'esse', 'est', 'et', 'eu', 'ex',
'excepteur', 'exercitation', 'fugiat', 'id', 'in', 'incididunt',
'ipsum', 'irure', 'labore', 'laboris', 'laborum', 'Lorem',
'magna', 'minim', 'mollit', 'nisi', 'non', 'nostrud', 'nulla',
@rshk
rshk / create-vm.ps1
Created July 29, 2014 15:49
PowerShell Create VM
# ------------------------------------------------------------
# Create Hyper-V virtual machine via PowerShell
# ------------------------------------------------------------
# Variables
$VM_NAME = "PS_TEST_VM"
$VM_MAC = "00:15:5d:11:22:01"
$VM_RAM = 256GB
$VM_CPUS = 16
@rshk
rshk / fields.py
Last active May 24, 2018 16:28
Flask-GraphQL Apollo file upload quickfix
import graphene
class FileUpload(graphene.Scalar):
@staticmethod
def serialize(value):
return None
@staticmethod
@rshk
rshk / README.md
Last active May 20, 2018 04:07
Python colorful logging example

Usage example

% python -i colorful_logging_formatter.py 
>>> import logging
>>> logger = logging.getLogger('foo')
>>> logger.setLevel(logging.DEBUG)
>>> import sys
>>> handler = logging.StreamHandler(sys.stderr)
>>> handler.setFormatter(ColorLogFormatter())
@rshk
rshk / build-docker-image.sh
Created August 29, 2016 17:40
build-docker-image.sh
#!/bin/bash
# Version tag needs to be dependent on all the files that will affect
# the generated image. Currently, only the dockerfile and Python
# requirements.
VERSION_TAG="$( sha1sum Dockerfile requirements/*.txt | sha1sum | cut -d' ' -f1 )"
echo "Image version: ${VERSION_TAG}"
echo "Commit SHA1: ${CIRCLE_SHA1}"