Skip to content

Instantly share code, notes, and snippets.

View octavioamu's full-sized avatar
:octocat:
Working from home

Octavio Amuchástegui octavioamu

:octocat:
Working from home
View GitHub Profile
@LewisJEllis
LewisJEllis / getRelativeTimeString.ts
Last active August 25, 2024 12:55
Simplified getRelativeTimeString
// from https://twitter.com/Steve8708/status/1504131981444980739
// simplified to a function body of 8 tidy lines
// no loop needed, no 2d array of 3-tuples needed
// just 2 arrays, a findIndex call, and some indexing :)
export function getRelativeTimeString(
date: Date | number,
lang = "en"
): string {
const timeMs = typeof date === "number" ? date : date.getTime();
const minute = 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = day * 365;
/**
* Convert a date to a relative time string, such as
* "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc.
@rmeissner
rmeissner / safe_sig_gen_uport_eip712.ts
Last active March 12, 2023 19:54
Example Safe signature generation with uport eip712 lib
import EIP712Domain from "eth-typed-data";
import BigNumber from "bignumber.js";
import * as ethUtil from 'ethereumjs-util';
import { ethers } from "ethers";
import axios from "axios";
/*
* Safe relay service example
* * * * * * * * * * * * * * * * * * * */
@frankchen07
frankchen07 / gitcoin_onboarding_pitch.md
Last active July 29, 2020 23:15
Gitcoin Onboarding Pitch

Gitcoin Onboarding Pitch

Problem:

When a user hits Gitcoin, they're immediately bombarded by townsquare and a navigation bar up top that indiscriminately introduces them to the whole product suite of Gitcoin. New folks find this confusing, and returning users have to dig through a dropdown list or URLs in order to find where they're going. From the Gitcoin operator side, we have no idea what that user is on the site for, and serving an entire buffet of products lengthens the "time to value" for a particular user.

Screen Shot 2020-07-24 at 10 52 39

Screen Shot 2020-07-24 at 10 52 54

const Parser = require('rss-parser');
const parseVolumeToInt = volume => {
const vol = volume.replace('+', '').replace(',', '');
return Number.parseInt(vol, 10);
};
async function getGoogleTrends(url) {
const parser = new Parser({
defaultRSS: 2.0,
@SagiMedina
SagiMedina / ImageTools.js
Last active September 7, 2024 04:39
Resize and crop images in the Browser with orientation fix using exif
import EXIF from 'exif-js';
const hasBlobConstructor = typeof (Blob) !== 'undefined' && (function checkBlobConstructor() {
try {
return Boolean(new Blob());
} catch (error) {
return false;
}
}());
@callmeloureiro
callmeloureiro / comoSerChatoNoWhatsapp.js
Last active January 15, 2024 20:44
Como fazer alguém te responder no whatsapp
/*
Hoje iremos MUDAR a vida da pessoa que não te responde no whatsappp...
Que tal enviar mensagens pra ela até obter uma resposta?!
Sensacional não acha?! Mas, somos devs, correto?! Então vamos automatizar esse paranauê!
Para utilizar:
- Abra o web.whatsapp.com;
- Selecione a conversa que você quer;
- Abra o console e cole o código que está no gist;
@jlouros
jlouros / aws.upload-folder-to-s3.js
Last active September 8, 2023 22:48
Upload folder to S3 (Node.JS)
const AWS = require("aws-sdk"); // from AWS SDK
const fs = require("fs"); // from node.js
const path = require("path"); // from node.js
// configuration
const config = {
s3BucketName: 'your.s3.bucket.name',
folderPath: '../dist' // path relative script's location
};
@sagivo
sagivo / gist:3a4b2f2c7ac6e1b5267c2f1f59ac6c6b
Last active September 22, 2024 10:55
webRTC stun / turn server list
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,
@paulirish
paulirish / what-forces-layout.md
Last active September 22, 2024 14:48
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent