Skip to content

Instantly share code, notes, and snippets.

View jgoux's full-sized avatar
I'm the fastest meme alive

Julien Goux jgoux

I'm the fastest meme alive
View GitHub Profile
@Tom-Bonnike
Tom-Bonnike / tiny-serialize.js
Last active November 24, 2020 21:56
Tiny form serialization helper
function serializeForm(form, urlEncode = false) {
const formData = new FormData(form);
if (urlEncode) {
const searchParams = new URLSearchParams(formData)
return searchParams.toString();
}
const serializedFormData = {};
@jaredly
jaredly / App.re
Last active January 1, 2021 17:34
ReasonReact Context API Example
module StringContext =
Context.MakePair({
type t = string;
let defaultValue = "Awesome";
});
let component = ReasonReact.statelessComponent("Tree");
let make = _children => {
@gregoryyoung
gregoryyoung / gist:a3e69ed58ae066b91f1b
Created June 24, 2015 13:25
Event Sourcing as 3 functions.
f(events) -> state
match f(state, event) -> state
f(state, command) -> events
import { multiSortBy } from 'src/shared/utils'
export type PathNode<T> = {
id: string
path: string
parentId: string
meta: T
children?: PathNode<T>[]
}
// NOTE: you will NOT write code like this when using suspense
// instead, you'll use react-cache (not yet officially published)
// it'll handle things like pre-loading, handling rapid re-renders, etc.
const cache = {}
function FetchPokemon({pokemonName}) {
const pokemon = cache[pokemonName]
if (!pokemon) {
const promise = fetchPokemon(pokemonName).then(
@dwhitney
dwhitney / README.md
Last active March 5, 2022 12:54
Quick React Native with PureScript
  1. create-react-native-app purescript-app; cd purescript-app

  2. pulp init --force

  3. pulp build

  4. src/Main.js

var React = require("react");
var RN = require("react-native");

exports.text = function(props){
@justinwoo
justinwoo / Counter.js
Last active September 29, 2022 08:29
React 0.14 function components and a fake Elm Architecture written with RxJS subjects (instead of Signal.mailbox). Inspired by Dan's tweet: https://twitter.com/dan_abramov/status/648517117176745984 ((i guess this is pretty ugly so please don't take it super seriously))
import React from 'react';
/**
* Counter.js
*
* exposes:
* init
* update
* view
*/
@kshailen
kshailen / Connecting_postgress_RDS_from_local_via_bastion.md
Last active October 12, 2022 13:26
Ways to connect to postgress RDS instance from bastion host and from local host

When it comes to databases and AWS VPC, best practice is to place your database in private subnet. By definition, private subnet in AWS is not reachable from the Internet because no Internet gateway is attached to private subnet. This is the way you protect your data. This kind of configuration is good for security but bad for data management.

How can you easily access and manage your secured data?

basic_RDS_bastion_architecture

There are two basic ways to acees it.

  1. Access postgres RDS from bastion host. There are following requirements for this.
@AndrewIngram
AndrewIngram / PostDetail.jsx
Last active October 23, 2022 01:56
Updated Next.js with Relay (still using getInitialProps)
import React from "react";
import { graphql } from "react-relay";
import createPageContainer from "../relay/createPageContainer";
import PostLayout from "../components/PostLayout";
import Header from "../components/Header";
import Shell from "../layouts/Shell";
@Fristi
Fristi / Aggregate.hs
Last active November 6, 2022 20:50
DDD/Event Sourcing in Haskell. Implemented an aggregate as a type class and type families to couple event, command and error types specific to the aggregate. Errors are returned by using Either (Error e) (Event e). Applying Applicative Functors fits here well to sequentially check if the command suffice.
{-# LANGUAGE TypeFamilies #-}
import Data.Function (on)
import Control.Applicative
data EventData e = EventData {
eventId :: Int,
body :: Event e
}