Skip to content

Instantly share code, notes, and snippets.

View cyberdelia's full-sized avatar

Timothée Peignier cyberdelia

View GitHub Profile
cyberdelia / Consumer.kt
Created October 21, 2020 23:29
Kafka + Kotlin + Coroutines
package com.lapanthere.bohemia
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import org.apache.kafka.clients.consumer.ConsumerRecord
import org.apache.kafka.clients.consumer.KafkaConsumer
import java.time.Duration
fun <K, V> KafkaConsumer<K, V>.asFlow(timeout: Duration = Duration.ofMillis(500)): Flow<ConsumerRecord<K, V>> =
cyberdelia /
Last active March 23, 2023 23:03
Secure Agent — Authentication agent using the Secure Enclave
secure-agent --generate-completion-script fish
secure-agent --generate-completion-script bash
secure-agent --generate-completion-script zsh
cyberdelia /
Created September 21, 2011 08:26
Django class based view mixins
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.utils.cache import patch_response_headers
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page, never_cache
from django.views.decorators.csrf import csrf_exempt
class NeverCacheMixin(object):
cyberdelia /
Created April 3, 2010 14:05
Fabric deploy script with : south migrations, rollback and maintenance page.
from fabric.api import env, run, sudo, local, put
def production():
"""Defines production environment"""
env.user = "deploy"
env.hosts = ['',]
env.base_dir = "/var/www"
env.app_name = "app"
env.domain_name = ""
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name }
cyberdelia /
Created April 2, 2010 13:11
Set cache-control headers for a s3 public bucket
#!/usr/bin/env python
# encoding: utf-8
from boto.s3.connection import S3Connection
AWS_ACCESS_KEY = '<aws access key>'
AWS_SECRET_KEY = '<aws secret key>'
AWS_BUCKET_NAME = '<aws bucket name>'
cyberdelia /
Created November 1, 2009 18:05
Find every available domain from a dictionary
#!/usr/bin/env python
# encoding: utf-8
import sys, json, urllib
from optparse import OptionParser
def main():
parser = OptionParser()
parser.add_option("-e", "--extension", action="append", type="string", dest="extensions", help="specify domain extension", default=[])
parser.add_option("-a", "--availability", action="store", type="choice", choices=["taken", "maybe", "available", "unavailable", "tld"], dest="availability", help="specifiy level of availability", default="available")