Skip to content

Instantly share code, notes, and snippets.

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

Friedrich Delgado TauPan

🏠
Working from home
View GitHub Profile
(setq weechat-timestamp-regex
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)?[[:blank:]]?\\([0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")
(setq weechat-timestamp-prefix-regex
(format "^[[:blank:]]*%s"
weechat-timestamp-regex))
(setq weechat-info-line-regex
(format "%s[[:blank:]]+\\(<?-->?\\)[[:blank:]]+\\(.+\\)"
weechat-timestamp-prefix-regex))
(setq weechat-msg-line-regex
(format "%s[[:blank:]]+\\([^[:blank:]]+\\)[[:blank:]]+\\(.+\\)"
@prudnikov
prudnikov / atomic_viewsets.py
Created December 17, 2019 09:55
Django Rest Framework Atomic ViewSet and Mixin.
from django.db import transaction
from rest_framework import mixins
from rest_framework.viewsets import GenericViewSet
__all__ = ['AtomicCreateModelMixin', 'AtomicUpdateModelMixin', 'AtomicDestroyModelMixin',
'AtomicModelViewSetMixin', 'AtomicModelViewSet']
class AtomicCreateModelMixin(mixins.CreateModelMixin):
@sk22
sk22 / lastfm-remove-duplicates.js
Last active January 13, 2024 16:26
Last.fm duplicate scrobble deleter
var elements = Array.from(document.querySelectorAll('.js-link-block'))
elements.map(function (element) {
var nameElement = element.querySelector('.chartlist-name')
return nameElement && nameElement.textContent.replace(/\s+/g, ' ').trim()
}).forEach(function (name, i, names) {
if (name !== names[i + 1]) return
var deleteButton = elements[i].querySelector('[data-ajax-form-sets-state="deleted"]')
if (deleteButton) deleteButton.click()
location.reload()
})
@tomgross
tomgross / check_coverage.py
Last active April 10, 2019 14:33
Check the coverage of Python tests and compare with previous run in gitlab
# This script checks the coverage and test if it keeps at least the same
# Add this to your .gitlab-ci.yml
#
# coveragetest:
# ...
# cache:
# paths:
# - coverage_value.txt
# script:
# - bin/coverage run bin/test
@TauPan
TauPan / config.py
Last active February 7, 2024 20:31
My current qtile config
# -*- coding: utf-8 -*-
import distutils.spawn
import os
import re
import socket
import subprocess
import xcffib.xproto
from libqtile import layout, bar, widget, hook
from libqtile.command import lazy
@fabiosussetto
fabiosussetto / gist:c534d84cbbf7ab60b025
Last active December 2, 2023 01:11
Enable Django toolbar for JSON responses
class NonHtmlDebugToolbarMiddleware(object):
"""
The Django Debug Toolbar usually only works for views that return HTML.
This middleware wraps any JSON response in HTML if the request
has a 'debug' query parameter (e.g. http://localhost/foo?debug)
"""
@staticmethod
def process_response(request, response):
if request.GET.get('debug'):
@svenfuchs
svenfuchs / gist:2063855
Created March 17, 2012 18:27
Developing with dependent local gem repositories

When developing an application where you have split out shared functionality to multiple dependent gem repositories can get cumbersome when you

  • need to edit the Gemfile in order to swap local :path sources with :git or just plain Rubygems sources,
  • then forget to bundle update,
  • wonder why your git repository is dirty and it's just the modified Gemfile and Gemfile.lock,
  • accidentally commit the Gemfile.lock with local :path sources bundled etc. etc.

So what about this strategy:

A. Create a file .Gemfile.local containing:

@TauPan
TauPan / s-bahn-hamburg.scm
Created July 26, 2011 11:51
Beginnings of a prototype scraper in racket for s-bahn-hamburg.de
#!/usr/bin/env racket
#lang scheme/base
;; downloading and compiling those requires will take ages, but only
;; for the first time!
(require srfi/1
srfi/13
net/url
(planet bzlib/http:1:0)
(planet neil/htmlprag:1:6)
;; (except-in (planet lizorkin/ssax:2:0/ssax)
@TauPan
TauPan / gitediff
Created July 25, 2011 12:27
Viewing differences in git with emacs-ediff
#!/bin/sh
# adapted from http://technotales.wordpress.com/2009/05/17/git-diff-with-vimdiff/
if [ -n "${GIT_EXTERNAL_DIFF}" ]; then
[ "${GIT_EXTERNAL_DIFF}" = "${0}" ] ||
{ echo "GIT_EXTERNAL_DIFF set to unexpected value" 1>&2; exit 1; }
exec emacsclient --eval "(ediff \"$2\" \"$5\")"
else
GIT_EXTERNAL_DIFF="${0}" exec git --no-pager diff "$@"
@TauPan
TauPan / xmms2continue.sh
Created July 20, 2011 09:52
extremely dirty first shell version of xmms2continue
#!/bin/bash
searchterm=$(echo $(curl http://ws.audioscrobbler.com/1.0/user/TauPan/recenttracks.rss|grep -A1 item|grep title|head -1|sed -e 's/<title>\(.*\)<\/title>/\1/'|tr -dc \ A-z0-9))
artist=$(echo $(xmms2 search $searchterm -l artist|tail -2|head -1))
album=$(echo $(xmms2 search $searchterm -l album|tail -2|head -1))
title=$(echo $(xmms2 search $searchterm -l title|tail -2|head -1))
xmms2 stop
xmms2 clear
xmms2 add artist:"$artist" album:"$album" -o "artist date tracknr"
xmms2 jump $title
xmms2 play