Skip to content

Instantly share code, notes, and snippets.

@joetsoi
joetsoi / charfield_unlimited.py
Created August 1, 2019 16:37
Unlimited input for django admin with single line input widget
import sys
from django.db.models import CharField
class CharFieldUnlimited(CharField):
"""Postgres specific varchar field
Use this over models.TextField when you want a one line input in the django
admin instead of the multi-line TextArea input widget.
Using this field gives you unlimited length CharFields, whilst still using
@joetsoi
joetsoi / imgsorter.py
Last active August 11, 2017 01:56
imgsorter
import os
import sys
import glob
import pygame
scale_factor = 4
@joetsoi
joetsoi / neopixel.py
Last active December 23, 2016 10:41
neopixel
from random import randint
from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0, 512)
# Merry Christmas
@joetsoi
joetsoi / auto.html
Last active September 29, 2015 12:46
ckan api jquery example
<html>
<body>
<div class="search">
<input type="text" id="search-box" placeholder="Dataset" />
<div id="matches"></div>
</div>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="dataset.js"></script>
</body>
</html>
@joetsoi
joetsoi / package_item.html
Last active August 29, 2015 14:21
snippet/package_item.html
{% ckan_extends %}
{% block heading_meta %}
{% if package.get('state', '').startswith('draft') %}
<span class="label label-info">{{ _('Draft') }}</span>
{% elif package.get('state', '').startswith('deleted') %}
<span class="label label-important">{{ _('Deleted') }}</span>
{% endif %}
( {{ h.link_to(h.truncate(package.organization.title, truncate_title), h.url_for(controller='organization', action='read', id=package.organization.name)) }} )
@joetsoi
joetsoi / schema.xml
Created May 21, 2015 23:13
ckan 2.3 schema with solr
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@joetsoi
joetsoi / licences.json
Last active August 29, 2015 14:19
license.json + is_okd_compliant:true to everyfield
[
{
"is_osi_compliant": false,
"od_conformance": "not reviewed",
"maintainer": "",
"is_generic": true,
"id": "notspecified",
"family": "",
"is_okd_compliant": false,
"url": "",
@joetsoi
joetsoi / init.lua
Last active January 21, 2020 01:03
Simple trouble in terrorist town hack that adds new variable ttt_traitor_pct_max . Each round, the percentage of traitors is random between the range ttt_traitor_pct and ttt_traitor_pct_max. Defaults to 0.5. Replace GarrysMod\garrysmod\gamemodes\terrortown\gamemode\init.lua with this file. (e.g C:\Program Files (x86)\Steam\steamapps\common\Garry…
---- Trouble in Terrorist Town
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_hud.lua")
AddCSLuaFile("cl_msgstack.lua")
AddCSLuaFile("cl_hudpickup.lua")
AddCSLuaFile("cl_keys.lua")
AddCSLuaFile("cl_wepswitch.lua")
AddCSLuaFile("cl_awards.lua")
@joetsoi
joetsoi / sample.py
Created September 22, 2011 15:36
functional programming python
from itertools import takewhile, dropwhile
from functools import partial
#... some other imports
def some_table(context, series, format_string):
table_options = format_string.split()
is_same_date = lambda date, i: i.datestamp > date
is_same_week = partial(is_same_date, context['date'] - timedelta(weeks=1))