Skip to content

Instantly share code, notes, and snippets.

View mfbx9da4's full-sized avatar

David Alberto Adler mfbx9da4

View GitHub Profile
@emehrkay
emehrkay / ws.js
Last active May 4, 2021 10:43
simple webrtc video
class Video {
constructor(video){
this.video = video;
}
setStream(stream){
console.log('setting stream', stream)
this.video.srcObject = stream;
this.video.play();
}
@mfbx9da4
mfbx9da4 / debouncedChunkedQueue.ts
Last active September 19, 2023 08:01
An implementation of a debounced chunked async queue. An async function may be called many times over some period of time. We want to first debounce the calls to the function and batch up all those arguments into one argument. Secondly all executions of that async function should be serialized in a FIFO manner.
export const debouncedChunkedQueue = <T>(
fn: (items: T[]) => Promise<void> | void,
delay = 1000
) => {
let items: T[] = []
let started = false
const push = (item: T) => {
items.push(item)
if (!started) start()
}
@mrcleanandfresh
mrcleanandfresh / super-list-infinite.tsx
Last active May 17, 2021 16:53
React Virtualized Infinite loader with List example using React Hooks
import faker from 'faker';
import _ from 'lodash';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Col, Row } from 'react-bootstrap';
import { AutoSizer, IndexRange, InfiniteLoader, List, ListRowProps } from 'react-virtualized';
import wait from 'waait';
import { SuperProps } from './super-props';
export interface SuperListProps {
/**
@autotrof
autotrof / App.tsx
Last active February 3, 2024 20:33
encrypt decrypt file in react native [working with large file]. using react-native-fs and node-forge
import React from 'react';
import { StyleSheet, Text, View, PermissionsAndroid, ProgressBarAndroid } from 'react-native';
import RNFS from 'react-native-fs'
import forge from 'node-forge'
import {Buffer} from 'buffer'
import zlib from 'react-zlib-js'
const key = forge.random.getBytesSync(16);
const iv = forge.random.getBytesSync(16);
const limit_big = 1024*512;
@tgriesser
tgriesser / formik.tsx
Last active March 12, 2021 10:58
Formik w/ Hooks
import React, {
useContext,
createContext,
createElement,
useEffect,
useRef,
useCallback,
useState,
} from 'react';
import isEqual from 'react-fast-compare';
@amcvitty
amcvitty / password_autofill_expo_how_to.md
Last active September 18, 2024 08:48
Configure Password Autofill on a React Native Expo app

Password Autofill on a React Native Expo app

Developing an app to accompany our website, worried that we would lose people in the transition if they couldn't remember their password, we were looking to make our app do Password AutoFill, a feature in iOS.

A talk from WWDC introducing the feature: https://developer.apple.com/videos/play/wwdc2017/206/

It works well, but there were a few bumps in the road making it work for React Native on Expo, so here are some notes to help out.

Apple's docs are here: https://developer.apple.com/documentation/security/password_autofill and they say something like this:

@atomkirk
atomkirk / parsce-csv-test.js
Last active February 13, 2023 09:19
parse csv with javascript
import parseCsv from 'zipbooks/utils/parse-csv'
import { module, test } from 'qunit'
module('Unit | Utility | parse-csv', function(_hooks) {
test('parses csv successfully', function(assert) {
let result = parseCsv('name,age\nadam,31\ntim,32\n"St, clair",26')
assert.equal(JSON.stringify(result), '[["name","age"],["adam","31"],["tim","32"],["St, clair","26"]]')
})
@nakov
nakov / secp256k1-example.js
Last active April 9, 2024 16:32
ECDSA in JavaScript: secp256k1-based sign / verify / recoverPubKey
let elliptic = require('elliptic');
let sha3 = require('js-sha3');
let ec = new elliptic.ec('secp256k1');
// let keyPair = ec.genKeyPair();
let keyPair = ec.keyFromPrivate("97ddae0f3a25b92268175400149d65d6887b9cefaf28ea2c078e05cdc15a3c0a");
let privKey = keyPair.getPrivate("hex");
let pubKey = keyPair.getPublic();
console.log(`Private key: ${privKey}`);
console.log("Public key :", pubKey.encode("hex").substr(2));
@pgilad
pgilad / Instructions.md
Last active March 27, 2024 12:59
Generate SSL Certificate for use with Webpack Dev Server (OSX)

Generate private key

$ openssl genrsa -out private.key 4096

Generate a Certificate Signing Request

openssl req -new -sha256 \