Skip to content

Instantly share code, notes, and snippets.

Avatar

Krzysztof Kowalczyk kjk

View GitHub Profile
@kjk
kjk / vercel_bug.md
Last active Sep 5, 2021
vercel "api" url bug
View vercel_bug.md

Vercel has a bug that if you put "api" anywhere in the URL, it triggers some internal Vercel 404 error.

I discovered it on my website because I had valid page with "api" in the url and it returned internal Vercel error page instead of rendering 404.html

It happens on any website hosted on Vercel.

Example:

https://realfoodprint.chipotle.com/soil-health.html : this is a page that exists

@kjk
kjk / main.txt
Created Jul 16, 2021
scratchpad.txt (made with https://codeeval.dev)
View main.txt
C:\Users\kjk\AppData\Local\Temp\sumE1DD.tmp -copy-self-to "C:\Users\kjk\src\sumatrapdf\out\dbg64\SumatraPDF.exe"
@kjk
kjk / main.go
Created Jun 22, 2021
pretty print JSON (made with https://codeeval.dev)
View main.go
package main
import (
"fmt"
"encoding/json"
"github.com/tidwall/pretty"
)
var prettyOpts = pretty.Options{
Width: 80,
@kjk
kjk / main.js
Created Dec 28, 2020
pdf.js usage (made with https://codeeval.dev)
View main.js
var pdfjsLib = require('pdfjs-dist/build/pdf');
var PdfjsWorker = require('worker-loader!pdfjs-dist/build/pdf.worker.js');
import {
DefaultAnnotationLayerFactory,
DefaultTextLayerFactory,
PDFLinkService,
PDFPageView
} from 'pdfjs-dist/web/pdf_viewer.js';
View main.cc
#include <iostream> // std::cout
#include <atomic> // std::atomic, std::memory_order_relaxed
#include <thread> // std::thread
std::atomic_int foo (0);
void set_foo(int x) {
foo.store(x); // set value atomically
}
@kjk
kjk / main.cc
Created Jul 21, 2020
Example for sort (made with https://codeeval.dev)
View main.cc
#include <algorithm> // std::sort
#include <iostream>
#include <vector> // std::vector
using namespace std;
int main()
{
vector<int> a{3, 8, 1, 5, -8, 33, 4};
sort( a.begin(), a.end() );
int const n = a.size();
View main.cc
#include <complex>
#include <iostream>
int main()
{
using namespace std::literals::complex_literals;
std::complex<double> c = 2.0 + 1i; // {2.0, 1.}
std::complex<float> cf = 2.0f + 1if; // {2.0f, 1.f}
std::complex<long double> cl = 2.0L + 1il; // {2.0L, 1.L}
View main.cc
#include <codecvt>
#include <iostream>
#include <locale>
#include <string>
int main()
{
using namespace std::literals::string_literals;
std::string s = "hello world"s;
View main.cc
#include <chrono>
#include <iostream>
int main()
{
using namespace std::literals::chrono_literals;
std::chrono::nanoseconds t1 = 600ns;
std::chrono::microseconds t2 = 42us;
std::chrono::milliseconds t3 = 51ms;
View main.cc
#include <iostream>
long double operator"" _km(long double val)
{
return val * 1000.0;
}
long double operator"" _mi(long double val)
{
return val * 1609.344;