Skip to content

Instantly share code, notes, and snippets.

View rafiamafia's full-sized avatar

Rafia Qutab rafiamafia

  • NASA Jet Propulsion Laboratory
  • Los Angeles, CA
View GitHub Profile

Labels:

How to copy Labels from source repo to dest repo

  1. Open the "Labels" tab in your GitHub source repo and paste this in the browser js console:
var labels = [];
[].slice.call(document.querySelectorAll(".js-label-link"))
.forEach(function(element) {
@rafiamafia
rafiamafia / jenkins_tricks.md
Last active May 26, 2022 06:34
time to version control outside your brain

Validate your Jenkinsfile

curl -X POST --user username-:accesstoken -F "jenkinsfile=<Jenkinsfile" https://jenkins-host-dns/pipeline-model-converter/validate

Jenkins cleanup

Workspace Plugin found here

Docker:

$ docker images #list all images

$ docker ps #list running containsers

$ docker ps -al -q #list all containers

$ docker container prune ## delete all stopped containers

@rafiamafia
rafiamafia / PyTrie.py
Last active August 15, 2018 16:49
A Trie class in python
class TrieNode:
def __init__(self):
self.children = dict()
self.end_of_word = False
def leafNode(self):
return self.end_of_word
def freeNode(self):
return not any(self.children)
class Node:
def __init__(self, data):
self.data = data
self.parent = self
self.rank = 0
class DisjointSet:
def __init__(self):
self.map = {}
@rafiamafia
rafiamafia / PyBinarySearchTree.py
Last active June 17, 2018 19:28
Python Binary Search Tree Implementation
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
# To allow duplicates we can store extra information i.e count
# to optimize memory and make search, insert, delete easier
#self.count = 1
def insert(self, data):
@rafiamafia
rafiamafia / PyStack.py
Created February 21, 2018 02:50
Stack implementation in Python
class PyStack():
def __init__(self):
self._items = []
def push(self, item):
self._items.append(item)
def pop(self):
if not self.isEmpty():
return self._items.pop()
@rafiamafia
rafiamafia / PyLinkedList.py
Created February 20, 2018 01:45
Python3 Linked List implementation
class Node:
def __init__(self, data, nextNode=None):
self.data = data
self.next = nextNode
def __str__ (self):
return str(self.data)
class PyLinkedList:
def __init__(self):
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@rafiamafia
rafiamafia / media_engineering_take_home.md
Last active April 25, 2019 19:35
Take home assignment for Fullscreen software engineering candidates.

Welcome to California

California is famous not only for its booming tech economy, controversial film industry, and yearlong summers, but due to its position on both the Pacific and North America plates, it experiences approximately 10,000 earthquakes each year. U.S. Geological Survey (USGS) provides near real time data and information and earth observations so that policy makers and the public have the understanding they need to enhance precedence, response and resilience.

You can find data of all earthquakes for the past 30 days here

Using the CSV above, write a Ruby program to find the first 10 cities and states with an earthquake that was felt in Los Angeles in a given date range. For the sake of over simplicity, let's assume a linear relationship between the magnitude of an earthquake and the distance it travels before it can be felt. Let's assume a magnitude-5 earthquake can be felt at up to a distance of 500 miles, ma