Skip to content

Instantly share code, notes, and snippets.

@beryllium
beryllium / Doc.md
Created November 11, 2022 21:35
Sculpin article excerpts

Sculpin Article Excerpts

The Breakaway

This method uses a special string, <!-- break -->, to denote a breakpoint in index.html:

{# Split the post into an array using explode().
   Because we provide a length of 2, the "rest"
 of the post will be stored in the second array
@beryllium
beryllium / tiles.md
Created May 3, 2019 16:55 — forked from veltman/tiles.md
Making a big image zoomable

Making a big image zoomable

When you have a giant image and you want to make it easy to pan and zoom without downloading the whole 50MB image into someone's browser, a nice workaround is to cut that image into tiles at different zoom levels and view it as it were a map. An example where I've used this technique is The "Snowpiercer" Scenario.

One way to cut your big image into the requisite tiles is with gdal2tiles.py.

Alternatively, this Node script will do the cutting after you install node-canvas and mkdirp:

const fs = require("fs"),
@beryllium
beryllium / LegacyRedirector.php
Last active December 10, 2018 16:47
Legacy Redirector for Sculpin 3
<?php
namespace Beryllium\Whateverthing;
use Sculpin\Core\Event\SourceSetEvent;
use Sculpin\Core\Output\FilesystemWriter;
use Sculpin\Core\Output\OutputInterface;
use Sculpin\Core\Permalink\Permalink;
use Sculpin\Core\Permalink\PermalinkInterface;
use Sculpin\Core\Sculpin;

Sculpin on Windows

Pre-Requisites

You'll need to have:

  • PHP 7.2 installed and configured in your path (so you can run php just by typing "php").
    • You'll probably need a few extensions enabled, like curl and openssl and maybe mbstring and a few others.
  • Git installed and configured in your path (so composer can use it).
  • Composer installed and (ideally) configured with a DOSKEY alias (so it's most useful for you! :) )
@beryllium
beryllium / macros.html.twig
Created March 11, 2018 01:23
Time-Ago Twig Macro
{# Based on this StackOverflow example: https://stackoverflow.com/a/26311354/1272059 #}
{% macro time_ago(timestamp) %}
{% set lapse = date().getTimestamp() - timestamp %}
{% set units = {
'year': 31536000,
'month': 2592000,
'week': 604800,
'day': 86400,
'hour': 3600,
@beryllium
beryllium / showcerts.sh
Created January 19, 2018 19:06
showcerts
#!/bin/sh
# Grab the certificate and parse out some info
# Usage:
# showcerts whateverthing.com
echo | openssl s_client -showcerts -connect "${1}:443" -servername "$1" | openssl x509 -text
@beryllium
beryllium / quick-slugify.sh
Last active December 7, 2016 07:54 — forked from oneohthree/quick-slugify.sh
Quick bash slugify
# Updated to work on OS X (convert both "-E" flags to "-r" to run on real server OSes)
echo "$STRING" | iconv -t ascii//TRANSLIT | sed -E s/[^a-zA-Z0-9]+/-/g | sed -E s/^-+\|-+$//g | tr A-Z a-z
@beryllium
beryllium / index.html.twig
Created September 29, 2014 16:49
Breakpoints in Sculpin
...
<div>
{# Split the post into an array using explode().
Because we provide a length of 2, the remainder
of the post will be stored in the second array
element, even if there are multiple breakpoints. #}
{% set break_array =
post.blocks.content|split('<!-- break -->', 2) %}
{# Output the first element of the array in raw mode #}
@beryllium
beryllium / components.md
Created June 12, 2014 21:10
Zero-Dependency Symfony Components

Zero-Dependency Symfony Components

These components have zero dependencies. They all require PHP > 5.3.3, but they can be integrated into projects without pulling in surprise dependencies. Some of them might not be terribly useful without a good binding component (e.g., DomCrawler and CSSSelector work best when using BrowserKit).

@beryllium
beryllium / Night..lrtemplate
Created May 16, 2014 20:00
Lightroom? More like Nightroom!
s = {
id = "3E89CB4C-C61A-4F25-B40C-37824BF89EA4",
internalName = "Night.",
title = "Night.",
type = "Develop",
value = {
settings = {
AutoLateralCA = 0,
Blacks2012 = 0,
BlueHue = 0,