Skip to content

Instantly share code, notes, and snippets.

View matthieuh's full-sized avatar
🏠
Working from home

Matthieu Hostache matthieuh

🏠
Working from home
View GitHub Profile
@slorber
slorber / react-navigation-tree.jsx
Last active August 13, 2022 19:17
react-navigation-tree.jsx
const App = createAppContainer(
createStack({
LoggedSwitch: createSwitch({
// When user is authenticated
LoggedIn: createStack({
// The logged in root is generally a tab or drawer navigator
LoggedInRoot: createTabsOrDrawer({
@darknoon
darknoon / sign_s3_url.sql
Last active March 30, 2022 16:37
A function that lets you sign S3 urls for viewing from within your database queries
-- This function is based on this description:
-- https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
CREATE OR REPLACE FUNCTION
sign_s3_url(
m_host text,
m_verb text,
m_resource text,
m_region text,
m_key text,
@HaNdTriX
HaNdTriX / UseRouterExample.next.js
Last active June 10, 2020 02:20
Next.js useRouter
// 🤫The following code is experimental and might break in the future!
// Don't use it if you are using some kind of side-effect patterns like: Helmet, GraphQL or react-side-effect.
import { useRouter } from 'next/router'
function Home() {
const {
// `String` of the actual path (including the query) shows in the browser
asPath,
// `String` Current route
@clodal
clodal / zeit-now-aws-ses.md
Last active April 17, 2020 09:30
Describes how to verify a Zeit Now domain with AWS SES for email sending

How to setup AWS SES with Zeit Now

  1. Domain Verification Record
now dns add <NAKED_DOMAIN> _amazonses TXT <VALUE>
  1. DKIM Record Set
now dns add  ._domainkey CNAME 
@rhostem
rhostem / _document.js
Last active January 2, 2022 07:40
[react, next.js] tags in head for SEO
import Head from 'next/head'
import SEO from '../constants/seo'
export default ({
title = SEO.title,
description = SEO.description,
pageUrl = SEO.siteUrl,
mainImage = SEO.mainImage,
iosApplink = SEO.quizBuzzHomeUrl,
androidAppLink = SEO.quizBuzzHomeUrl,
@bramus
bramus / fix.md
Last active May 20, 2018 19:47
Fixing the XCode 9.x Simulator 3D/Map Performance issue

Got a slow/unresponsive Simulator with XCode 9.x?

You're most likely using some kind of 3D or Native Maps in your App then, no? Awaiting XCode 9.1 (which contains a fix) here's a workaround which replaces the bundled OpenGLES.framework with the version from XCode 9.0 beta 3.

Please do note …

⚠️ Installing frameworks/binaries from unfamiliar/untrusted resources always involves some risk. I can only say that I’ve been using the linked version without any issues. Your mileage may vary.

Instructions

@vlucas
vlucas / encryption.js
Last active July 23, 2024 01:24
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@joyrexus
joyrexus / README.md
Last active June 19, 2024 09:35 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
function map (arr, func) {
return Promise.resolve().then(function () {
return arr.map(function (el) { return func(el) })
}).all()
}
function mapSeries (arr, func) {
let currentPromise = Promise.resolve()
let promises = arr.map(function (el) {
return currentPromise = currentPromise.then(function () {
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active July 21, 2024 01:20
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh