Skip to content

Instantly share code, notes, and snippets.

@andrew-levy
andrew-levy / JetpackComposeView.kt
Last active April 11, 2024 05:03
JetpackComposeViewModule
package expo.modules.jetpackcomposeview
import android.content.Context
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.*
import ExpoModulesCore
import SwiftUI
public class SwiftuiViewModule: Module {
public func definition() -> ModuleDefinition {
Name("SwiftuiForm")
View(SwiftuiView.self) {
Prop("name") { (view, name: String) in
view.name = name
}
@iam-mhaseeb
iam-mhaseeb / slackmojis_downloader.py
Created January 31, 2022 09:40
Slackmojis.com Downloader
import os
import sys
import requests
from bs4 import BeautifulSoup
def show_arg():
req = requests.get(sys.argv[1])
@meotimdihia
meotimdihia / How to fix the bug: "Warning: Expected server HTML to contain a matching <div> in <div>." in Next.js.md
Last active December 21, 2022 10:01
How to fix the bug: "Warning: Expected server HTML to contain a matching <div> in <div>." in Next.js

1 Easy but re-render

most simple way, but it will re-render. It may be related to the scrolling restoration bug when the user return the page if your data is fetched on the client

import {useState, useEffect} from 'react'

export default function Index() {
  const [mounted, setMounted] = useState(false);
  useEffect(() => {
      setMounted(true)
@sindresorhus
sindresorhus / esm-package.md
Last active May 8, 2024 22:50
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@bergmannjg
bergmannjg / rearct-native-app-in-wsl2.md
Last active May 8, 2024 17:43
Building a react native app in WSL2
@bradtraversy
bradtraversy / vscode_shortcuts.md
Last active May 6, 2024 12:38
Helpful shortcuts for VSCode

VSCode Shortcuts

List of helpful shortcuts for faster coding

If you have any other helpful shortcuts, feel free to add in the comments of this gist :)

Official List of all commands

You don't need CORS Middleware 2019

A node example using Zeit's Micro.

const micro = require('micro')

const server = micro(async (request, response) => {
 // set response headers

WebApp Rendering Strategies 2019

Client Side Rendering

Tooling: Hyperapp, Mithril, React, Vue

Pros

  • Dynamic Routing. There's no refresh when routing between pages.

Cons

  • JavaScript must be downloaded before the page can begin to render, slowing down first paint performance.[1]