Skip to content

Instantly share code, notes, and snippets.

@blaylockbk
blaylockbk / numpy_datetime_to_datetime.py
Last active September 4, 2025 07:05
Convert numpy.datetime64 to datetime.datetime
from datetime import datetime
import numpy as np
def to_datetime(date):
"""
Converts a numpy datetime64 object to a python datetime object
Input:
date - a np.datetime64 object
Output:
DATE - a python datetime object
@Lobsterrr
Lobsterrr / prision_labor_dpdgers_solution.py
Last active August 22, 2017 21:56 — forked from gggauravgandhi/gfc_l1q1_solution.py
Google's Foo.bar Two Array Difference Puzzle (Prison Labor Dodgers)
# Quiz: Prison Labor Dodgers
# ====================
# Commander Lambda is all about efficiency, including using her bunny prisoners for manual labor. But no one's been properly monitoring the labor shifts for a while, and they've gotten quite mixed up. You've been given the task of fixing them, but after you wrote up new shifts, you realized that some prisoners had been transferred to a different block and aren't available for their assigned shifts. And manually sorting through each shift list to compare against prisoner block lists will take forever - remember, Commander Lambda loves efficiency!
# Given two almost identical lists of prisoner IDs x and y where one of the lists contains an additional ID, write a function answer(x, y) that compares the lists and returns the additional ID.
# For example, given the lists x = [13, 5, 6, 2, 5] and y = [5, 2, 5, 13], the function answer(x, y) would return 6 because the list x contains the integer 6 and the list y doesn't. Given the lists x = [14, 27, 1, 4, 2, 50,
@gggauravgandhi
gggauravgandhi / gfc_l1q1_solution.py
Created June 3, 2017 06:49
Google's Foo.bar Two Array Difference Puzzle (Prison Labor Dodgers)
# Quiz: Prison Labor Dodgers
# ====================
# Commander Lambda is all about efficiency, including using her bunny prisoners for manual labor. But no one's been properly monitoring the labor shifts for a while, and they've gotten quite mixed up. You've been given the task of fixing them, but after you wrote up new shifts, you realized that some prisoners had been transferred to a different block and aren't available for their assigned shifts. And manually sorting through each shift list to compare against prisoner block lists will take forever - remember, Commander Lambda loves efficiency!
# Given two almost identical lists of prisoner IDs x and y where one of the lists contains an additional ID, write a function answer(x, y) that compares the lists and returns the additional ID.
# For example, given the lists x = [13, 5, 6, 2, 5] and y = [5, 2, 5, 13], the function answer(x, y) would return 6 because the list x contains the integer 6 and the list y doesn't. Given the lists x = [14, 27, 1, 4, 2, 50,
@zcaceres
zcaceres / Eyeballing-This.md
Last active July 18, 2025 14:52
Understanding Binding and 'this' in Javascript by zach.dev

How to Eyeball Your ‘This’ Context in Javascript

The early programmer struggles with the Javascript keyword this. But understanding your this context is easier than it seems.

This is all about where a function is invoked. Often, early programmers worry about where the function was declared. Perhaps the function was declared in a specific file or a particular object. Surely this changes it's this!

Nope.