Skip to content

Instantly share code, notes, and snippets.

View gloc-mike's full-sized avatar
💭
Living the dream! 🎉

Michael B gloc-mike

💭
Living the dream! 🎉
View GitHub Profile
@basnijholt
basnijholt / cto_line.pine
Created September 18, 2021 08:23
CTO Line indicator for TradingView
//@version=4
study(title="CTO Line", shorttitle="CTO", overlay=true, resolution="")
smma(src, length) =>
smma = 0.0
smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length
smma
v1 = smma(hl2, 15)
m1 = smma(hl2, 19)
m2 = smma(hl2, 25)
v2 = smma(hl2, 29)
@register.filter
def is_new(added, days=7):
days_new_deadline = timezone.now() - timezone.timedelta(days=days)
return added > days_new_deadline
# use in template
<a {% with obj.added|is_new as is_new %}
{% if is_new %}class="is_new newLeft"{% endif %}
{% endwith %} href="{% url 'app:view' pk %}">link</a>
{% for book in books %}
<li>{{ book }}</li>
{% empty %}
<li>Sorry, there are no books.</li>
{% endfor %}
class TermsEnforcerMiddleware:
"""Django Middleware (add to MIDDLEWARE) to enforce users to sign the terms"""
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
# only relevant for logged in users
from django.core.management.base import BaseCommand
# import ORM objects
class Command(BaseCommand):
help = 'help text'
def add_arguments(self, parser):
parser.add_argument(
'--test',
@rickdaalhuizen90
rickdaalhuizen90 / .zshrc
Created July 13, 2020 18:03
Enhance your terminal with zsh and Prezto
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
#
# Python
#
export PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv}
# Usage:
# Add to .envrc file:
# use python 3.7.5
use_python() {
# Install pyenv for management of Python versions
@gloc-mike
gloc-mike / ios.gradle
Created April 30, 2019 04:23 — forked from benasher44/ios.gradle
iOS Gradle Utilities for Generating Fat Frameworks and dSYMs
afterEvaluate {
// Create tasks for creating fat frameworks and fat dsyms for sim and device
def binaryKinds = [
// config, sim task, device task
new Tuple('Debug', linkDebugFrameworkIosSim, linkDebugFrameworkIosDevice),
new Tuple('Release', linkReleaseFrameworkIosSim, linkReleaseFrameworkIosDevice),
]
@kenyee
kenyee / migrateAndroidX.py
Created April 17, 2019 18:01
Hardened Python3 script to automatically rename classpaths for the AndroidX migration...thanks to AndiMiko for the original: https://gist.github.com/AndiMiko/58ecc04a64ac4f89eb5262176ab3fc9e
#!/usr/local/bin/python3
import sys, getopt
import glob
import csv
import os
dictCSV = "androidx-class-mapping.csv"
projectPath = os.getcwd()
@h0tk3y
h0tk3y / kotlin-variant-aware-dependencies.md
Last active March 31, 2023 11:05
Kotlin Usages of Gradle Variant-Aware Dependency Management

Kotlin Usages of Gradle Variant-Aware Dependency Management

This document is up-to-date for Kotlin release: 1.3.30.

Here is the list of all attributes used by the Kotlin Gradle plugin. The details, configuration and possible values will be listed below.

Name Type
org.gradle.usage (owned by Gradle) org.gradle.api.attributes.Usage