Skip to content

Instantly share code, notes, and snippets.

View elitan's full-sized avatar

Johan Eliasson elitan

View GitHub Profile
@boxabirds
boxabirds / .cursorrules
Last active June 27, 2025 16:13
Rock solid: turn Cursor into a rock-solid software engineering companion
# Project Policy
This policy provides a single, authoritative, and machine-readable source of truth for AI coding agents and humans, ensuring that all work is governed by clear, unambiguous rules and workflows. It aims to eliminate ambiguity, reduce supervision needs, and facilitate automation while maintaining accountability and compliance with best practices.
# 1. Introduction
> Rationale: Sets the context, actors, and compliance requirements for the policy, ensuring all participants understand their roles and responsibilities.
## 1.1 Actors
@ConProgramming
ConProgramming / pageql.config.js
Created November 13, 2020 00:28
Nhost Svelte Stuffs (file names with - are for / of subdirectory)
import { auth } from "./src/js/nhost.js";
import { initClient, getClient } from "./src/js/graphqlClient.js";
export default {
auth: {
checkRole: (requiredRole) => {
//Used by pageql:authRole directive
//Return false if user's role fails to hit specifications
//Returning false hides the component
@defrex
defrex / AuthClient.ts
Last active June 27, 2020 22:39
Nhost Auth & Apollo integrated with Next.js
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 17:55
PHP: get JSON, with headers
<?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 November 8, 2024 18:31
Encrypt & Decrypt using PyCrypto AES 256 From http://stackoverflow.com/a/12525165/119849
#!/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])]