Skip to content

Instantly share code, notes, and snippets.

View micaiah-effiong's full-sized avatar
👨‍💻
Focusing

Micah Effiong micaiah-effiong

👨‍💻
Focusing
View GitHub Profile
@micaiah-effiong
micaiah-effiong / addToBuildGradle.ts
Created November 8, 2024 21:30
A function for expo-plugin that adds new lines to build gradle. Can be used to add lines to other files
const addToBuildGradle = (
newLine: string,
anchor: RegExp | string,
offset: number,
buildGradle: string,
) => {
const lines = buildGradle.split('\n');
const lineIndex = lines.findIndex((line) => line.match(anchor));
// add after given line
lines.splice(lineIndex + offset, 0, newLine);
import { jwtDecode } from "jwt-decode";
import * as api from "./generated";
import { ApiRequestOptions } from "./generated/core/ApiRequestOptions";
import { toast } from "react-toastify";
import { storageKey } from "@/utils/keys";
api.OpenAPI.BASE = import.meta.env.VITE_APP_BASE_API;
export const apiConfig = api;
@micaiah-effiong
micaiah-effiong / list-view.md
Created August 13, 2024 13:48
Get the selected element/list-item from gtk4 listview
@micaiah-effiong
micaiah-effiong / array-range.ts
Last active February 23, 2024 01:35
get a fixed range of data from an array. if bounds overflow it shift in the other direction.
function edgeAwareSlice<T>(arr: Array<T>, start: number, win: number) {
if(win > arr.length) { return arr }
const half = Math.floor(win/2)
let front = start - half
let back = start + half;
if (back >= arr.length){
// console.log('gap', {front, back, diff: (back+win%2) - arr.length}, arr.length)
type LatLng = [number, number];
function decodePolyline(encoded: string): Array<LatLng> {
const poly: Array<LatLng> = [];
let index = 0;
const len = encoded.length;
let lat = 0,
lng = 0;
@micaiah-effiong
micaiah-effiong / .zshrc
Last active September 19, 2023 13:08
my zsh config(mac)
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
@micaiah-effiong
micaiah-effiong / storage.service.ts
Created August 14, 2023 23:56
google cloud storage service for Nestjs
import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { Storage, Bucket, File } from '@google-cloud/storage';
import StorageKeyFile from 'src/config/storage-service-account.json';
import { ConfigService } from '@nestjs/config';
import { ENV } from 'src/config';
import { BucketDirectories } from './constants';
@Injectable()
export class StorageService {
private gcStorage = new Storage({
import {
CallHandler,
ExecutionContext,
Injectable,
NestInterceptor,
} from '@nestjs/common';
import { Response } from 'express';
import { map, Observable } from 'rxjs';
@Injectable()
@micaiah-effiong
micaiah-effiong / firebase-function-deploy.md
Created April 5, 2023 14:14
APIs and roles needed for deploying firebase functions using service account

APIs and roles needed for deploying firebase functions using service account

Date: 5th April, 2023.

Time: 3:00pm WAT.

Report:

Succesfully deployed a firebase function, using a service account.
This was me trying not to use the ci token as it was flagged unsafe.

This gist contains the roles needed for your service account to deploy properly

const wmi = [
{
"code": "AAA",
"name": "Audi South Africa made by Volkswagen of South Africa"
},
{
"code": "AAK",
"name": "FAW Vehicle Manufacturers SA (PTY) Ltd."
},
{