Skip to content

Instantly share code, notes, and snippets.

View antoniopresto's full-sized avatar

Antonio Silva antoniopresto

View GitHub Profile
import cx from 'classnames';
import { createType, Infer, tuple, tupleNum } from 'backland';
export const ViewportSizeEnum = tuple('xs', 'sm', 'md', 'lg', 'xl');
export const ViewportSizes = Object.values(ViewportSizeEnum);
export type ViewportSize = typeof ViewportSizes[number];
export const ViewportSizeType = createType('ViewportSize', {
enum: ViewportSizes,
optional: true,
const userSchema = createSchema({
name: 'string?',
age: 'int',
gender: ['f', 'm', 'o'],
address: {
type: 'schema',
def: {
name: 'string',
number: [['float', 'string']],
},
@antoniopresto
antoniopresto / NullableToPartial.ts
Last active January 27, 2022 16:21
Typescript convert Nullable (null or undefined) to Partial / not required
export type NullableToPartial<T> = T extends { [K: string]: any }
? {
[K in keyof ({
[K in NullableKeys<T>]?: T[K];
} & {
[K in RequiredKeys<T>]-?: T[K];
})]: ({
[K in NullableKeys<T>]?: T[K];
} & {
[K in RequiredKeys<T>]-?: T[K];
.ui-flex {
display: flex;
flex-wrap: wrap;
flex: 0 1 auto;
flex-basis: 100%;
max-width: 100%;
max-height: max-content;
&.full {
width: 100%;
# First, you must get the previous commit sha, the one before the forced push:
## Hit through terminal
curl -u <username> https://api.github.com/repos/:owner/:repo/events
# Then you can create a branch from this sha:
## Hit through terminal
curl -u <github-username> -X POST -d '{"ref":"refs/heads/<new-branch-name>", "sha":"<sha-from-step-1>"}' https://api.github.com/repos/:owner/:repo/git/refs
@antoniopresto
antoniopresto / spotify-shuffle-all.js
Created November 20, 2019 12:50
shuffle all songs on spotify library
/**
* paste in the browser console and hit enter
*/
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutationRecord) {
window.onChangeProgressBar(
+mutationRecord.target.style.transform.split('.')[0].replace(/\D/gim, '')
);
});
git log master..HEAD --oneline | tail -1
@antoniopresto
antoniopresto / fix-yarn-integity.sh
Created November 8, 2019 12:13
fix "Incorrect integrity when fetching from the cache"
yarn policies set-version 1.18
# https://github.com/yarnpkg/yarn/issues/7584#issuecomment-538048817
@antoniopresto
antoniopresto / spotify-shuffle.js
Created August 30, 2019 11:01
spotify shuffle all playlists, random all songs
/**
go to https://open.spotify.com/collection/playlists
and ast this in the browser console
**/
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutationRecord) {
window.onChangeProgressBar(
+mutationRecord.target.style.transform.split('.')[0].replace(/\D/gim, '')
);
/**
* Register and cache promises for SSR
*/
import React from 'react';
// @ts-ignore
import EventEmitter from 'events';
// @ts-ignore
import * as http from 'http';
import { captureError } from './capture';