Skip to content

Instantly share code, notes, and snippets.

View carloslfu's full-sized avatar
🚀
Building!

Carlos Galarza carloslfu

🚀
Building!
View GitHub Profile
@carloslfu
carloslfu / machine.js
Last active September 1, 2020 23:42
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@carloslfu
carloslfu / vendor-list.json
Last active February 18, 2020 18:56
global vendor List (GVL) for TCF v2 experiments
{"gvlSpecificationVersion":2,"vendorListVersion":25,"tcfPolicyVersion":2,"lastUpdated":"2020-02-13T16:05:22Z","purposes":{"1":{"id":1,"name":"Store and/or access information on a device","description":"Cookies, device identifiers, or other information can be stored or accessed on your device for the purposes presented to you.","descriptionLegal":"Vendors can:\n* Store and access information on the device such as cookies and device identifiers presented to a user."},"2":{"id":2,"name":"Select basic ads","description":"Ads can be shown to you based on the content you\u2019re viewing, the app you\u2019re using, your approximate location, or your device type.","descriptionLegal":"To do basic ad selection vendors can:\n* Use real-time information about the context in which the ad will be shown, to show the ad, including information about the content and the device, such as: device type and capabilities, user agent, URL, IP address\n* Use a user\u2019s non-precise geolocation data\n* Control the frequency of ads sh
@carloslfu
carloslfu / README.md
Created November 20, 2019 18:01
Flatten an array in TypeScript
@carloslfu
carloslfu / flatten.js
Created November 7, 2018 06:51
Flatten in JS
function flatten(list) {
return list.reduce(function (acc, val) {
return acc.concat(Array.isArray(val) ? flatten(val) : val);
}, []);
}
@carloslfu
carloslfu / index.ts
Created March 30, 2018 21:27
Stackblitz resolver with Github support
import { Resolver, NpmHttpRegistry } from '@stackblitz/turbo-resolver';
function resolve(dependencies){
const resolver = new Resolver();
return resolver.resolve(dependencies);
}
resolve({
"rxjs": "https://github.com/reactivex/rxjs", // Master branch of Rx.js repo
"left-pad": "*",
@carloslfu
carloslfu / index.js
Last active April 16, 2023 20:01
Make a P2P connection in 10 minutes
const crypto = require('crypto')
const Swarm = require('discovery-swarm')
const defaults = require('dat-swarm-defaults')
const getPort = require('get-port')
const readline = require('readline')
/**
* Here we will save our TCP peer connections
* using the peer id as key: { peer_id: TCP_Connection }
*/
@carloslfu
carloslfu / cpromise.js
Last active October 21, 2018 12:03
Cancellable Promise Example
function CPromise (fn) {
let obj = {}
let p = new Promise((resolve, reject) => {
fn(resolve, reject, obj)
obj.reject = reject
})
p.cancel = () => {
if (obj.oncancel) {
obj.oncancel()
}
function CPromise (fn) {
let obj = {}
let p = new Promise((resolve, reject) => {
fn(resolve, reject, obj)
obj.reject = reject
})
p.cancel = () => {
if (obj.oncancel) {
obj.oncancel()
}
@carloslfu
carloslfu / keybase.md
Last active September 20, 2017 23:07

Keybase proof

I hereby claim:

  • I am carloslfu on github.
  • I am carloslfu (https://keybase.io/carloslfu) on keybase.
  • I have a public key whose fingerprint is 3662 9804 D90A 636A B7FD 9754 11DB ECC1 FFB7 8186

To claim this, I am signing this object: