Skip to content

Instantly share code, notes, and snippets.

@gaearon
gaearon / 00-README-NEXT-SPA.md
Last active October 14, 2024 00:05
Next.js SPA example with dynamic client-only routing and static hosting

Next.js client-only SPA example

Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.

You use Next.js router like normally, but don't define getStaticProps and such. Instead you do client-only fetching with swr, react-query, or similar methods.

You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)

Don't like Next? Here's how to do the same in Gatsby.

@commonsensesoftware
commonsensesoftware / Cargo.toml
Last active October 30, 2023 22:38
JSON Streaming in Rust
[package]
name = "json-streaming"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "streamjson"
path = "main.rs"
[dependencies]
@tomfa
tomfa / client.ts
Last active April 7, 2023 22:15
graphql-request with automatic parsing of DateTime
import { GraphQLClient } from 'graphql-request';
import { gqlSerializer } from './serializer.ts'
const gqlClient = new GraphQLClient(url, {
credentials: 'include',
mode: 'cors',
jsonSerializer: gqlSerializer,
});
@YashasSamaga
YashasSamaga / A0_NOTICE.md
Last active September 22, 2024 12:22
GSoC 2019 | OpenCV | Adding a CUDA backend to the DNN module

DISCLAIMER

This gist documents the Google Summer of Code project. It is not updated and hence does not indicate current status of the CUDA backend.

For updated details, please see this gist.

@EricWF
EricWF / constinit.md
Last active July 16, 2020 09:07
A Proposal to add [[constinit]] to C++
Document Number: P1143r3
Date: 2019-06-18
Project: Programming Language C++, Evolution
Revises: P1143r2
Reply to: eric@efcs.ca

Adding the constinit keyword

@ectrimble20
ectrimble20 / example.html
Created May 12, 2018 23:56
Multiple Checkboxes using Flask WTForms
{% extends "layout_new.html" %}
{% block content_main %}
<div class="content-section">
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<legend class="border-bottom mb-4">User Choices</legend>
{% if form.choices.errors %}
<div class="invalid-feedback">
{% for error in form.choices.errors %}
@sofaking
sofaking / reset_submodules.sh
Created November 23, 2017 16:22
Reset a git repository with submodules to initial state
git submodule foreach --recursive git reset --hard
git reset --hard
git submodule update --init
git submodule foreach --recursive git submodule update --init
@f0k
f0k / cuda_check.py
Last active September 18, 2024 08:59
Simple python script to obtain CUDA device information
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Outputs some information on CUDA-enabled devices on your computer,
including current memory usage.
It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1
from C to Python with ctypes, so it can run without compiling anything. Note
that this is a direct translation with no attempt to make the code Pythonic.
@absent1706
absent1706 / sqlalchemy-truncate_db.py
Last active April 5, 2023 03:50
Sqlalchemy: Truncate all tables
def truncate_db(engine):
# delete all table data (but keep tables)
# we do cleanup before test 'cause if previous test errored,
# DB can contain dust
meta = MetaData(bind=engine, reflect=True)
con = engine.connect()
trans = con.begin()
con.execute('SET FOREIGN_KEY_CHECKS = 0;')
for table in meta.sorted_tables:
con.execute(table.delete())
@Fr6jDJF
Fr6jDJF / ddc-ci.py
Created May 23, 2016 10:02 — forked from vdcrim/ddc-ci.py
Python script for adjusting the settings of my monitor, by using DDC/CI
#!/usr/bin/env python3
"""
Show and adjust display parameters on an Iiyama ProLite XB2483HSU-B1 monitor
Requirements:
- mentioned monitor (27' should also work) with DDC/CI setting on
- Windows Vista+
- Python 3