Skip to content

Instantly share code, notes, and snippets.

View johndatserakis's full-sized avatar

John Datserakis johndatserakis

View GitHub Profile
@zmts
zmts / s3_aws-sdk_digitalocean.md
Last active August 27, 2020 08:55
Configure AWS SDK with Digital Ocean endpoint; S3

Configure AWS SDK with Digital Ocean endpoint

const AWS = require('aws-sdk')
const spacesEndpoint = new AWS.Endpoint('nyc3.digitaloceanspaces.com');

const s3 = new AWS.S3({
    endpoint: spacesEndpoint,
    accessKeyId: 'ACCESS_KEY',
 secretAccessKey: 'SECRET_KEY'
@andywer
andywer / _readme.md
Last active January 8, 2025 04:42
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 2, 2025 03:01
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@BeFiveINFO
BeFiveINFO / components-Adsense.vue
Last active June 8, 2021 19:27
Adsense for Gridsome
<template>
<ins class="adsbygoogle"
:data-ad-client="adClient"
:data-ad-slot="adSlot"
:data-ad-format="adFormat"
:style="adStyle"></ins>
</template>
<script>
export default {
@robertcoopercode
robertcoopercode / .zshrc
Last active March 31, 2024 01:08
Zsh configuration file
#------------------
# Shell Variables
#------------------
# Specify VS Code as default editor for the React Native Simulator
export REACT_EDITOR=code-insiders
# Set VS Code Insiders as default code editor
export EDITOR=code-insiders
# Android SDK
export ANDROID_HOME=~/Library/Android/sdk
@joshuacerbito
joshuacerbito / useScroll.js
Last active January 8, 2024 13:44
Custom React hook for listening to scroll events
/**
* useScroll React custom hook
* Usage:
* const { scrollX, scrollY, scrollDirection } = useScroll();
*/
import { useState, useEffect } from "react";
export function useScroll() {
const [lastScrollTop, setLastScrollTop] = useState(0);
@rstacruz
rstacruz / README.md
Last active October 17, 2024 15:36
Setting up Babel and TypeScript

Install Babel 7 and TypeScript

yarn add --dev \
  @babel/core \
  @babel/cli \
  @babel/preset-env \
  @babel/preset-typescript \
  typescript
@yuki-yano
yuki-yano / ducks.tsx
Last active January 20, 2021 08:36
typescript-redux-thunk-sample
import axios from "axios"
import { Reducer, Dispatch } from "redux"
import Cookies from "js-cookie"
export type UserState = {
accessToken: string
loggingIn: boolean
error: string
}
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active November 9, 2025 07:22
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@enriquemorenotent
enriquemorenotent / VS Code extensions and settings
Last active August 17, 2023 10:55
My favorite extensions and settings for Visual Studio Code
Extensions
==========
ext install wakatime.vscode-wakatime (time tracking)
ext install esbenp.prettier-vscode (prettifier)
ext install ms-vscode.csharp (C#)
ext install mikestead.dotenv (.env files)
ext install msjsdiag.debugger-for-chrome (chrome's debugger)
ext install deerawan.vscode-faker (faker)
ext install ms-vsliveshare.vsliveshare (shared coding sessions)