Skip to content

Instantly share code, notes, and snippets.

View slomo's full-sized avatar

Yves Müller slomo

View GitHub Profile
@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
@slomo
slomo / read-result.java
Last active December 1, 2015 14:57 — forked from miguelcardo/read-result.java
Check operation result
// handles response from the Read MIFARE Data message
post(new Route(Constants.readBlockCallbackUrl) {
@Override
public Object handle(Request request, Response response) {
JSONObject jsonParameters = (JSONObject) JSONValue.parse(request.body());
String operationId = (String) jsonParameters.get("operationId");
String sessionId = pendingOperations.get(operationId);
pendingOperations.remove(operationId);
int statusCode = ((Long)jsonParameters.get("statusCode")).intValue();
if (statusCode != HTTP_OK)
export PATH=/home/yves/repos/policycompass/nix/env/bin:/home/yves/.nix-profile/bin:/home/yves/.nix-profile/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/sbin:/sbin:~/bin:~/.scripts:`(gem env gempath | cut -d ':' -f 2 )`/bin&&\
mkdir -p var/lib/tomcat/webapps&&\
gem install --user compass&&\
./carneades/src/CarneadesWeb/scripts/build_war.sh --deploy /home/yves/repos/policycompass/var/lib/tomcat/webapps/carneades.war
Building native extensions. This could take a while...
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
/nix/store/kn475x0hqa96vxhb3f6czfpm714n80hc-ruby-1.9.3-p484/bin/ruby extconf.rb
checking for ffi_call() in -lffi... *** extconf.rb failed ***