Skip to content

Instantly share code, notes, and snippets.

View mintyPT's full-sized avatar
🦑

MG Santos mintyPT

🦑
View GitHub Profile
@mintyPT
mintyPT / migration.py
Last active December 16, 2024 14:35
Migrate charfield's choice in django
# If you change some field's choice, django will not migrate the value at
# the database level. You need to do it.
#
# Generate an empty migration:
# > python manage.py makemigrations --empty <app_name>
#
# This will migration the value in the `state` field from `new` to `new_b`
# (and back if necessary).
from django.db import migrations
@mintyPT
mintyPT / progress_list.py
Last active August 20, 2024 09:53
Class to help you keep track of the progress of a loop
import time
from datetime import timedelta
class ProgressList:
def __init__(self, data, step=1, description=None, eta=True):
self.data = data
self.total = len(data)
self.current_index = 0
self.step = step # Step interval for printing progress
self.start_time = None
const fs = require("fs")
const puppeteer = require("puppeteer")
// First level config
const project = "atelier/05"
const count = 50
// Second level config
const folder = `screenshots/${project}/`
function doubleiter(nums: number[], target: number): number[] {
for(let i = 0; i<nums.length; i++){
for(let j = i+1; j<nums.length; j++){
}
}
};
@mintyPT
mintyPT / Makefile
Last active February 12, 2021 13:45
Example of a Makefile to work with django
# ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-
# SETUP
# ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-
.PHONY: help activate install flake8 isort black check virtualenv-path runserver runserver_plus migrations migrate shell shell_plus makemessages compilemessages collectstatic createsuperuser reset_db startapp clear_cache services
YELLOW := "\e[1;33m"
NC := "\e[0m"
INFO := @bash -c 'printf $(YELLOW); echo "=> $$1"; printf $(NC)' MESSAGE
@mintyPT
mintyPT / hodl20.py
Created December 1, 2019 18:03 — forked from anthonytxie/hodl20.py
Hodl 20 Rebalancing Algorithm
def calc_allocations(self, date, quantity, cap):
"""Figure out ideal allocations for a given date"""
# {
# coin_name: (percent_allocation, data)
# }
top_market = self.get_top_market(date, quantity)
total_cap = sum([coin.market_cap for coin in top_market])
allocations = [{
@mintyPT
mintyPT / ._bootstrap.sh
Last active October 30, 2019 21:10
Bootstrap a typesript (node) project
npm init -y
npm install \
tslint \
eslint \
ts-node \
nodemon \
prettier \
typescript \
eslint-config-prettier \
eslint-plugin-prettier \
@mintyPT
mintyPT / diff.js
Created November 2, 2018 14:09
Shows the difference (in keys) between 2 json files
// node diff.js f1.json f2.json
const _ = require('lodash');
const path = require('path');
if (process.argv.length != 4) {
throw new Error('node script.js file1.json file2.json');
}
const f1 = process.argv[2];
@mintyPT
mintyPT / toType.js
Last active September 13, 2018 22:06
js snippets
const toType = obj => ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream