Skip to content

Instantly share code, notes, and snippets.

View alysivji's full-sized avatar
🕶️

Aly Sivji alysivji

🕶️
View GitHub Profile
@alysivji
alysivji / graph_transitions.py
Created March 30, 2021 06:05
Exporting Mermaid Markdown for django-fsm
# -*- coding: utf-8; mode: django -*-
import graphviz
from optparse import make_option
from django.core.management.base import BaseCommand
from django.utils.encoding import force_text
from django_fsm import FSMFieldMixin, GET_STATE, RETURN_VALUE
try:
@alysivji
alysivji / app.py
Created July 6, 2018 16:57
Decorators inside of classes. ChiPy Slack question 20180706
def add_two(func):
def _wrapper(*args, **kwargs):
return func(*args, **kwargs) + 2
return _wrapper
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
# combine last 2 commits into 1
git reset --soft "HEAD^"
git commit --amend
import pytest
import interface
@pytest.fixture(scope='session')
def run_command_mock(mocker):
def _create_run_command_mock(mock_return_value):
mock_run = mocker.MagicMock(name='run command mock')
mock_run.return_value = "foo"
run_command_patch = mocker.patch('interface.run_command', new=mock_run)
@alysivji
alysivji / debugging.php
Created February 28, 2018 16:17
PHP snippets
if ( ! function_exists('write_log')) {
function write_log ( $log ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
@alysivji
alysivji / docker-compose.yml
Last active February 27, 2018 01:22
Container-based PHP + MySQL development environment
version: '3'
services:
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: my_secret_pw_shh
MYSQL_DATABASE: test_db
MYSQL_USER: devuser
MYSQL_PASSWORD: devpass
@alysivji
alysivji / auth token
Last active April 15, 2018 15:50
Unix snippets
import uuid; uuid.uuid4().hex
@alysivji
alysivji / keybindings.json
Last active September 18, 2020 15:21
VSCode Settings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+g",
"command": "editor.foldAll",
"when": "editorTextFocus"
},
{
"key": "cmd+h",
"command": "editor.unfoldAll",
@alysivji
alysivji / app.py
Created December 23, 2017 13:02
troubleshooting-soccer-dashboard-20171223
# standard library
import os
# dash libs
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import plotly.figure_factory as ff
import plotly.graph_objs as go
defaults write -g InitialKeyRepeat -int 15 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 2 # normal minimum is 2 (30 ms)