Skip to content

Instantly share code, notes, and snippets.

View mixxorz's full-sized avatar

Mitchel Cabuloy mixxorz

View GitHub Profile
@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 February 15, 2024 16:18
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 January 19, 2023 15:46
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',
@mixxorz
mixxorz / gist:691b107fdbb7b15dd899
Created March 10, 2015 11:17
PHP Arrays to JSON
<?php
// This is how you would declare arrays in PHP (version 5.4+)
$someArray = [
"first value",
"second value"
];
// PHP Arrays are apparently also hash maps/dictionaries/whatever
$person = [