Skip to content

Instantly share code, notes, and snippets.

View sajoku's full-sized avatar
🏠
Working from home

Sander sajoku

🏠
Working from home
View GitHub Profile
@sajoku
sajoku / SoundParser.rb
Created May 15, 2020 08:48 — forked from davidcornu/SoundParser.rb
Convert MP3 Files to Waveform Images in Ruby
# --------------------------------------------------------------------
# Create SoundCloud-style waveforms from mp3 files
# Author: David Cornu
# Credit for the idea goes to http://cl.ly/292t2B09022I3S3X3N2O
#
# Requirements:
# mpg123 - [ % brew install mpg123 ]
# imagemagick - [ % brew install imagemagick ]
# rmagick - [ % brew install rmagick ]
#

The Problem

wkhtmltopdf is broken and cannot render multiple fonts because of some issues around names. See wkhtmltopdf/wkhtmltopdf#2435

Workaround

  1. Pick an 8 or less char name for each font and variation e.g. HelvBold, HelvLite, TimeReg
  2. Every variation needs to be a separate font file, with all the details renamed in Font Forge using the short name determined before.
  3. Give the font files the same short name (e.g. HelvBold.ttf)
@sajoku
sajoku / docker-compose.yml
Created July 11, 2019 14:41 — forked from agarzon/docker-compose.yml
My docker-compose.yml for development
gitlab:
image: 'gitlab/gitlab-ce:latest'
container_name: gitlab
restart: always
hostname: 'gitlab.mcu.dc'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.mcu.dc:8090'
gitlab_rails['gitlab_shell_ssh_port'] = 2290
gitlab_rails['smtp_enable'] = true
@sajoku
sajoku / pipenv_install.sh
Created April 24, 2019 17:18
Pipenv install offline
# pipenv allows us to install packages straight from source but only
# when providing a location to the wheel
#pipenv install file:///home/packages/packages/aioredis-1.2.0-py3-none-any.whl
packages_directory='/home/packages/packages/'
packages=(aioredis asgiref asn1crypto async-timeout attrs autobahn automat cffi channels-redis channels constantly cryptography daphne django-redis django-reversion django-webpack-loader django h2 hiredis hpack hyperframe hyperlink idna incremental msgpack priority psycopg2-binary psycopg2 py-moneyed pyasn1-modules pyasn1 pycparser pyhamcrest pyopenssl pytz redis restless selenium service-identity six sqlparse twisted[http2,tls] txaio urllib3 uwsgi whitenoise zope.interface)
for package in ${packages[@]}
do
package_location=$(find "$packages_directory" -print | grep -i "$package")
echo "Found package: $package in location: $package_location"
@sajoku
sajoku / .vimrc
Created March 5, 2019 09:57
Local vimrc to run rails test inside docker
"Sometimes I want to run stuff in a docker-container like rails tests. With this local .vimrc that's configurable per project
" This 'overrides' the rails executable command and replaces it with docker-compose.
" Drawback is that it takes a bit of time to run docker
let g:test#ruby#rails#executable = 'docker-compose run web bin/rails test'
@sajoku
sajoku / base_set.py
Created November 27, 2018 12:07
Immediate evaluation of a QuerySet vs lazy
# This way executes two queries because if not evaluates the base_set argument
def execute_query(base_set=None):
if not base_set: # Eecutes the queryset thrown in
base_set = YourObject.objects
base_set.filter(pk=1) #this is where the queryset should be executed
# Checking with is None does not evaulate the given base_set
def execute_query(base_set=None):
if base_set is None: # Does not execute the given queryset.
@sajoku
sajoku / readme.md
Created October 19, 2018 07:04
Roomy bootstrap 4 table with border spacing

This creates a roomy table with borders around it. The important stuff here is the border-spacing and border-collapse. border-collaps: 0px 5px; -> 0px means the spacing between the cells (left and right), 5px is the spacing between the rows.

@sajoku
sajoku / active_tag.py
Created February 16, 2018 13:30 — forked from mnazim/active_tag.py
(Django) A simple template tag to add an 'active' class to anchor tags
from django import template
from django.core.urlresolvers import reverse
register = template.Library()
@register.simple_tag
def add_active(request, name, by_path=False):
""" Return the string 'active' current request.path is same as name
Keyword aruguments:
@sajoku
sajoku / forms.py
Created February 9, 2018 07:49 — forked from neara/forms.py
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@sajoku
sajoku / nginx.conf
Created November 15, 2017 19:20 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048