Skip to content

Instantly share code, notes, and snippets.

View creimers's full-sized avatar
🏠
Working from a great place

C Reimers creimers

🏠
Working from a great place
View GitHub Profile
@kentcdodds
kentcdodds / session.server.ts
Created November 18, 2021 21:04
Authentication in Remix applications
import * as bcrypt from "bcrypt";
import { createCookieSessionStorage, redirect } from "remix";
import { db } from "./db.server";
export type LoginForm = {
username: string;
password: string;
};
@EduVencovsky
EduVencovsky / useAsyncStorage.js
Last active April 27, 2022 07:33
React Native hook for keeping the state in sync with AsyncStorage
import { useState, useEffect } from 'react'
import AsyncStorage from '@react-native-community/async-storage'
const useAsyncStorage = (key, initialValue) => {
const [hasLoad, setHasLoad] = useState(false)
const [data, setData] = useState(initialValue)
const set = async newData => {
setData(newData)
return newData === null ?
@royshil
royshil / cylindricalWarping.py
Last active May 7, 2024 06:42
Warp an image to cylindrical coordinates for cylindrical panorama stitching, using Python OpenCV
import cv2
import numpy as np
def cylindricalWarp(img, K):
"""This function returns the cylindrical warp for a given image and intrinsics matrix K"""
h_,w_ = img.shape[:2]
# pixel coordinates
y_i, x_i = np.indices((h_,w_))
X = np.stack([x_i,y_i,np.ones_like(x_i)],axis=-1).reshape(h_*w_,3) # to homog
Kinv = np.linalg.inv(K)
@edp1096
edp1096 / index.html
Created August 25, 2018 04:20 — forked from tmichel/index.html
simple websocket example with golang
<html>
<head>
<title>WebSocket demo</title>
</head>
<body>
<div>
<form>
<label for="numberfield">Number</label>
<input type="text" id="numberfield" placeholder="12"/><br />
@nickcernis
nickcernis / readme.md
Last active March 7, 2024 01:43
Exclude node_modules and .git from Backblaze backups on Mac

Exclude node_modules and .git from Backblaze backups on Mac

  1. Edit the file at /Library/Backblaze.bzpkg/bzdata/bzexcluderules_editable.xml.
  2. Add these rules inside the bzexclusions tag:
<!-- Exclude node_modules. -->
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/node_modules/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
<excludefname_rule plat="mac" osVers="*"  ruleIsOptional="t" skipFirstCharThenStartsWith="users/" contains_1="/.git/" contains_2="*" doesNotContain="*" endsWith="*" hasFileExtension="*" />
@hubgit
hubgit / SelectField.tsx
Last active December 29, 2023 03:41
Use react-select with Formik
import { FieldProps } from 'formik'
import React from 'react'
import Select, { Option, ReactSelectProps } from 'react-select'
export const SelectField: React.SFC<ReactSelectProps & FieldProps> = ({
options,
field,
form,
}) => (
<Select
@GabLeRoux
GabLeRoux / env-to-json.py
Last active September 10, 2023 00:45
.env file to json using simple python
#!/usr/bin/env python
import json
import sys
try:
dotenv = sys.argv[1]
except IndexError as e:
dotenv = '.env'
with open(dotenv, 'r') as f:
/* @flow */
import React from 'react';
import Relay from 'react-relay';
import cookies from 'browser-cookies';
import LoginForm from './LoginForm';
import LoginMutation from './mutations/LoginMutation';
@rverton
rverton / test_file_upload.py
Created August 2, 2016 15:00
Test file upload with flask (Python3)
from io import BytesIO
def test_file_upload(client):
data = {
'field': 'value',
'file': (BytesIO(b'FILE CONTENT'), 'test.csv')
}
rv = client.post('/upload', buffered=True,
@manuelroth
manuelroth / index.js
Last active May 18, 2023 07:51
A very simple node.js server for serving vector tiles from an mbtiles file
var express = require("express"),
app = express(),
MBTiles = require('mbtiles'),
p = require("path");
// Enable CORS and set correct mime type/content encoding
var header = {
"Access-Control-Allow-Origin":"*",
"Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept",
"Content-Type":"application/x-protobuf",