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 java.util.*; | |
/** | |
* Problem statement: Given a number (that is guaranteed to fit within a 32 bit | |
* two's compliment integer), print the absolute value of that number. | |
* | |
* The catch: A two's compliment signed integer has a larger range for negative | |
* numbers than it does positive. So simply returning Math.abs() on the input | |
* won't always work if the input is Integer.MIN_VALUE (-2147483648). | |
*/ |
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
#!/usr/bin python3 | |
""" | |
A simple script to send a text message over gmail. Text messages are sent as | |
emails. The mail address depends on the carrier, based on the table below: | |
AT&T: number@txt.att.net | |
T-Mobile: number@tmomail.net | |
Verizon: number@vtext.com | |
Sprint: number@messaging.sprintpcs.com or number@pm.sprint.com | |
Virgin Mobile: number@vmobl.com |
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 urllib.request | |
import json | |
base_url = "http://dev.markitondemand.com/Api/v2/Quote/json?symbol=" | |
def get_quote(symbol): | |
html = urllib.request.urlopen(base_url + symbol).read().decode("utf-8") | |
parsed_json = json.loads(html) | |
return parsed_json["Name"] + ": " + str(parsed_json["LastPrice"]) | |
NewerOlder