Skip to content

Instantly share code, notes, and snippets.

Mitchel Cabuloy mixxorz

Block or report user

Report or block mixxorz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mixxorz
mixxorz / vr-debug.scss
Created Sep 17, 2018
Debug vertical rhythm with Sass
View vr-debug.scss
@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 Feb 12, 2018
Source code for "How to write JavaScript components with jQuery"
View components-CarouselBlock-index.js
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 May 7, 2019
Django Service Objects
View services.py
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 Aug 22, 2016
MultipleSelectField Django 1.10 Python 3.4
View fields.py
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 Jul 19, 2019
Get requested fields from ResolveInfo. Graphene python.
View graphene.py
"""
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 Aug 7, 2018
Generate waveform images from audio files
View waveform.py
# 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 Mar 13, 2016
Creating new users and databases
View gist:d3e99ebbb1b3d75a1bda
# 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 Apr 16, 2015
Python Linked List
View linkedlist.py
card1 = {
'name': 'John Smith',
'age': 20,
'gpa': 3.0,
'pointer': None
}
card1
card2 = {
'name': 'Amanda Jones',
View gist:691b107fdbb7b15dd899
<?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 = [
You can’t perform that action at this time.