Skip to content

Instantly share code, notes, and snippets.

View antoniopresto's full-sized avatar

antoniopresto

  • São Paulo - Brasil
View GitHub Profile
# 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';
@antoniopresto
antoniopresto / funcions.php
Created April 24, 2019 22:31
prevent wordpress redirect subdomain
//...
remove_filter('template_redirect', 'redirect_canonical');
// https://stackoverflow.com/a/40958850
function hashStr(str) {
let hash = 0, i, chr, len;
if (str.length === 0) return hash;
for (i = 0, len = str.length; i < len; i++) {
chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
# Will show all the driver packages which apply to your current system. You can then
# sudo ubuntu-drivers list
# to install all the packages you need, or you can do:
sudo ubuntu-drivers autoinstall
# to show you which devices need drivers, and their corresponding package names.
# sudo ubuntu-drivers devices
@antoniopresto
antoniopresto / Form.js
Last active November 30, 2019 14:04
Antd Masked Input
import { Form } from 'antd'
import { FormInput } from './antd-masked-input'
export default () => (
<Form>
<FormInput
form={this.props.form} // antd form
mask={'111.111.111-11'}
placeholder=""
label={''}