Skip to content

Instantly share code, notes, and snippets.

@gidj
gidj / async_collection.py
Created December 11, 2019 12:43
Asyncio iterator
import asyncio
import random
ten = tuple(range(10))
async def ran_sleep(param):
value = random.choice(ten)
await asyncio.sleep(value)
print("{0} Sleep value:{1}".format(param, value))
@gidj
gidj / catalog_service.py
Last active December 9, 2019 23:37
Service idea for CatalogAPI
from enum import Enum
from typing import Tuple
from pydantic import BaseModel
MAX_OBJECTS_PER_PAGE = 10
class Categories(Enum):
MUSIC = "2"
@gidj
gidj / sfp_checklist.md
Last active January 28, 2019 22:29
SFP Post-release monitoring checklist

SFP Production Checklist

SFP Post-release Main Checklist

FeedProcessor

  • Error logs in FeedProcessor
  • Errors logs to look for:
    • "Error parsing line: "
    • "Processing terminated * could not download S3 file for customer: "
  • "Processing terminated * duplicate file detected for customer: "
@gidj
gidj / rpn.py
Last active February 28, 2020 21:11
Basic RPN implmementation
#
# Postfix Notation Calculator
#
# Postfix notation, is a way of writing mathematical
# expressions where each operator is preceded by the
# two operands it applies to and looks something
# like 2 5 3 + * instead of (5 + 3 ) * 2
#
# Write a function that takes a postfix notation expression
# returns the result of evaluating the expression.
# Add outside repository:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# For Node.js 9:
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install nodejs and npm:
@gidj
gidj / restoration from gzipped SQL dump
Last active September 6, 2017 19:41
Restoring a gzipped SQL dump
# First get the file:
scp ubuntu@10.0.1.120:~/rds_backups/backup-2017-08-27.sql.gz ./
# Drop and create the template database:
sudo -u postgres dropdb aya_prod && sudo -u postgres createdb aya_prod
# Copy it to the virtual disk, then create a new database with it:
@gidj
gidj / lifx_bulb_example.py
Last active October 6, 2016 16:34
LifxBulb Example
import pylifx
""" First you need to create a controller object using the controller group address """
controller_group_address = "MAC Address of controller group goes here"
gateway_controller = pylifx.LifxController(site_addr=controller_group_address)
""" Now, you have two options: controlling it via the gateway_controller object created above using the MAC address of the
bulb itself, or creating an individual LifxBulb object and controlling it directly.
@gidj
gidj / lifx_revised.py
Created October 6, 2016 16:05
Revised lifxbulb script
#! /usr/bin/env python
# -*- encoding: utf8 -*-
from __future__ import division, print_function, division, absolute_import
import argparse
import os
import pylifx
def power(bulb, state):
if state == 'on':