Skip to content

Instantly share code, notes, and snippets.

View sansyrox's full-sized avatar
🐶
Exiting Vim!!!

Sanskar Jethi sansyrox

🐶
Exiting Vim!!!
View GitHub Profile
@sansyrox
sansyrox / heap.py
Created July 1, 2020 16:50
Custom Comparators in Python heap
class FreqWord(object):
def __init__(self, freq, word):
self.freq = freq
self.word = word
def __lt__(self, other):
if self.freq != other.freq:
return lt(self.freq, other.freq)
else:
# opposite sort
@sansyrox
sansyrox / FB-PE-InterviewTips.md
Created May 18, 2020 22:38 — forked from ameenkhan07/FB-PE-InterviewTips.md
Facebook Production Engineering Interview

What to Expect and Tips

• 45-minute systems interview, focus on responding to real world problems with an unhealthy service, such as a web server or database. The interview will start off at a high level troubleshooting a likely scenario, dig deeper to find the cause and some possible solutions for it. The goal is to probe your knowledge of systems at scale and under load, so keep in mind the challenges of the Facebook environment.
• Focus on things such as tooling, memory management and unix process lifecycle.

Systems

More specifically, linux troubleshooting and debugging. Understanding things like memory, io, cpu, shell, memory etc. would be pretty helpful. Knowing how to actually write a unix shell would also be a good idea. What tools might you use to debug something? On another note, this interview will likely push your boundaries of what you know (and how to implement it).

Design/Architecture 

Interview is all about taking an ambiguous question of how you might build a system and letting

@sansyrox
sansyrox / Contract Killer 3.md
Created May 13, 2020 11:51 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@sansyrox
sansyrox / postgres-brew.md
Created April 17, 2020 13:25 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@sansyrox
sansyrox / parse_json.py
Created March 17, 2020 15:36 — forked from amaciel81/parse_json.py
Import a JSON file. If condition is met, print two attributes.
from json import load as json_load
with open("sample_input.json") as input_fh:
people = json_load(input_fh)
for person in people["people"]:
if person["age"] >= 30:
print("Name: {name}, City: {city}".format(name=person["name"], city=person["city"]))
@sansyrox
sansyrox / parse_csv.py
Created March 17, 2020 15:36 — forked from amaciel81/parse_csv.py
Import a CSV file. If condition is met, print two attributes for that condition
from csv import reader as csv_reader
with open("sample_input.csv") as input_fh:
people = csv_reader(input_fh)
headers = next(people)
for row in people:
person = (dict(zip(headers, row)))
if int(person["age"]) >= 30:
print("Name: {name}, City: {city}".format(name=person["name"], city=person["city"]))
@sansyrox
sansyrox / heap.py
Created February 23, 2020 19:56
Dijkstra's
from collections import defaultdict
from heapq import *
def dijkstra(edges, f, t):
g = defaultdict(list)
for l,r,c in edges:
g[l].append((c,r))
q, seen, mins = [(0,f,())], set(), {f: 0}
while q:
@sansyrox
sansyrox / tail.py
Created January 26, 2020 19:48
Create a Program to Imitate the working of the tail command in Linux
from collections import deque
def get_last(filename, n=5):
"""
Returns the last n lines from the file
"""
try:
with open(filename) as f:
return deque(f, n)
@sansyrox
sansyrox / mysql_cheat_sheet.md
Created October 22, 2019 13:52 — forked from bradtraversy/mysql_cheat_sheet.md
MySQL Cheat Sheet

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH