Skip to content

Instantly share code, notes, and snippets.

View mixxorz's full-sized avatar

Mitchel Cabuloy mixxorz

View GitHub Profile
@mixxorz
mixxorz / README.md
Last active March 6, 2025 10:03
Tampermonkey script that allows you to test your CSS/JS on staging/production sites without a deployment

Local Dev Redirector

Redirect requests for specific JS/CSS files to your local versions for development.

I sometimes find myself needing to test my local development JS/CSS files on staging/production without actually comitting the file and making a deployment. This can be because staging/production has specific content that you can't replicate locally, or if one or more of your front-end components need to execute on the correct domain.

So I (cough ChatGPT) wrote this script that replaces the URLs in the <script> and tags that you specify. More than that, it can also redirect requests for specific endpoints to your local development server for further testing flexibility.

Usage

@mixxorz
mixxorz / gist:f47df05e468233300255c79eff18fddf
Created April 24, 2020 21:43
World of Warcraft: Google Sheet custom number format for gold
Format: [>9999999999]###\,###\,###"g "##"s "#0"c";[>9999999]###\,###"g "##"s "#0"c";#0"g "00"s "00"c";
How it looks
0g 00s 00c
0g 00s 12c
0g 01s 23c
0g 12s 34c // Does not support hiding silver/copper
1g 23s 45c
12g 34s 56c
123g 45s 67c
@mixxorz
mixxorz / vr-debug.scss
Created September 17, 2018 09:34
Debug vertical rhythm with Sass
@mixin vertical-grid($line-height: 24px) {
position: relative;
&::before {
$stripe-color: rgba(blue, 0.2);
background-image: repeating-linear-gradient(to bottom, $stripe-color, $stripe-color $line-height, transparent $line-height, transparent $line-height * 2);
bottom: 0;
content: '';
left: 0;
position: absolute;
@mixxorz
mixxorz / components-CarouselBlock-index.js
Created February 12, 2018 04:04
Source code for "How to write JavaScript components with jQuery"
import $ from 'jquery'
import './styles.scss'
import CarouselControls from '../CarouselControls'
import CarouselDots from '../CarouselDots'
import CarouselSlider from '../CarouselSlider'
import mod from '../../lib/mod'
class CarouselBlock {
@mixxorz
mixxorz / services.py
Last active January 21, 2020 16:52
Django Service Objects
from django import forms
from django.core.exceptions import ValidationError
from django.db import transaction
class InvalidInputsError(Exception):
def __init__(self, errors, non_field_errors):
self.errors = errors
self.non_field_errors = non_field_errors
@mixxorz
mixxorz / fields.py
Created August 22, 2016 10:54
MultipleSelectField Django 1.10 Python 3.4
from django import forms
from django.core import exceptions
from django.db import models
from django.utils.encoding import force_text
class MultipleSelectFormField(forms.MultipleChoiceField):
widget = forms.CheckboxSelectMultiple
@mixxorz
mixxorz / graphene.py
Last active January 9, 2025 16:46
Get requested fields from ResolveInfo. Graphene python.
"""
MIT License
Copyright (c) 2018 Mitchel Cabuloy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@mixxorz
mixxorz / waveform.py
Last active February 5, 2025 12:02
Generate waveform images from audio files
# Requires pydub (with ffmpeg) and Pillow
#
# Usage: python waveform.py <audio_file>
import sys
from pydub import AudioSegment
from PIL import Image, ImageDraw
@mixxorz
mixxorz / gist:d3e99ebbb1b3d75a1bda
Last active March 13, 2016 04:38
Creating new users and databases
# Postgres
psql -d postgres
CREATE USER user_name WITH PASSWORD 'password';
CREATE DATABASE database_name WITH OWNER user_name;
# MySQL
mysql -u root -p
CREATE DATABASE database_name;
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'newuser'@'localhost';
@mixxorz
mixxorz / linkedlist.py
Created April 16, 2015 03:43
Python Linked List
card1 = {
'name': 'John Smith',
'age': 20,
'gpa': 3.0,
'pointer': None
}
card1
card2 = {
'name': 'Amanda Jones',