Skip to content

Instantly share code, notes, and snippets.

View passiomatic's full-sized avatar

Andrea Peltrin passiomatic

View GitHub Profile
@passiomatic
passiomatic / universal.css
Last active February 21, 2023 14:09
Universal CSS
/* --------------------------------------------------------------
Universal stylesheet. Based on the work of Andy Clarke et al.
License: Creative Commons CC Zero Declaration. No Rights Reserved.
More info at:
https://stuffandnonsense.co.uk/blog/universal_internet_explorer_6_css_revisited
-------------------------------------------------------------- */
@passiomatic
passiomatic / tiled.py
Created April 15, 2022 13:11
Convert a Tiled JSON level into a Levels.elm module. Only object layers are included.
#!/usr/bin/env python3
import os
import sys
import json
import struct
import base64
import io
from urllib.parse import urlparse
import itertools
from functools import partial
@passiomatic
passiomatic / SpriteSheet.elm
Created April 2, 2017 19:42
GLSL fragment shader which renders a portion of a given sprite sheet
module SpriteSheet exposing (..)
import Math.Vector2 exposing (Vec2, vec2)
import WebGL exposing (Texture, Shader)
{-|
Render a portion of a sprite sheet.
-}
fragmentSpriteSheet : Shader {} { u | spriteSheet : Texture, spriteSheetSize: Vec2, spriteSize: Vec2, index : Float } { vcoord : Vec2 }
fragmentSpriteSheet =
port module Main exposing (..)
import Html exposing (program, div, button, text, Html, Attribute)
import Html.Events as Events
import Html.Attributes as Attributes
import Dict exposing (Dict)
import Json.Decode as Json
baseUrl =
@passiomatic
passiomatic / bitfont.py
Created August 6, 2017 15:28
Convert a Bitfontmaker JSON into PNG
# -*- coding: utf-8 -*-
# Convert a Bitfontmaker JSON into PNG (requires Pillow library)
#
# See gallery:
# http://www.pentacom.jp/pentacom/bitfontmaker2/gallery/
#
# Usage:
# python bitfont.py font.json font.png
@passiomatic
passiomatic / mysqlmigrate.py
Created November 1, 2013 15:09
A quick hack to make Peewee migrator work with MySQL - Tested against MySQL 5.1.52 on OS X.
from peewee import *
from playhouse import migrate
kwargs = dict(
host = 'localhost',
user = 'root',
passwd = '' # The legendary MySQL empty password
)
_db = MySQLDatabase('test', **kwargs)
@passiomatic
passiomatic / upgrade.py
Created January 3, 2013 15:52
Quick and dirty script to create a Bikini 2.x database file from previous 1.x /pages/* files. Copy this into your Bikini 2.x installation directory and run "python upgrade.py" command. The script will look for a "pages" directory and will load the most recent revision of every page found in there.
'''
Quick and dirty script to create a Bikini 2.x database file from previous 1.x /pages/* files.
'''
import hashlib, re, codecs, glob, sqlite3
DATABASE_NAME = 'bikini.db'
ENCODING = 'utf-8'
FILENAME_MASK = u'./pages/%s%s.%s'
from bikini import storage
@passiomatic
passiomatic / index_tmpl.html
Created October 4, 2012 12:26
An somewhat old Python script file to create "Ghost Thumbnails" see: http://www.deelan.com/dev/ghost-thumbnails/. Requires Cheetah template engine and Python Imaging Library.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ghost thumbnails</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofollow" />
#gallery a {background: transparent url(.thumbnails.jpg) top left no-repeat;}
</style>
</head>