Skip to content

Instantly share code, notes, and snippets.

View AngaKoko's full-sized avatar

Anga Koko AngaKoko

View GitHub Profile
@AngaKoko
AngaKoko / signInMethod.kt
Created March 31, 2020 13:33
Method that launches google sign in UI
private fun signIn() {
val signInIntent = googleSignInClient.signInIntent
startActivityForResult(signInIntent, RC_SIGN_IN)
}
@AngaKoko
AngaKoko / SignInFragment.kt
Created March 31, 2020 13:28
Initializing google sign in client
// Configure Google Sign In
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
//Initialize google sign in client
googleSignInClient = GoogleSignIn.getClient(requireActivity(), gso)
@AngaKoko
AngaKoko / fragment_sign_in.xml
Created March 31, 2020 13:26
Sign in button for firebase google sign in
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="277dp"
tools:layout_editor_absoluteX="61dp" />
@AngaKoko
AngaKoko / build.gradle
Created March 31, 2020 13:23
Dependencies to implement for Firebase Google Authentication
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
@AngaKoko
AngaKoko / google_sign_in.kt
Last active June 4, 2020 14:00
Firebase authentication using Googe sign in
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
val task = GoogleSignIn.getSignedInAccountFromIntent(data)
try {
// Google Sign In was successful, authenticate with Firebase
val account = task.getResult(ApiException::class.java)
firebaseAuthWithGoogle(account!!)
@AngaKoko
AngaKoko / tweet_listener.py
Created February 7, 2019 20:34 — forked from hugobowne/tweet_listener.py
Here I define a Tweet listener that creates a file called 'tweets.txt', collects streaming tweets as .jsons and writes them to the file 'tweets.txt'; once 100 tweets have been streamed, the listener closes the file and stops listening.
class MyStreamListener(tweepy.StreamListener):
def __init__(self, api=None):
super(MyStreamListener, self).__init__()
self.num_tweets = 0
self.file = open("tweets.txt", "w")
def on_status(self, status):
tweet = status._json
self.file.write( json.dumps(tweet) + '\n' )
self.num_tweets += 1