This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _wr = function(type) { | |
var orig = history[type]; | |
return function() { | |
var rv = orig.apply(this, arguments); | |
var e = new Event(type); | |
e.arguments = arguments; | |
window.dispatchEvent(e); | |
return rv; | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
import 'package:path/path.dart'; | |
import 'package:sqflite/sqflite.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
class DatabaseHelper { | |
static final _databaseName = "MyDatabase.db"; | |
static final _databaseVersion = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if you don't plan to upload only images : | |
/* | |
async function convertToFile(data: AsyncIterable<Uint8Array>) { | |
const chunks = []; | |
for await (const chunk of data) { | |
chunks.push(chunk); | |
} | |
return chunks; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Alert } from "react-native"; | |
import * as WebBrowser from "expo-web-browser"; | |
import { useSupabaseClient } from "@supabase/auth-helpers-react"; | |
import { initiateAppleSignIn } from "../utils/auth"; | |
export const useAuth = () => { | |
const Supabase = useSupabaseClient(); | |
const signInWithPassword = async ( |
This setup uses some tricks to ensure that the right email/name/ssh-key is used for the right repos without having to think about it ever again.
- First generate two SSH keys,
~/.ssh/id_ed25519
and~/.ssh/id_ed25519_work
- Add one key to your personal account and the other to your work account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: make `pages` optional and measure the div when unspecified, this will | |
// allow more normal document flow and make it easier to do both mobile and | |
// desktop. | |
import { | |
createContext, | |
useCallback, | |
useContext, | |
useEffect, | |
useMemo, | |
useRef, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> | |
<script src="//ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script> | |
<!-- | |
TODO: |
This is an example to demo how you generate the RSA key pair from server side(.NetCore 3.1) and pass the public key to the client(Browser) for encrypting the data that <= 245 bytes.
RSA-2048 can only support to encrypt up to 245 bytes data.
using var rsaProvider = new RSACng();
// spki is used for browser side encryption
var spki = Convert.ToBase64String(rsaProvider.ExportSubjectPublicKeyInfo());
var encodedPrivateKey = Convert.ToBase64String(rsaProvider.ExportPkcs8PrivateKey());
NewerOlder