Skip to content

Instantly share code, notes, and snippets.

View slomo's full-sized avatar

Yves Müller slomo

View GitHub Profile
@slomo
slomo / pacicron.sh
Created January 31, 2012 13:27
apticron for arch
#!/bin/bash
# copy this file to /usr/local/sbin (or any other $PATH location)
# add to daily.cron
VAR_FILE="/var/lib/pacicron/sha"
MAIL_TO="root"
HOST=$(uname -n)
if [[ ! -f ${VAR_FILE} ]]; then
echo "${VAR_FILE} doesn't exits. Therefore creating."
@slomo
slomo / mailprint.py
Created January 12, 2012 10:59
A script to print a mail delivered on stdin
#!/usr/bin/env python
# could be added to .forward with "|$PATH/mailprint.py"
import sys
import email.feedparser as mailparser
"""
TODO
====
* add quota
@slomo
slomo / SeekableBlobByteChannel.java
Created June 19, 2019 20:50
SeekableFileChannel from Azure Blob Storage
package default;
import com.microsoft.azure.storage.blob.BlobRange;
import com.microsoft.azure.storage.blob.BlockBlobURL;
import com.microsoft.azure.storage.blob.DownloadResponse;
import com.microsoft.azure.storage.blob.ReliableDownloadOptions;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;
@slomo
slomo / a4phases.py
Last active August 29, 2017 08:06
What my ideal phases.py should look like
from adhcoracy4.phases import register_module, ModuleType, PhaseType
from .models import MyModel
from .views import MyDashBoardView, MyCollectView
Collect(PhaseType):
description = _('Human readable phase name')
view = MyCollectView
features = {
'crud': (MyModel, 'myapp_name.MyOtherModel') # model as class or django style model string
@property
def idea_topics_names(self):
choices = dict(IDEA_TOPIC_CHOICES)
return [ choices[topic] for topic in self.idea_topics ]
if action = "create":
project = instance.project
if 'action_target' in instance._meta.action_target:
action.target = getattr(instance, instance._meta.action_target)
if 'content_object' in instance:
action.traget = instance.content_object
if 'module' in instance:
action.target = instance.module
from adhcoracy4.maps.models import AreaSettings
SETTINGS_WIDGETS = {
AreaSettings: {
'polygon': MapChoosePolygonPresets
}
}
def get_module_settings_form(settings_instance_or_modelref):
class Idea(module_models.Item):
slug = models.SlugField(max_length=512, unique=True)
name = models.CharField(max_length=512)
description = models.TextField()
image = models.ImageField(upload_to='ideas/images', blank=True,
validators=[validators.validate_hero_image])
def __str__(self):
return self.name
# projects/mixins.py
class ProjectMixin():
def get_project(self):
pass
def get_context_data(self, **kwargs):
kwargs['project'] = self.get_project()
return super().get_context_data(**kwargs)
# process/__init__.py
class BasePhasePermissions():
can_edit = False
can_delete = False
# idea_collection/phases.py
from . import process
class PhasePermissions(process.BasePhasePermissions):
can_edit = True