View urlencode.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
alias urlencode='python3 -c "import sys, urllib.parse as ul; print(ul.quote_plus(sys.argv[1]))"' |
View this_help.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
help(this) | |
# Help on module this: | |
# NAME | |
# this | |
# MODULE REFERENCE | |
# https://docs.python.org/3.7/library/this | |
# The following documentation is automatically generated from the Python |
View zen_of_python.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import this | |
# The Zen of Python, by Tim Peters | |
# Beautiful is better than ugly. | |
# Explicit is better than implicit. | |
# Simple is better than complex. | |
# Complex is better than complicated. | |
# Flat is better than nested. | |
# Sparse is better than dense. | |
# Readability counts. |
View this_source.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = """Gur Mra bs Clguba, ol Gvz Crgref | |
Ornhgvshy vf orggre guna htyl. | |
Rkcyvpvg vf orggre guna vzcyvpvg. | |
Fvzcyr vf orggre guna pbzcyrk. | |
Pbzcyrk vf orggre guna pbzcyvpngrq. | |
Syng vf orggre guna arfgrq. | |
Fcnefr vf orggre guna qrafr. | |
Ernqnovyvgl pbhagf. | |
Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf. |
View view_this_sourcecode.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import this | |
import inspect | |
print(inspect.getsource(this)) |
View impl_my_sql.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//handle COM_INIT_DB command, you can check whether the dbName is valid, or other. | |
func (Foo) UseDB(dbName string) error { | |
panic("not implemented") // TODO: Implement | |
} | |
//handle COM_QUERY command, like SELECT, INSERT, UPDATE, etc... | |
//If Result has a Resultset (SELECT, SHOW, etc...), we will send this as the response, otherwise, we will send Result | |
func (Foo) HandleQuery(query string) (*server.Result, error) { | |
panic("not implemented") // TODO: Implement | |
} |
View impl_sort.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Len is the number of elements in the collection. | |
func (Foo) Len() int { | |
panic("not implemented") // TODO: Implement | |
} | |
// Less reports whether the element with | |
// index i should sort before the element with index j. | |
func (Foo) Less(i int, j int) bool { | |
panic("not implemented") // TODO: Implement | |
} |
View impl_hash.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (Foo) Write(p []byte) (n int, err error) { | |
panic("not implemented") // TODO: Implement | |
} | |
// Sum appends the current hash to b and returns the resulting slice. | |
// It does not change the underlying hash state. | |
func (Foo) Sum(b []byte) []byte { | |
panic("not implemented") // TODO: Implement | |
} |
View stock_lambda_function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from datadog import datadog_lambda_wrapper, lambda_metric | |
from botocore.vendored import requests | |
def get_stock_quote(symbol): | |
API_KEY = os.environs['API_KEY'] | |
response = requests.get(f'https://www.alphavantage.co/query?apikey={API_KEY}&function=GLOBAL_QUOTE&symbol={symbol}') | |
return response.json()['Global Quote'] | |
def track_metric(symbol, title, value): |
View get_stock_quote.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from botocore.vendored import requests | |
def get_stock_quote(symbol): | |
API_KEY = os.environ['API_KEY'] | |
response = requests.get(f'https://www.alphavantage.co/query?apikey={API_KEY}&function=GLOBAL_QUOTE&symbol={symbol}') | |
return response.json()['Global Quote'] | |
# get_stock_quote('AAPL') | |
# { |
NewerOlder