Skip to content

Instantly share code, notes, and snippets.

View morajabi's full-sized avatar

Mo morajabi

View GitHub Profile
@morajabi
morajabi / FPSCounter.swift
Created December 29, 2024 19:16
An FPS Counter for macOS apps built for inline.chat
import AppKit
import Charts
import CoreVideo
import SwiftUI
struct FPSMeasurement: Identifiable, Equatable {
let id: Int
let fps: Int
static func == (lhs: FPSMeasurement, rhs: FPSMeasurement) -> Bool {
@morajabi
morajabi / bun-lint-test-typecheck.yml
Created December 7, 2024 08:26
Bun test, lint, and typecheck your Bun project in GitHub actions with caching
# .github/workflows/test.yml
on:
push:
branches:
- main
pull_request:
branches:
- main
@morajabi
morajabi / FormState.swift
Last active October 16, 2024 12:28
Form state management in Swift UI
import SwiftUI
struct FormStateData {
var loading: Bool
var error: String?
var succeeded: Bool?
}
// A helper for easier state management for simple forms
class FormState: ObservableObject {
@morajabi
morajabi / useHover.js
Created August 9, 2021 09:17
Use Hover for react native web
import { useMemo } from 'react'
import { useState } from 'react'
export function useHover() {
const [hovered, setHovered] = useState(false)
let callbacks = useMemo(
() => ({
onMouseEnter: () => {
setHovered(true)
},

Keybase proof

I hereby claim:

  • I am morajabi on github.
  • I am morajabi (https://keybase.io/morajabi) on keybase.
  • I have a public key ASCPpYSKHC9c0nSXk3DPQS6uJsTJHJk5hE49pS0wJ2FPcAo

To claim this, I am signing this object:

{
"version": 2,
"alias": ["there.team"],
"builds": [
{ "src": "web/package.json", "use": "@now/next" },
{
"src": "api/lambda.js",
"use": "@now/node",
"config": {
"includeFiles": [
@morajabi
morajabi / chrome_tabs.osa
Created May 9, 2019 05:25 — forked from samyk/chrome_tabs.osa
applescript to show all url+titles of Chrome tabs along with front window+tab url+title
# shows all url+titles of Chrome along with front window+tab url+title
set titleString to ""
tell application "Google Chrome"
set window_list to every window # get the windows
repeat with the_window in window_list # for every window
set tab_list to every tab in the_window # get the tabs
repeat with the_tab in tab_list # for every tab
@morajabi
morajabi / useRect.js
Created February 18, 2019 14:35
useRect — getBoundingClientRect() React Hook with resize handler
import { useLayoutEffect, useCallback, useState } from 'react'
export const useRect = (ref) => {
const [rect, setRect] = useState(getRect(ref ? ref.current : null))
const handleResize = useCallback(() => {
if (!ref.current) {
return
}
import styled, { css } from 'styled-components'
import { mobile } from '../style/media'
type Props = {
width?: number
height?: number
widthOnMobile?: number
heightOnMobile?: number
fillRow?: boolean
fillColumn?: boolean
@morajabi
morajabi / Link.tsx
Created October 28, 2018 12:46
Smart Gatsby Link