Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Patches pi to fix Shift+Enter in tmux with extended-keys on
# Run this after upgrading pi: bash ~/Code/pi-playground/patch-pi.sh
set -e
# Find the installed paths
PI_TUI=$(node -e "console.log(require.resolve('@mariozechner/pi-tui/dist/keys.js'))" | xargs dirname)
PI_AGENT=$(node -e "console.log(require.resolve('@mariozechner/pi-coding-agent/dist/modes/interactive/components/custom-editor.js'))" | xargs dirname)

Installation

npm install -g .

Run

$ sudo -E xfwd
class Payments(models.Model):
STATES = {
'started': 'Started',
'captured': 'Captured',
'completed': 'Completed',
'incomplete': 'Incomplete', # new incomplete state for us
}
def __init__(self, *args, **kwargs):
super(Payments, self).__init__(*args, **kwargs)
class Payments(models.Model):
STATES = {
'started': 'Started',
'captured': 'Captured',
'completed': 'Completed',
}
state = models.CharField(default='started', choices=STATES.items(), max_length=16)
def __init__(self, *args, **kwargs):
class Payment(models.Model):
STATE_CHOICES = (
('started', 'Started'),
('captured', 'Captured'),
('completed', 'Completed'),
# we introduce a new "incomplete" state
('incomplete', 'Incomplete'),
)
def can_complete(self):
class Payment(models.Model):
STATE_CHOICES = (
('started', 'Started'),
('captured', 'Captured'),
('completed', 'Completed'),
)
state = models.CharField(choices=STATE_CHOICES, default='started', max_length=16)
def can_capture(self):
class Payment(models.Model):
is_started = models.BooleanField(default=True)
is_captured = models.BooleanField(default=False)
is_completed = models.BooleanField(default=False)
def can_capture(self):
return self.is_started and not self.is_captured and not self.is_completed
def can_complete(self):
return self.is_captured
@dhruvbaldawa
dhruvbaldawa / pytransitions.py
Created January 27, 2018 19:50
pytransitions example
from transitions import Machine
class Payments(models.Model):
STATES = {
'started': 'Started',
'captured': 'Captured',
'completed': 'Completed',
}
### Keybase proof
I hereby claim:
* I am dhruvbaldawa on github.
* I am dhruvbaldawa (https://keybase.io/dhruvbaldawa) on keybase.
* I have a public key whose fingerprint is 7C20 B07E 23F3 2875 0BD1 FC85 3825 385A 7C27 34C1
To claim this, I am signing this object:
@dhruvbaldawa
dhruvbaldawa / check_mu.py
Created April 24, 2014 23:57
few interesting python scripts
import urllib2
import time
import os
msg_string = 'Result for %s %s declared.'
url = 'http://results.mu.ac.in/choose_nob.php?exam_id=%s&exam_year=2012&exam_month=MAY'
# some exam_id to start looking from
id_start = 2765