Skip to content

Instantly share code, notes, and snippets.

View amorino's full-sized avatar
🏠
Working from home

Erick Bazán amorino

🏠
Working from home
View GitHub Profile
@amorino
amorino / xcode-downloader.rb
Created June 10, 2020 18:48
Script for reliably downloading binaries (e.g. Xcode) from Apple's CDN
#!/usr/bin/env ruby
print "What is the URL of your Apple Downloads resource?\nURL:"
url = gets.strip
print "What is the ADCDownloadAuth cookie token:\nADCDownloadAuth: "
token = gets.strip
command = "aria2c --header \"Host: adcdownload.apple.com\" --header \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\" --header \"Upgrade-Insecure-Requests: 1\" --header \"Cookie: ADCDownloadAuth=#{token}\" --header \"User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0 Mobile/14B72 Safari/602.1\" --header \"Accept-Language: en-us\" -x 16 -s 16 #{url} -d ~/Downloads"
Atrapado en Moon Ball
Charizard-Gmax (F) @ Master Ball
Ability: Blaze
EVs: 4 Def / 252 SpA / 252 Spe
Timid Nature
IVs: 0 Atk
- Protect
- Blast Burn
- Solar Beam
- Air Slash
ffmpeg -i Main.mov -c:v libvpx -pix_fmt yuva420p -b:v 1M -auto-alt-ref 0 -metadata:s:v:0 alpha_mode="1" -c:a libvorbis Main.webm
@amorino
amorino / axios.refresh_token.js
Created March 14, 2019 17:01 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@amorino
amorino / letsencrypt_2017.md
Created February 20, 2018 17:12 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@amorino
amorino / letsencrypt.sh
Created February 16, 2018 16:17
Backup Let's Encrypt folder
# Backup
tar zcvf /tmp/letsencrypt_backup_$(date +'%Y-%m-%d_%H%M').tar.gz /etc/letsencrypt
# Check content
tar tvf /tmp/letsencrypt_backup_2016-10-23_0114.tar.gz
# In case of disaster
tar zxvf /tmp/letsencrypt_backup_2016-10-23_0114.tar.gz -C /
window.open('https://player.twitch.tv/?volume=1&!muted&channel=Shiptur','Twitch','height=500,width=300');
/*
Returns a random point of a sphere, evenly distributed over the sphere.
The sphere is centered at (x0,y0,z0) with the passed in radius.
The returned point is returned as a three element array [x,y,z].
*/
function randomSpherePoint(x0,y0,z0,radius){
var u = Math.random();
var v = Math.random();
var theta = 2 * Math.PI * u;
var phi = Math.acos(2 * v - 1);
@amorino
amorino / convert id_rsa to pem
Created March 6, 2017 16:21 — forked from mingfang/convert id_rsa to pem
Convert id_rsa to pem file
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
chmod 700 id_rsa.pem
ratio = (parent = {width: window.innerWidth, height: window.innerHeight }, child) => {
let width, height
if (child.width / parent.width < child.height / parent.height) {
width = parent.width
height = width / child.width * child.height
} else {
height = parent.height
width = height / child.height * child.width
}