Skip to content

Instantly share code, notes, and snippets.

View jpic's full-sized avatar
💾
Searching for my Monkey Island II floppy disks

Yacht Shaver jpic

💾
Searching for my Monkey Island II floppy disks
View GitHub Profile
@jpic
jpic / make_busybox
Created June 24, 2016 11:08
Creating a busybox image for lxd

image=$1
if [ -f $image ]; then
exit 0
fi
path=$(mktemp --directory lxdapi.busybox.XXXXXXXX)
arch=$(uname --machine)
@jpic
jpic / output.txt
Created June 17, 2016 15:33
issue with newline
[env] 17/06 2016 17:29:30 jpic@lue ~
$ ansible-playbook test.yml
[WARNING]: Host file not found: /etc/ansible/hosts
[WARNING]: provided hosts list is empty, only localhost is available
PLAY [localhost] ***************************************************************
TASK [setup] *******************************************************************
[[runners]]
name = "jpic"
url = "https://gitlab.com/ci"
token = "redacted"
executor = "docker"
[runners.docker]
tls_verify = false
image = "jpic/ansible-git:jessie"
@jpic
jpic / iptables
Created May 10, 2016 15:13
Logdrop iptable
# Generated by iptables-save v1.4.21 on Tue May 10 17:03:12 2016
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [1228037347:3674412776210]
:LOGDROP - [0:0]
:TCP - [0:0]
:UDP - [0:0]
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
#!/bin/bash
light=off
while true; do
if hcitool scan | grep 'iPhone de Micka'; then
if [ $light = off ]; then
echo 'allumer la lampe'
light=on
fi
class TestApp(AppConfig):
name = 'select2_one_to_one'
def ready(self):
model = self.get_model('TestModel')
# Perhaps that's the kind of nice place to override this kind of things
model._meta.get_field('test').formfield_defaults['widget'] = forms.RadioSelect
# django-autocomplete-light users would execute something like:
model._meta.get_field('test').formfield_defaults['widget'] = autocomplete.Select2(url='my_autocomplete_url')
@jpic
jpic / human_log.py
Last active March 25, 2016 17:55 — forked from cliffano/human_log.py
A version i use, posted here to comply with the license
# upstream: https://gist.github.com/cliffano/9868180
# Dunno if it still shares a single line with the original, but still i think the license forces me to post it. So here it is, my F****ING AWESOME CLASSY DEFAULT OUTPUTTER OVERRIDE !!
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
class ModelChoiceModelField(ModelChoiceField):
def value_from_object(self, instance, name):
return getattr(instance, name)
def save_form_data(self, instance, name, value):
setattr(instance, name, value)
@jpic
jpic / after.py
Last active February 1, 2016 22:11
form_business
class GFKFormBusiness(object):
def value_from_object(self, instance, name):
return getattr(instance, name)
def save_form_data(self, instance, name, value):
setattr(instance, name, value)
class TestForm(forms.ModelForm):
test = autocomplete.QuerySetSequenceModelField(
"""
ModelForm mixin that supports virtual fields, ie. GenericForeignKey.
By default, Django's ModelForm will not update the instance's virtual fields
even if a matching form field was given to the form. For example::
class YourForm(forms.ModelForm):
gfk_name = SomeField()
instance = YourModel.objects.get(pk=4)
# Django doesn't populate virtual fields by default, compensate manually:
initial = {'gfk_name': instance.gfk_name}
# Use the form as usual