Skip to content

Instantly share code, notes, and snippets.

View iamsahebgiri's full-sized avatar

Saheb Giri iamsahebgiri

View GitHub Profile
@iamsahebgiri
iamsahebgiri / api.ts
Last active March 31, 2025 06:43
Rendering Thumbhash in React Native Skia
import sharp from "sharp";
import { rgbaToThumbHash } from "thumbhash";
const image = sharp("image.jpg").resize(100, 100, { fit: "inside" });
const { data, info } = await image
.ensureAlpha()
.raw()
.toBuffer({ resolveWithObject: true });
@iamsahebgiri
iamsahebgiri / bouncing-dvd.html
Created May 25, 2024 06:30
The iconic bouncing DVD logo in javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DVD Screensaver</title>
<style>
* {
margin: 0;
padding: 0;
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"sync"
"time"
)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The World Wide Web project</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
@import url("https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");
:root {
--bg: #f4f5f7;
--paper: #fff;
--text-color: #172b4d;
}
* {
box-sizing: border-box;
@iamsahebgiri
iamsahebgiri / router.js
Created May 13, 2022 12:33
Implementing simple React Router in 45 LOC.
import React, { useState, useEffect } from 'react';
const Router = ({ routes, defaultComponent }) => {
const [currentPath, setCurrentPath] = useState(window.location.pathname);
useEffect(() => {
const onLocationChange = () => {
setCurrentPath(window.location.pathname);
};
@iamsahebgiri
iamsahebgiri / git.sh
Created April 16, 2022 16:29
Git config
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
@iamsahebgiri
iamsahebgiri / temp.cc
Created March 28, 2022 05:58
C++ code template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
@iamsahebgiri
iamsahebgiri / vscode.json
Created March 28, 2022 03:01
VSCode C++ bracket formatting
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}"
@iamsahebgiri
iamsahebgiri / colors.ts
Last active March 21, 2022 14:36
Tailwind colors for Mantine
import { MantineThemeColorsOverride } from '@mantine/core';
export const DEFAULT_COLORS: MantineThemeColorsOverride = {
get dark() { return this.gray; },
gray: [
'#f8fafc',
'#f1f5f9',
'#e2e8f0',
'#cbd5e1',