Skip to content

Instantly share code, notes, and snippets.

🚆
.

Keyan Pishdadian keyan

Block or report user

Report or block keyan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@keyan
keyan / lmdb.tcl
Created Feb 27, 2019 — forked from antirez/lmdb.tcl
LMDB -- First version of Redis written in Tcl
View lmdb.tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@keyan
keyan / dark.css
Last active Feb 27, 2019
slack dark mode css
View dark.css
body { background: #222; color: #e6e6e6; }
a { color: #949494; }
a:link, a:visited { color: #949494; }
a:hover, a:active, a:focus { color: #c7c7c7; }
hr { border-bottom: 1px solid #424242; border-top: 1px solid #222; }
@keyan
keyan / gtfs_rt_proto_parser.py
Created Feb 15, 2019
A small helper script for quickly parsing agency GTFS-RT feeds for debugging
View gtfs_rt_proto_parser.py
"""
A small helper script for quickly parsing agency GTFS-RT feeds for debugging.
Usage:
$ service_venv python3 parse_gtfs_rt_feed.py --help
"""
import argparse
import requests
from google.transit import gtfs_realtime_pb2
@keyan
keyan / nested_map.py
Created Nov 1, 2018
Apply a func to a target class to any fields and items nested within an object
View nested_map.py
def nested_map(obj: object, func, target_class) -> Any:
"""
Accepts any object type and calls .func() on any nested fields of the specified class.
"""
def _nested_map(obj: object) -> None:
"""
Traverse all object fields and list items, calling func when possible.
"""
# Objects without __dict__ cannot have vars() called
if not hasattr(obj, '__dict__'):
@keyan
keyan / ssl_disable.md
Last active Mar 19, 2018
Disabling Python's SSL verification
View ssl_disable.md

It is pretty confusing how to add custom root certificates to Python's trusted cert list as it doesn't use system certs. Instead I just disabled verification entirely. Note this is for local development only and SHOULD NOT BE USED IN PRODUCTION:

$ export PYTHONHTTPSVERIFY=0

This is helpful for capturing and inspecting outbound packets using Charles proxy or a similar tool.

@keyan
keyan / config_management_terms.md
Last active Mar 18, 2018
Chef <-> Salt <-> Puppet terminology equivalence
View config_management_terms.md

Recently I have had to deal with Salt configuration. I am doing product work so I didn't want to focus too much on deeply grasping Salt, but instead knowing the terminology equivalents to Chef/Puppet which I am comfortable with.

Salt Chef Puppet
state resource resource
states recipes manifests
formula* cookbook module
pillars databags hiera
grains ohai facter
@keyan
keyan / fair_lock.py
Created Jan 19, 2018
Implement a "fair lock"
View fair_lock.py
"""
A "fair lock" is a lock which guarantees threads are given access in
the order that they requested it. The whole idea here is just to play
with the concurrency control ideas, because Python's Queue
implementation is already threadsafe, therefore acheiving the same
behavior as the FIFO lock below.
"""
import threading
@keyan
keyan / halyard.md
Created Jan 4, 2018
Some notes on how to setup spinnaker and use halyard
View halyard.md

Installation

  • Halyard must be run on Ubuntu 14.04 (Trusty), you will likely use a VM to run it:
$ vagrant init ubuntu/trusty64; vagrant up --provider virtualbox
  • Sync your local kubeconfig with the guest VM by adding the following line to your newly created Vagrantfile:
@keyan
keyan / email_todo_authors.py
Last active Jan 4, 2018
A script you can run in your repo to scan for TODO messages and email the authors asking them to fix it! Can be easily adapted for other search strings.
View email_todo_authors.py
#!/usr/bin/python
"""
This script searches the git repo looking for TODO messages, determines the
author of the line, then emails that author asking them to repair the issue.
It is intended to be run at a regular interval on a CI server or cron-job
server. By changing the `SEARCH_STRING` the script can be easily adapted to
trigger on any undesired code.
Usage:
@keyan
keyan / task1.exs
Created Oct 30, 2017 — forked from moklett/task1.exs
Elixir Task - Crash Handling
View task1.exs
# This demonstrates that, when using async/await, a crash in the task will crash the caller
defmodule Tasker do
def good(message) do
IO.puts message
end
def bad(message) do
IO.puts message
raise "I'm BAD!"
end
You can’t perform that action at this time.