Skip to content

Instantly share code, notes, and snippets.

View cb109's full-sized avatar
💭
🍴 🐘

Christoph Bülter cb109

💭
🍴 🐘
View GitHub Profile
@marcelrv
marcelrv / Bluez Install.txt
Created December 12, 2018 12:06
Installation Bluez 5.46 on Ubuntu 16.04
Based on https://askubuntu.com/questions/883713/using-bluez-5-43-on-ubuntu-16-04
sudo apt-get install debhelper dh-autoreconf flex bison libdbus-glib-1-dev libglib2.0-dev libcap-ng-dev libudev-dev libreadline-dev libical-dev check dh-systemd libebook1.2-dev devscripts
#unless you have already a gpg key
sudo apt-get install rng-tools
gpg --gen-key
@loranallensmith
loranallensmith / scaling-font-size.md
Last active April 12, 2021 09:30
Auto Scaling Font Size in After Effects

Auto-scaling fonts in After Effects

This Gist contains a simple expression for auto scaling the size of text layers to fit a composition based on the size of their text content. This is similar to the behavior in programs like Keynote, where the font size automatically scales down as you type more content.

How to do it

Set things up

Set up your composition and add your text layer. You'll want to get a baseline font size for things, so enter a bit of text and size it to look the way you want that amount of text to look. This is more of an art than a science, so go with your ❤️ here. 💪

Make the scale property dynamic

@denis-ryzhkov
denis-ryzhkov / patch_graphene_django_JSONField_converter.py
Last active February 24, 2021 04:34
Ask `graphene_django` to convert `JSONField` to `GenericScalar` (JSON as is) instead of default `JSONString`
from django.contrib.postgres.fields import JSONField
from graphene.types.generic import GenericScalar
from graphene.utils.str_converters import to_camel_case, to_snake_case
from graphene_django.converter import convert_django_field
def patch_graphene_django_JSONField_converter(auto_camel_case=True):
"""
Ask `graphene_django` to convert `JSONField` to `GenericScalar` (JSON as is) instead of default `JSONString`
@BARJ
BARJ / pre-commit.run-pytest.sh
Created April 16, 2018 03:56
pre-commit hook that runs pytest
#!/bin/sh
RED='\033[0;31m'
NC='\033[0m' # No Color
test_results=$(script -q /dev/null pipenv run python -m pytest ./test -v --tb=no)
if [ $? -eq 1 ]; then
printf "${RED}CANNOT COMMIT, PYTEST FAILED\n\nPYTEST RESULTS:\n"
echo "$test_results"
exit 1
fi
@nikhilkumarsingh
nikhilkumarsingh / paint.py
Created November 3, 2017 16:26
A simple paint application using tkinter in Python 3
from tkinter import *
from tkinter.colorchooser import askcolor
class Paint(object):
DEFAULT_PEN_SIZE = 5.0
DEFAULT_COLOR = 'black'
def __init__(self):
@jperelli
jperelli / conditional_orderby.py
Last active January 26, 2024 11:56
Conditional order by in django's ORM
"""
Some table has two Date fields: expiredate and SALexpiredate
Both fields can be null
when SALexpiredate is not null, overrides expiredate
when ordering:
if SALexpiredate is not null, that field needs to be used
otherwise fallback to use expiredate
"""
from django.db.models import DateField, Case, When, F
@kampta
kampta / simpleBool.py
Created September 28, 2016 14:58
Code to evaluate simple boolean logic in python using pyparsing
#
# simpleBool.py
#
# Example of defining a boolean logic parser using
# the operatorGrammar helper method in pyparsing.
#
# In this example, parse actions associated with each
# operator expression will "compile" the expression
# into BoolXXX class instances, which can then
# later be evaluated for their boolean value.
@rjz
rjz / ngrok_hostname.sh
Created August 9, 2016 16:20
Get ngrok hostname from command line
#!/bin/sh
# ngrok's web interface is HTML, but configuration is bootstrapped as a JSON
# string. We can hack out the forwarded hostname by extracting the next
# `*.ngrok.io` string from the JSON
#
# Brittle as all get out--YMMV. If you're still reading, usage is:
#
# $ ./ngrok_hostname.sh <proto> <addr>
#
@yang-wei
yang-wei / destructuring.md
Last active February 20, 2024 04:40
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent