Skip to content

Instantly share code, notes, and snippets.

View ernestkamara's full-sized avatar

Saidu Ernest Kamara ernestkamara

View GitHub Profile
@ernestkamara
ernestkamara / AdbCommands
Created June 26, 2018 08:42 — forked from Pulimet/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
Developer setup guid
https://www.stuartellis.name/articles/mac-setup/
# Install Xcode
xcode-select --install
# Install and update Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@ernestkamara
ernestkamara / Salone Hackathon 2019 Entry Questions Solutions
Last active March 9, 2021 17:11
Solution to Salone Hackathon 2019 Entry Questions
###1. FIND THE LONGEST WORD
["hello", "world", "hi", "bye"]
###Solution:
Given that there is only one longest word in the Array or the first longest word is a valid
```kotlin
fun findLongestWord(words: List<String>): String {
var longestWord = ""
words.onEach { word -> if(word.length > longestWord.length) longestWord = word }
return longestWord
@ernestkamara
ernestkamara / account_key.json
Last active April 3, 2020 08:49
Cloud Function Demo Service Account
// ./account_key.json
// https://console.firebase.google.com/u/1/project/project_id/settings/serviceaccounts/adminsdk
// Google recommends using Secret Manager to store API keys, passwords, certificates, and other sensitive data.
{
"type": "service_account",
"project_id": "...",
"private_key_id": "...",
"private_key": "...",
"client_email": "...",
"client_id": "...",
@ernestkamara
ernestkamara / setup.js
Last active March 23, 2020 10:34
Cloud Functions Demo
// Create the serpwow object, passing in our API key
const serpwow = new SerpWow(API_KEY);
// Initialize the default app
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://APP_ID.firebaseio.com"
});
// Minimum time period(i.e. 'from') search parameter
@ernestkamara
ernestkamara / index.js
Last active March 23, 2020 10:19
Cloud Functions Demo Dependencies
// functions/index.js
const admin = require('firebase-admin');
const functions = require('firebase-functions');
// Path to a service account key JSON file
const serviceAccount = require("./account_key.json");
// Lightweight JavaScript date library for parsing, validating,
// manipulating, and formatting dates.
const moment = require('moment');
// Serpwow module
const SerpWow = require('google-search-results-serpwow');
@ernestkamara
ernestkamara / index.js
Last active March 10, 2020 22:57
Cloud Functions Demo
// functions/index.js
const admin = require('firebase-admin');
const functions = require('firebase-functions');
// path to a service account key JSON file
const serviceAccount = require("./account_key.json");
// Lightweight JavaScript date library for parsing, validating,
// manipulating, and formatting dates.
const moment = require('moment');
// Serpwow module
const SerpWow = require('google-search-results-serpwow');
@ernestkamara
ernestkamara / scheduled_function.js
Created March 10, 2020 22:56
Cloud Functions Demo
// The function scheduled to run every 12 hours
exports.scheduledFunction = functions.pubsub.schedule('every 12 hours').onRun(async (context) => {
// retrieve the search results as JSON
await serpwow.json(params)
.then(result => {
// Articles Firestore CollectionReference
const articlesRef = admin.firestore().collection('articles');
// Save search results to Firestore
const articles = result["news_results"]
@ernestkamara
ernestkamara / OnboardingBubbleItem.kt
Last active January 6, 2020 13:00
Onboarding Bubble Item
class OnboardingBubbleItem
@kotlin.jvm.JvmOverloads
constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : FrameLayout(context, attrs, defStyleAttr) {
init { initView(attrs) }
private fun initView(attrs: AttributeSet?) {
View.inflate(context, R.layout.layout_bubble_item, this)
val ta = context.obtainStyledAttributes(attrs, R.styleable.OnboardingBubbleItem)
@ernestkamara
ernestkamara / OnboardingFragment.kt
Last active January 4, 2020 14:41
The Onboarding Fragment
class OnboardingFragment : DialogFragment() {
private val indicators = mutableListOf<View>()
private var currentPosition = 0
private fun attachNextButtonListener() {
next.setOnClickListener {
when (currentPosition) {
0 -> next.navigate(R.id.firstTransition, R.id.secondTransition)
1 -> next.navigate(R.id.secondTransition, R.id.thirdTransition)
else -> dismiss()