Skip to content

Instantly share code, notes, and snippets.

View nficano's full-sized avatar
:octocat:
deprecated

Nick Ficano nficano

:octocat:
deprecated
View GitHub Profile
@nficano
nficano / spotify.sh
Created November 17, 2020 20:21
spotify
interface=$(networksetup -listnetworkserviceorder | grep "Hardware Port: Wi-Fi" | grep -o -E "en[0-9]")
for ip in "78.31.8.0/24" "78.31.12.0/24" "193.182.8.0/24" "193.235.0.0/16" "193.182.0.0/16" "194.68.0.0/16" "193.235.232.103"; do
sudo route delete $ip 2 &>1 >/dev/null
sudo route -n add $ip -interface $interface >/dev/null
done
@nficano
nficano / pyfix.sh
Created June 10, 2020 14:40
python fix
# Install MacOS Xcode Command Line Tools (even if you've done it, run to make sure you're up-to-date)
xcode-select --install
# let's get rid of any existing python install
brew uninstall python --ignore-dependencies > /dev/null 2>&1
brew uninstall python2 --ignore-dependencies > /dev/null 2>&1
brew uninstall python3 --ignore-dependencies > /dev/null 2>&1
# just back-up your virtualenvs to be safe
mkdir $HOME/.virtualenvs
@nficano
nficano / hash_functions.rst
Created March 26, 2020 22:15
hash_functions

Hash Functions

A hash table is a data structure that implements an dictionary abstract data type, and is used to map keys to values.

array (key)
  ┌───┐
@nficano
nficano / hash_functions.ipynb
Last active March 26, 2020 22:13
Hash Functions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nficano
nficano / queues.md
Last active March 7, 2020 01:16
Queue Notes

Queues

Implementation:

You can implement a queue using either a linked list or an array.

Circular Array based queue:

Enqueuing:

@nficano
nficano / mapreduce.md
Last active March 3, 2020 11:17
MapReduce

MapReduce: Simplified Data Processing on Large Clusters

Jeffrey Dean and Sanjay Ghemawat Google, Inc.

Abstract

MapReduce is a programming model and an associated implementation for processing and generating large data sets. Users specify a map function that processes a key/value pair to generate a set of intermediate key/value pairs, and a reduce function that merges all intermediate values associated with the same intermediate key. Many real world tasks are expressible in this model, as shown in the paper.

Programs written in this functional style are automatically parallelized and executed on a large cluster of commodity machines. The run-time system takes care of the details of partitioning the input data, scheduling the program's execution across a set of machines, handling machine failures, and managing the required inter-machine communication. This allows programmers without any experience with parallel and distributed systems to easily utilize the resources of a large distributed system

@nficano
nficano / The Google file System.md
Last active March 2, 2020 20:35
The Google file System

The Google file System

Sanjay Ghemawat, Howard Gobioff, and Shun-Tak Leung Google

Categories and Subject Descriptors

[4]: 3—Distributed file systems

General Terms

Design, reliability, performance, measurement

@nficano
nficano / _pixel_density_mixin.scss
Created April 10, 2019 11:22
A SASS media query mixin for dealing with various screen pixel densities
@mixin for-res($size) {
@if $size == ldpi-up {
// 2017 LG 34" Ultrawide
@media
(min-resolution: 90dpi),
(min-resolution: 1dppx),
(-webkit-min-device-pixel-ratio: 1),
(min--moz-device-pixel-ratio: 1) {
@content;
}
@nficano
nficano / is_tree_balanced.py
Created May 19, 2016 14:44
Implement a function to check if a tree is balanced.
# -*- coding: utf-8 -*-
"""
4.1: Implement a function to check if a tree is balanced. For the purposes of
this question, a balanced tree is defined to be a tree such that no two leaf
nodes differ in distance from the root by more than one.
"""
class Node(object):
def __init__(self, value):
@nficano
nficano / boilerplate.py
Last active January 30, 2016 00:41
Python Boilerplate
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
def main():
args = sys.argv[1]
# start here
if __name__ == '__main__':
main()