Skip to content

Instantly share code, notes, and snippets.

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

Ismail Ghallou smakosh

👨‍💻
Building https://ontwik-dev.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 / README.md
Created September 3, 2022 01:42
SEO Next js

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

@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 / 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;
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 / vanilla_percepton_js.js
Created March 14, 2018 07:31
Perceptron from scratch with vanilla Js
// Sigmoid
const sigmoid = x => 1 / (1 + Math.exp(-x))
const D_sigmoid = x => sigmoid(x) * (1-sigmoid(x))
// data
const data = [
[ 5.1, 3.5, 0 ],
[ 4.9, 3. , 0 ],
[ 4.7, 3.2, 0 ],
@smakosh
smakosh / countries.json
Created April 12, 2019 09:54
List of countries in arabic
[
{
"label": "آروبا",
"value": "آروبا"
},
{
"label": "أسبانيا",
"value": "أسبانيا"
},
{
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
? {