Skip to content

Instantly share code, notes, and snippets.

View smakosh's full-sized avatar
👨‍💻
Building https://starlink-prices.com

Ismail Ghallou smakosh

👨‍💻
Building https://starlink-prices.com
View GitHub Profile
@smakosh
smakosh / constants.ts
Created March 16, 2024 22:06
Next.js Offset/limit pagination
export const LIMIT = 10;
export const RANGE = 5;
@smakosh
smakosh / _app.tsx
Last active September 19, 2022 13:06
Adding Google Analytics to your Next js app
import Error from "next/error";
import Script from "next/script";
import * as gtag from "utils/ga";
import { useEffect } from "react";
import { AppProps } from "next/app";
import { useRouter } from "next/router";
const App = ({ Component, pageProps, err }: AppProps & { err: Error }) => {
const router = useRouter();
@smakosh
smakosh / README.md
Created September 3, 2022 01:42
SEO Next js

Easily implement good SEO in your Next js app using next-seo

did:3:kjzl6cwe1jw14adt85e30363whpdxq48lwt1lax9meleqpl8lr64wh3zmnjnhez
@smakosh
smakosh / SEO.tsx
Created December 10, 2021 22:41
Next SEO component
import { NextSeo } from 'next-seo';
export interface SeoProps {
url?: string;
title?: string;
description?: string;
cover?: string | null;
}
const SEO = ({ url, title, description, cover }: SeoProps) => {
@smakosh
smakosh / useSwitchNetwork.ts
Created December 10, 2021 22:26
A cool Switch network React hook
import { useMemo } from 'react';
const useswitchNetwork = async (
account: string | null | undefined,
nextChainId: 1 | 10 | 42 | 69,
currentChainId: number | undefined,
forceOptimism = false,
) => {
if (!account) {
return;
const hexToRgb = hex => {
// http://stackoverflow.com/a/5624139
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i
hex = hex.replace(shorthandRegex, (m, r, g, b) => {
return r + r + g + g + b + b
})
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
return result
? {
@smakosh
smakosh / README.md
Created June 11, 2020 11:55
Change package name on a React Native app
  1. Changed project' subfolder name from: "android/app/src/main/java/<com.old_id>/" to: "android/app/src/main/java/com.new_id/"
  2. In android/app/src/main/java/MY/APP/com.new_id/MainActivity.java:, change:
package com.new_id;
  1. In android/app/src/main/AndroidManifest.xml, change:
package="com.new_id"
  1. In android/app/build.gradle, change:
@smakosh
smakosh / hexToRgba.js
Created December 5, 2019 19:47
Hex to RGBA - SC
const hexToRgb = hex => {
// http://stackoverflow.com/a/5624139
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i
hex = hex.replace(shorthandRegex, (m, r, g, b) => {
return r + r + g + g + b + b
})
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
return result
? {