Skip to content

Instantly share code, notes, and snippets.

@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>
@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/
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 2, 2024 15:59
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 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):
@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:
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"
@hunterbridges
hunterbridges / twitch_irc.md
Last active May 1, 2024 11:39
How to connect to Twitch with an IRC client (As of Oct 2015)

HOWTO

Connect to Twitch.tv chat with an IRC client

  1. Visit this website and get an OAuth Token for your Twitch account.
  2. Add a server to your IRC client with this configuration, using your OAuth Token as the server password. Make sure it is not using SSL.
{
  address = "irc.twitch.tv";
chatnet = "Twitch";
@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