Skip to content

Instantly share code, notes, and snippets.

View gcrsaldanha's full-sized avatar
🏠
Working from home

Gabriel Saldanha gcrsaldanha

🏠
Working from home
View GitHub Profile
@gcrsaldanha
gcrsaldanha / find_factors.py
Created December 31, 2018 01:13
Simple method to find the factors of a given number (computationally expensive)
def find_factors(number):
factors = []
for factor in range(1, number + 1): # makes range go from 1 to number (inclusive)
if number % factor == 0:
factors.append(factor)
return factors
# Or by using list comprehensions
def find_factors_comprehesion(number):
return [factor for factor in range(1, number + 1) if number % factor == 0]
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, World!'
if __name__ == '__main__':
app.run()
@gcrsaldanha
gcrsaldanha / set_literal_vs_set_method.py
Created June 27, 2018 12:16
This gist demonstrates the usage of `set()` and `{}` for building sets in python and when one is preferred over the other
import dis
def non_empty_set_literal():
return {1, 2, 3} # Build a set {1, 2, 3}
def non_empty_set_method():
return set([1, 2, 3]) # Builds a set {1, 2, 3} from a list
def empty_set_literal():
@gcrsaldanha
gcrsaldanha / tmux-cheatsheet.markdown
Created June 25, 2018 21:01 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname