Skip to content

Instantly share code, notes, and snippets.

View trangcongthanh's full-sized avatar
👀
Bug Breeder

Thành Trang trangcongthanh

👀
Bug Breeder
View GitHub Profile
@glzawalski
glzawalski / ContentView.swift
Last active December 5, 2023 12:19
Basic ContentView loading data with async/await
//
// ContentView.swift
// FetchAsync
//
// Created by Gabriel Zawalski on 09/11/23.
//
import SwiftUI
struct ContentView: View {
@longseespace
longseespace / send-critical-update-email.js
Created September 22, 2022 05:28
Send bulk email to users using MailerSend
const Recipient = require('mailersend').Recipient;
const EmailParams = require('mailersend').EmailParams;
const BulkEmails = require('mailersend').BulkEmails;
const MailerSend = require('mailersend');
const users = require('./users');
const MAILERSEND_API_KEY = process.env.MAILERSEND_API_KEY;
if (!MAILERSEND_API_KEY) {
console.error('MAILERSEND_API_KEY is required');
@s-cork
s-cork / codemirror.tsx
Last active September 15, 2021 07:11
Codemirror 6 with react
import React, { useEffect, useMemo, useCallback, useLayoutEffect, useState } from "react";
import { EditorView } from "@codemirror/view";
import { EditorState, Compartment, EditorStateConfig, StateEffect, Extension } from "@codemirror/state";
import { indentUnit } from "@codemirror/language";
/** creates an editor view from an initial state - destroys the view on cleanup */
export function useEditorView(initState: (() => EditorStateConfig) | EditorStateConfig = {}): EditorView {
const view = useMemo(
() => new EditorView({ state: EditorState.create(typeof initState === "function" ? initState() : initState) }),
[]
@tannerlinsley
tannerlinsley / createCrudHooks.js
Created November 29, 2020 06:39
A naive, but efficient starter to generate crud hooks for React Query
export default function createCrudHooks({
baseKey,
indexFn,
singleFn,
createFn,
updateFn,
deleteFn,
}) {
const useIndex = (config) => useQuery([baseKey], indexFn, config)
const useSingle = (id, config) =>
@bergmannjg
bergmannjg / rearct-native-app-in-wsl2.md
Last active April 27, 2024 07:21
Building a react native app in WSL2
@titoaesj
titoaesj / .kt
Last active March 17, 2024 22:22
Android convert int to dp
OBS: O var_number_int é a varável que recebera o valor a ser convertido em DP
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, var_number_int, getResources().getDisplayMetrics())
##KOTLIN
val Int.dp: Int
get() = (this * Resources.getSystem().displayMetrics.density + 0.5f).toInt()
val Float.dp: Int
@Daniel-Hug
Daniel-Hug / collision-detection.js
Last active March 3, 2024 04:02
JS functions: check if 2 rectangles intersect, are touching, or if one contains the other
// Check if rectangle a contains rectangle b
// Each object (a and b) should have 2 properties to represent the
// top-left corner (x1, y1) and 2 for the bottom-right corner (x2, y2).
function contains(a, b) {
return !(
b.x1 < a.x1 ||
b.y1 < a.y1 ||
b.x2 > a.x2 ||
b.y2 > a.y2
);
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 28, 2024 12:29
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname