Skip to content

Instantly share code, notes, and snippets.

Avatar

Johan Eliasson elitan

View GitHub Profile
@defrex
defrex / AuthClient.ts
Last active Jun 27, 2020
Nhost Auth & Apollo integrated with Next.js
View AuthClient.ts
import fetch from 'cross-fetch'
import jwtDecode from 'jwt-decode'
import moment from 'moment'
import { NextPageContext } from 'next'
import { destroyCookie, parseCookies, setCookie } from 'nookies'
export class AuthClient {
baseUrl = 'https://backend-[whatev].nhost.app'
stateChangeCallbacks: (() => void)[] = []
context?: NextPageContext
@stopsatgreen
stopsatgreen / php-get-json.php
Last active May 31, 2019
PHP: get JSON, with headers
View php-get-json.php
<?php
// Because I don’t use PHP often enough to remember it instantly
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept: application/json"
)
);
$context = stream_context_create($opts);
@swinton
swinton / AESCipher.py
Last active Mar 3, 2020
Encrypt & Decrypt using PyCrypto AES 256 From http://stackoverflow.com/a/12525165/119849
View AESCipher.py
#!/usr/bin/env python
import base64
from Crypto import Random
from Crypto.Cipher import AES
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
You can’t perform that action at this time.