Skip to content

Instantly share code, notes, and snippets.

View mendes5's full-sized avatar
📉
[object Object]

mendes5

📉
[object Object]
View GitHub Profile
@mendes5
mendes5 / ocs.json
Created March 9, 2022 04:04
Deep Rock Galatic overclocks by guns by characters, from karl.gg
{
"Engineer": {
"\"Warthog\" Auto 210": [
{
"id": 25,
"character_id": 1,
"gun_id": 1,
"overclock_type": "Clean",
"overclock_index": 1,
"overclock_name": "Stunner",
@mendes5
mendes5 / README.md
Created February 11, 2022 16:54
aws-iot-device-sdk + Nx Webpack config

Packages Needed:

  • aws-iot-device-sdk
  • buffer
  • process
  • util
  • @types/aws-iot-device-sdk(optional)

Override the default webpack config in project.json

While using @nrwl/web:build as the executor for the build target, add a custom webpack config file to your build configurations:

@mendes5
mendes5 / yaml.yml
Last active January 10, 2022 12:48
How to skip a GitLabCI job from a before_script
build-job:
before_script:
- |
if [[ "${CI_COMMIT_BRANCH}" != "${CI_DEFAULT_BRANCH}" ]]; then
git fetch origin $CI_DEFAULT_BRANCH
SKIPPABLE_CHANGES=`git diff origin/$CI_DEFAULT_BRANCH --name-only $SKIP_SOURCE_STAGES_FOR_DIRS`
ALL_CHANGES=`git diff origin/$CI_DEFAULT_BRANCH --name-only`
if [[ $SKIPPABLE_CHANGES == "" ]]; then
echo "There were no skippable changes, the script will continue"
elif [[ $SKIPPABLE_CHANGES == $ALL_CHANGES ]]; then
type Loaded<T> = {
state: 'loaded',
data: unknown,
};
type ErrorState = {
state: 'error',
error: Error,
};
@mendes5
mendes5 / cursed.js
Created October 26, 2021 14:10
Cursed numbered array builder
Number.prototype[Symbol.iterator] = function*() {
for (let n = 0; n <= this; n++)
yield n;
};
// this: [...4]
// outputs: [0, 1, 2, 3, 4]
@mendes5
mendes5 / cursed-loop.js
Created October 22, 2021 15:51
Cursed for loop using const
for (const x = { i: 0 }; x.i < 10; x.i++) {
console.log(x.i);
}
@mendes5
mendes5 / index.js
Created October 20, 2021 19:43
Hook into history and location functions to execute the debugger to debug unexpected URL changes
const _pushState = window.history.pushState.bind(window.history);
window.history.pushState = (...args) => {debugger; return _pushState(...args)};
const _replaceState = window.history.replaceState.bind(window.history);
window.history.replaceState = (...args) => {debugger; return _replaceState(...args)};
const _replace = window.location.replace.bind(window.location);
window.location.replace = (...args) => {debugger; return _replace(...args)};
const _reload = window.location.reload.bind(window.location);
@mendes5
mendes5 / git-alias.sh
Created August 23, 2021 23:29
My GIT aliases
alias branch="git symbolic-ref --short HEAD"
alias cki="git checkout \`recent | fzf | awk '{print \$1}'\`"
alias pushn="git push origin \`branch\` --no-verify"
alias push="git push origin \`branch\`"
alias master="git checkout master"
alias main="git checkout main"
alias st="git status"
alias changes="git diff --name-only HEAD master"
alias bop='git stash pop'
alias suc='git stash --keep-index --include-untracked'
@mendes5
mendes5 / track_alloc.rs
Created July 21, 2021 02:16
Track specific object allocations
use core::any::type_name;
use std::ops::{Deref, DerefMut};
use std::sync::Mutex;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::collections::HashMap;
pub struct TrackingStats {
pub instance_count: usize,
const assertFieldsPresent = <T extends Record<string, unknown>, U extends keyof T>(data: T, fields: U[]): T & Required<Pick<T, U>> => {
for (let field of fields) {
const value = data[field];
if (value === undefined || value === null) {
throw new Error(`[assertFields] Field "${field}" was not present`);
}
}
// @ts-ignore;