Skip to content

Instantly share code, notes, and snippets.

Avatar

Harro van der Klauw hvdklauw

View GitHub Profile
@hvdklauw
hvdklauw / custom-table.blade.php
Created Aug 7, 2018
Custom Backpack table field that posts an actual array.
View custom-table.blade.php
<!-- 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 Sep 23, 2016
Pretty print github issue json.
View issues.py
# 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 Nov 18, 2014
Crash log ender io light
View crash-log
---- 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)
View test_permissions.py
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 Aug 29, 2015
Keybase verification
View keybase.md

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:

View config.fish
# 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 ''
View gist:1017471
class RelatedField(object):
def __init__(self, *args, **kwargs):
sup = super(RelatedField, self)
if hasattr(sup, 'test'):
sup.test()
class Field(object):
def test(self):
View gist:1016394
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 Jun 1, 2011
Quick WizardAdmin to get it in the add_view, needs more admin-like-styling for the admin
View admin__wizard_form.html
{% 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>
View gist:719942
{% 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 %}