Skip to content

Instantly share code, notes, and snippets.

View robinpokorny's full-sized avatar

Robin Pokorny robinpokorny

View GitHub Profile
@robinpokorny
robinpokorny / uuid4to7.js
Created April 26, 2023 10:40
Convert UUID v4 to v7 in JavaScript (or generate one)
const uuid4to7 = (uuid, now = Date.now()) => {
const ts = now.toString(16).padStart(12, `0`)
return `${ts.slice(0, 8)}-${ts.slice(8)}-7${uuid.slice(15)}`
}
// generate new UUIDv7
uuid4to7(crypto.randomUUID())
// Conforms to example in the spec RFC4122bis C.6
@robinpokorny
robinpokorny / railway_oriented_typescript.ts
Created November 3, 2022 08:47
Heapcon 2022: Railway Oriented Typescript
/*
=============================
Railway Oriented Typescript
=============================
by @robinpokorny
*/
/* === 1. Union basics === */
const a: string | number = 42;
@robinpokorny
robinpokorny / HttpStatusCode.ts
Created April 13, 2021 21:38
All HTTP status codes in TypeScript const Enums
export const enum InformationalResponse {
Continue = 100,
SwitchingProtocols = 101,
Processing = 102,
EarlyHints = 103,
}
export const enum Success {
OK = 200,
Created = 201,
@robinpokorny
robinpokorny / .bash_profile
Created March 4, 2020 13:10
In case of fire
function fire() {
local BRANCH=emergency-`date +%s`-`git config user.email`
git checkout -b $BRANCH
git add -A
git commit -m 'EMERGENCY!'
git push -f origin $BRANCH
}
# Inspired by https://www.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/cvn1k27/
@busypeoples
busypeoples / TypeScriptFundamentals.ts
Last active June 21, 2022 14:57
TypeScript Fundamentals For JavaScript Developers
// TypeScript Fundamentals For JavaScript Developers
/*
Tutorial for JavaScript Developers wanting to get started with TypeScript.
Thorough walkthrough of all the basic features.
We will go through the basic features to gain a better understanding of the fundamentals.
You can uncomment the features one by one and work through this tutorial.
If you have any questions or feedback please connect via Twitter:
A. Sharif : https://twitter.com/sharifsbeat
*/
@nemoDreamer
nemoDreamer / styles.less
Created May 20, 2017 12:16
Subtle italics in Atom syntaxes
atom-text-editor.editor {
.syntax--punctuation.syntax--whitespace.syntax--comment.syntax--leading,
.syntax--source {
font-family: FiraCode-Retina; // https://github.com/tonsky/FiraCode
text-rendering: optimizeLegibility;
letter-spacing: 0;
}
.syntax--string.quoted,
.syntax--string.regexp {
@bestander
bestander / gist:a8a07724138a7e89392de1a795a82ef9
Created March 9, 2017 17:50
When I need to make sure that people are on the same build tool for a project
"scripts": {
"preinstall": "if [[ '$npm_config_user_agent' != *'yarn'* ]]; then echo 'Use Yarn!'; exit 0; fi"
}
@jmahc
jmahc / style.css
Last active September 6, 2017 15:05
Operator Mono Collection & Styling for Atom Text Editor (Operator Mono/Pro/ScreenSmart)
/* CSS for VS Code */
/*
Feel free to remove these comments - just documenting why we do what we do...
*/
/* This is the left-hand pane or "tree-view" */
.monaco-split-view,
/* These are for any `.js` or `.jsx` files */
.editor-container[data-mode-id~="javascript"],
.editor-container[data-mode-id~="javascriptreact"] {
@bloodyowl
bloodyowl / Component.js
Created January 4, 2017 15:16
Component library in less than 140 bytes
b=0;$=x=>(p,i="_"+b++,u=($[i]=q=>eval(i).innerHTML=x(p,$[q],u),z=>($[++b]=z,`$.${i}(${b})`)))=>`<c id=${i}>${x(p,[]._,u)}</c>`
@steida
steida / OfflinePage.react.jsx
Last active August 19, 2016 10:10
Stateless functional component with decorators (not available yet)
import Helmet from 'react-helmet';
import React from 'react';
import linksMessages from '../../common/app/linksMessages';
import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { fields } from '../../common/lib/redux-fields';
@fields({
path: 'offline',
fields: [