Skip to content

Instantly share code, notes, and snippets.

@michaelgodshall
michaelgodshall / ABOUT
Created February 8, 2012 19:48 — forked from Skirmantas/ABOUT
Username maxlength hack for ``django.contrib.auth``
This code is a suggested answer to question asked on Stackoverflow:
http://stackoverflow.com/questions/4827965/can-i-change-djangos-auth-user-username-field-to-be-100-chars-long-without-break/
function string_ends(text, ends)
return ends == "" or string.sub(text, -string.len(ends)) == ends
end
function vlc_format(filename)
-- https://wiki.videolan.org/VLC_Features_Formats#Format.2FContainer.2FMuxers
local formats = {
"3gp", "asf", "wmv", "au", "avi", "mka", "mkv", "flv", "mov", "mp4",
"ogg", "ogm", "ts", "mpg", "mp3", "mp2", "msc", "msv", "nut", "ra",
@bacher09
bacher09 / aliases.sh
Last active February 5, 2017 13:58
Useful aliases
myip() {
curl -4 "http://icanhazip.com/"
}
myip6() {
curl -6 "http://icanhazip.com/"
}
reverse_ipv4() {
local ip="$1"
@ahankinson
ahankinson / generics.py
Created December 14, 2012 03:57
PATCH support for Django REST Framework. The Django Rest Framework (http://django-rest-framework.org/api-guide/serializers.html) does not provide support for the PATCH HTTP method. These two overridden classes will allow you to mix-in support for PATCH. Place these in your Django webapp and import them as needed. I've kept the same DRF file name…
from rest_framework import mixins
from rest_framework.generics import SingleObjectAPIView
from yourapp.mixins import PartialUpdateModelMixin
class RetrievePartialUpdateDestroyAPIView(PartialUpdateModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
SingleObjectAPIView):
@rodlie
rodlie / airwave64.sh
Last active September 21, 2021 16:12
Build and install Airwave64 on Ubuntu Bionic (https://youtu.be/p93Fj3I3t9I)
#!/bin/sh
# Build and install Airwave64
# https://github.com/rodlie - <ole.andre.rodlie@gmail.com>
#
CWD=`pwd`
AIRWAVE_GIT="https://github.com/phantom-code/airwave"
AIRWAVE_COMMIT="8cd3507a46c2f7809a2ef8481cbded7dcbbae8ff"
VST_V="369_01_03_2018_build_132"
@willprice
willprice / .travis.yml
Last active August 15, 2023 17:12
How to set up TravisCI for projects that push back to github
# Ruby is our language as asciidoctor is a ruby gem.
lang: ruby
before_install:
- sudo apt-get install pandoc
- gem install asciidoctor
script:
- make
after_success:
- .travis/push.sh
env:
@zbyte64
zbyte64 / async_app.py
Created May 26, 2016 20:47
Asyncio Views With Django
import asyncio
from django import http
from django.core.urlresolvers import set_script_prefix
from django.utils.encoding import force_str
from django.core.handlers.wsgi import get_script_name
from django_wsgi.handler import DjangoApplication
import logging
import logging
import sys
@alexxxnf
alexxxnf / sqla_regex.py
Last active February 18, 2024 15:36 — forked from Xion/sqla_regex.py
Regular expression filters in SQLAlchemy
"""
Module implementing an enhanced string column type for SQLAlchemy
with a support for regular expression operators in Postgres and SQLite.
"""
import re
from sqlalchemy import String as _String, Text as _Text, Unicode as _Unicode, UnicodeText as _UnicodeText, event, exc
from sqlalchemy.engine import Engine
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import BinaryExpression, func, literal
@jeetsukumaran
jeetsukumaran / custom_iterator.cpp
Created February 18, 2010 02:33
Sample C++/STL custom iterator
// Sample custom iterator.
// By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558)
// From: http://www.dreamincode.net/forums/index.php?showtopic=58468
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>