This file contains hidden or 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
// get realtime database pointer | |
let ref = Database.database().reference() | |
// get currently authenticated user | |
guard let currentUser = Auth.auth().currentUser else { | |
return | |
} | |
// store any data at a given path | |
ref.child("users/\(currentUser.uid)/twitter/token").setValue(authToken) |
This file contains hidden or 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 updateLocation(_ location: CLLocation) { | |
if let uid = Auth.auth().currentUser?.uid { | |
let latitude = location.coordinate.latitude + (Double(arc4random()) / Double(UINT32_MAX) / 10 - 0.05) | |
let longitude = location.coordinate.longitude + (Double(arc4random()) / Double(UINT32_MAX) / 10 - 0.05) | |
self.ref.child("users/\(uid)/location").setValue(["lat": latitude, "lon": longitude]) | |
} | |
} |
This file contains hidden or 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
function getCountry(addrComponents) { | |
var address = {}; | |
for (var i = 0; i < addrComponents.length; i++) { | |
if (addrComponents[i].types[0] == "country") { | |
address["country_short"] = addrComponents[i].short_name; | |
address["country"] = addrComponents[i].long_name; | |
} | |
if (addrComponents[i].types[0] == "locality") { | |
address["city"] = addrComponents[i].long_name; | |
} |
This file contains hidden or 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
{ | |
"users" : { | |
"HvzLGDoF2yZKOFywjuWVGEafEhs1" : { | |
"location" : { | |
"lat" : 37.37016786494953, | |
"lon" : -122.06975715302978 | |
}, | |
"public" : { | |
"city" : "Los Altos", | |
"country" : "United States", |
This file contains hidden or 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
{ | |
"rules": { | |
"users": { | |
"$uid": { | |
"location": { | |
".write": "$uid === auth.uid", | |
".read": "$uid === auth.uid" | |
}, | |
"twitter": { | |
".write": "$uid === auth.uid", |
This file contains hidden or 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
curl "http://api.mytravatar.com/[email protected]" | |
{ | |
"city": "San Carlos", | |
"country": "United States", | |
"country_emoji": "🇺🇸", | |
"country_short": "US" | |
} |
This file contains hidden or 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
@app.route('/users/<string:user_id>') | |
def users(user_id): | |
profile = firebase.get('/users/{}'.format(user_id), "public") | |
return jsonify(profile) | |
@app.route('/users') | |
def users_by_email(): | |
# TODO: single network call | |
email = request.args.get("email") |
This file contains hidden or 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
node -e "console.log(require('crypto').randomBytes(32).toString('hex'));" |
This file contains hidden or 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 Siesta | |
let baseURL = "https://jwt-api-siesta.herokuapp.com" | |
let AwesomeAPI = _AwesomeAPI() | |
class _AwesomeAPI { | |
// MARK: - Configuration | |
This file contains hidden or 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 Siesta | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
AwesomeAPI.ping().addObserver(self) | |
} | |
override func viewWillAppear(_ animated: Bool) { |