Skip to content

Instantly share code, notes, and snippets.

View jsmrcaga's full-sized avatar

Jo Colina jsmrcaga

View GitHub Profile
@tuxuser
tuxuser / xbl_oauth2.py
Created September 2, 2020 09:15
Sign in to Xbox Live with OAUTH2
"""
Sign in to Xbox Live with OAUTH2
1. Go to https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade
2. Register new app ("+ New registration")
2.1. Enter a name for your app
2.2. Set "Supported account types" to "Personal Microsoft accounts only"
2.3. Click register
2.4. Choose "Redirect URIs" -> "Add a Redirect URI"
2.5. Click "Add a platform" -> "Mobile and desktop applications"
@april
april / arena-macos-fixes.sh
Last active March 14, 2024 04:48
Fixes Magic Arena's broken full screen implementation on macOS
# this forces Arena into full screen mode on startup, set back to 3 to reset
# note that if you go into the Arena "Graphics" preference panel, it will reset all of these
# and you will need to run these commands again
defaults write com.wizards.mtga "Screenmanager Fullscreen mode" -integer 0
defaults write com.wizards.mtga "Screenmanager Resolution Use Native" -integer 0
# you can also replace the long complicated integer bit with any other scaled 16:9
# resolution your system supports.
# to find the scaled resolutions, go to System Preferences --> Display and then
# divide the width by 16 and multiple by 9. on my personal system this ends up
@herrjemand
herrjemand / verify.packed.webauthn.js
Last active April 4, 2024 15:09
WebAuthn Packed attestation verification sample in NodeJS
const crypto = require('crypto');
const base64url = require('base64url');
const cbor = require('cbor');
const jsrsasign = require('jsrsasign');
const elliptic = require('elliptic');
const NodeRSA = require('node-rsa');
let COSEKEYS = {
'kty' : 1,
'alg' : 3,
@n-ts
n-ts / worker.js
Created October 3, 2018 20:21
Cloudflare Workers - Load balancing to nearest datacenter from current POP
/*
--------------------------------------------------------
Please note that this grouping is just for example...
You can rearrange POPs, remove or add dacaneters according to your needs.
--------------------------------------------------------
First, we have to get all Cloudflare POP codes (three letter airport codes) from https://www.cloudflarestatus.com/
North America is routed to Chigaco datacenter;
Europe, Africa and Middle East is routed to Amsterdam datacenter;
@joewiz
joewiz / post-mortem.md
Last active September 3, 2023 11:57
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files)

2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

  1. * Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  2. Added fs.file-max = 70000 to /etc/sysctl.conf
@Artazor
Artazor / await-promises.md
Last active July 25, 2023 11:44
Await operator desugaring into promises

Here is an example how await operator can be desugared into Promise-based code without ES6 generators (and state machines that emulate generators missing in ES5). The only assumption is that there is Promise.resolve (to create an empty promise for the loop finalization) among the globals.

Examples are written with "throw early" policy adoption: if promisified code has a synchronous preamble that throws we prefer to throw instead of creating rejected Promise.

Note that patterns below don't cover control flow breaks like return, break, continue and throw (for these breaks we should use a bit more complex structures).

Asynchronous sequence

@sindresorhus
sindresorhus / post-merge
Last active February 14, 2024 06:20
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: