Skip to content

Instantly share code, notes, and snippets.

View hvdklauw's full-sized avatar
🏠
Working from home (mostly)

Harro van der Klauw hvdklauw

🏠
Working from home (mostly)
View GitHub Profile
@hvdklauw
hvdklauw / custom-table.blade.php
Created August 7, 2018 14:54
Custom Backpack table field that posts an actual array.
<!-- array input -->
<?php
$max = isset($field['max']) && (int) $field['max'] > 0 ? $field['max'] : -1;
$min = isset($field['min']) && (int) $field['min'] > 0 ? $field['min'] : -1;
$item_name = strtolower(isset($field['entity_singular']) && !empty($field['entity_singular']) ? $field['entity_singular'] : $field['label']);
$items = old($field['name']) ? (old($field['name'])) : (isset($field['value']) ? ($field['value']) : (isset($field['default']) ? ($field['default']) : '' ));
// make sure not matter the attribute casting
@hvdklauw
hvdklauw / issues.py
Last active September 23, 2016 12:58
Pretty print github issue json.
# curl --header "X-GitHub-OTP: <code>" -u "<username>" https://api.github.com/repos/StriatumVentures/ZUPR/issues\?milestone\=1\&state\=open > issues.json
import json
with open("issues.json") as of:
data = json.load(of)
for issue in data:
t = issue['title']
n = issue['number']
@hvdklauw
hvdklauw / crash-log
Created November 18, 2014 16:52
Crash log ender io light
---- Minecraft Crash Report ----
// Why did you do that?
Time: 11/18/14 5:50 PM
Description: Ticking block entity
java.lang.NullPointerException: Ticking block entity
at crazypants.enderio.machine.light.TileElectricLight.findNearestCharger(TileElectricLight.java:167)
at crazypants.enderio.machine.light.TileElectricLight.func_145845_h(TileElectricLight.java:151)
at net.minecraft.world.World.func_72939_s(World.java:1939)
import pytest
from flaskbb.user.models import User
from flaskbb.forum.models import Forum, Category
@pytest.fixture
def category(database):
category = Category(title="Test Category")
category.save()
@hvdklauw
hvdklauw / keybase.md
Last active August 29, 2015 13:57
Keybase verification

Keybase proof

I hereby claim:

  • I am hvdklauw on github.
  • I am hvdklauw (https://keybase.io/hvdklauw) on keybase.
  • I have a public key whose fingerprint is E86C ACF2 880C 35B0 65D1 432E B022 99FA DAF8 24DD

To claim this, I am signing this object:

# Fish git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
set __fish_git_prompt_showupstream 'yes'
set __fish_git_prompt_color_branch yellow
set __fish_git_prompt_showuntrackedfiles 'yes'
# Status Chars
set __fish_git_prompt_char_dirtystate '⚡'
set __fish_git_prompt_char_stagedstate '→'
@hvdklauw
hvdklauw / gist:1017471
Created June 9, 2011 19:12
MRO powerrrr
class RelatedField(object):
def __init__(self, *args, **kwargs):
sup = super(RelatedField, self)
if hasattr(sup, 'test'):
sup.test()
class Field(object):
def test(self):
@hvdklauw
hvdklauw / gist:1016394
Created June 9, 2011 09:09
Formwizard diff
Index: django/contrib/formtools/wizard/views.py
===================================================================
--- django/contrib/formtools/wizard/views.py (revision 16341)
+++ django/contrib/formtools/wizard/views.py (working copy)
@@ -96,6 +96,7 @@
instance_dict = None
condition_dict = None
template_name = 'formtools/wizard/wizard_form.html'
+ extra_context = None
@hvdklauw
hvdklauw / admin__wizard_form.html
Created June 1, 2011 18:46
Quick WizardAdmin to get it in the add_view, needs more admin-like-styling for the admin
{% extends 'admin/change_form.html' %}
{% load i18n %}
{% block content %}
<div id="content-main">
<p>Step {{ wizard.steps.current }} of {{ wizard.steps.count }}</p>
<form action="." method="post">{% csrf_token %}
<table>
@hvdklauw
hvdklauw / gist:719942
Created November 29, 2010 13:23
KISS?
{% thumbnail candidate.picture "60x40" as im %}
<img class="quickProfilePicture" alt="{{ candidate.full_name }}" src="{{ im.url }}" style="margin:{{ im|margin:"60x40" }}" width="{{ im.x }}" height="{{ im.y }}" />
{% empty %}
{% thumbnail "defaults/pol-dummy.jpg" "60x40" as im %}
<img class="quickProfilePicture" alt="{{ candidate.full_name }}" src="{{ im.url }}" style="margin:{{ im|margin:"60x40" }}" width="{{ im.x }}" height="{{ im.y }}" />
{% endthumbnail %}
{% endthumbnail %}