Skip to content

Instantly share code, notes, and snippets.

View iampato's full-sized avatar
🖐️
Hey

Patrick waweru iampato

🖐️
Hey
View GitHub Profile
@iampato
iampato / bash.sh
Created September 4, 2023 17:13
Alternative of installing protoc on Mac (brew failed)
PROTOC_ZIP=protoc-3.14.0-osx-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
@iampato
iampato / main.ts
Last active August 18, 2023 12:25
const axios = require("axios");
const express = require("express");
const GRAPHQL_URL = "https://sports-fed-api.stage.nonprod.wmsports.io/graphql";
// querySportsFedApi
// paramaters is an objects that contains: url, token, query
// returns the response from the query or undefined if unsuccessful
const querySportsFedApiReferenceStream = async (opts) => {
// parameters
@iampato
iampato / main.go
Created May 5, 2023 16:15
To watch and observe a Google Sheet in GoLang, you can use the Google Sheets API to access the sheet and the time package to set up a timer to check for changes periodically. Here's an example code snippet that demonstrates this:
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/api/sheets/v4"
"google.golang.org/api/option"
@iampato
iampato / bash.sh
Created March 21, 2023 09:37
Rename all .js files to .tsx in a next application
find ./src/pages ./src/modules -type f -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.tsx"' {} \;
@iampato
iampato / main.dart
Last active March 14, 2023 16:24
/* *Print out all palindrome and prime numbers between 1 and 100. Use any language you want. 1. Palindrome definition: a word, phrase, or sequence that reads the same backwards as forwards 2. Prime number definition: a whole number greater than 1 that cannot be exactly divided by any whole number other than itself and 1 (e.g. 2, 3, 5, 7, 11). */
/*
*Print out all palindrome and prime numbers between 1 and 100. Use any language you want.
1. Palindrome definition: a word, phrase, or sequence that reads the same backwards as forwards
2. Prime number definition: a whole number greater than 1 that cannot be exactly divided by any whole number other than itself and 1 (e.g. 2, 3, 5, 7, 11).
*/
void main() {
// create numbers list from 1 to 100
List<int> numbers = List.generate(100, (int index) => index + 1);
// print(numbers);
@iampato
iampato / main.tsx
Created March 10, 2023 12:15
Detect the app state in react native
import { useEffect, useRef } from 'react';
import { AppState } from 'react-native';
const getAppCurrentState = () => {
const appState = useRef(AppState.currentState);
useEffect(() => {
const subscription = AppState.addEventListener('change', nextAppState => {
@iampato
iampato / main.ts
Created March 5, 2023 09:43
Download react native images
import RNFS from 'react-native-fs';
import Share from 'react-native-share';
import Progress from 'react-native-progress';
const downloadAndShareImage = async (imageUrl, imageName) => {
const downloadDest = `${RNFS.DocumentDirectoryPath}/${imageName}.jpg`;
// Download the image file
const options = {
fromUrl: imageUrl,
@iampato
iampato / main.dart
Created February 26, 2023 20:53
convert digitis into words
library digits_to_words;
class DigitsToWords {
static const List<String> _units = [
"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"
];
static const List<String> _tens = [
"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"
];
@iampato
iampato / main.dart
Created February 22, 2023 20:01
Limited box constraints
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@iampato
iampato / readme.md
Last active February 20, 2023 12:27
check for internet speed

wss://ndt-mlab1-tnr01.mlab-oti.measurement-lab.org/ndt/v7/download?access_token=eyJhbGciOiJFZERTQSIsImtpZCI6ImxvY2F0ZV8yMDIwMDQwOSJ9.eyJhdWQiOlsibWxhYjEtdG5yMDEubWxhYi1vdGkubWVhc3VyZW1lbnQtbGFiLm9yZyJdLCJleHAiOjE2NzY4OTYwNDksImlzcyI6ImxvY2F0ZSIsImp0aSI6ImU5ZjFjNDA4LWY5MjItNDJhMy1hODc2LWIyYjhlMmJmZGNkNyIsInN1YiI6Im5kdCJ9.uCWoNNXvomclwRRzd8LTPsIZ4PdxoC7n1eOcL54bte0z7Jr1C5Nw7ktxw5TZlTpkoa_mNDUpNYbC11MbdtrfAA&client_name=ist&locate_version=v2