Skip to content

Instantly share code, notes, and snippets.

@su-narthur
su-narthur / minify-middleware.php
Created October 18, 2016 18:52 — forked from frugan-dev/middleware.php
Silex minify HTML middleware
<?php
$app->after(function (\Symfony\Component\HttpFoundation\Request $request, \Symfony\Component\HttpFoundation\Response $response) use ($app) {
if ($app['debug']) return;
$search = array(
'#\/\*.+?\*\/#', // /* JS Comments */
'#^\s+\/\/.+#m', // // JS Comments
'/<!--.+?-->/', // <!-- HTML Comments -->
'/\n/',
@su-narthur
su-narthur / svg-extract.py
Last active May 9, 2022 13:29
Convert SVG font to individual SVG files
# http://helpfulsheep.com/2015-03-25-converting-svg-fonts-to-svg/
import sys, re
if len(sys.argv) < 2:
print 'Usage: python {} webfont-file.svg'.format(sys.argv[0])
sys.exit()
with open(sys.argv[1], 'r') as r:
lines = r.read().split('\n')
glyphs = [x for x in lines if '<glyph' in x]
@su-narthur
su-narthur / caniuse_updates.md
Last active August 10, 2017 14:29
Get a caniuse update weekly
$ npm install -g caniuse-cmd # install the caniuse cli
$ caniuse grid layout | mail -s test [email protected] # send a test email
$ crontab -e # open crontab

After opening crontab, add this line and save:

0 5 * * Sun /bin/bash -li -c "/usr/local/bin/caniuse grid layout | mail -s Update [email protected]"

import * as React from 'react'
import {Link} from 'react-router-dom'
import {default as styled, ThemeInterface} from '../../styled-components'
interface ButtonProps {
theme?: ThemeInterface
className?: string
action?: any
modalId?: string
disabled?: boolean
<div class="container" style="max-width:100%;padding:0;">
<div class="row">
{% for i, post in su.page("/my-blog").posts|reverse|slice(0,4) %}
<div class="col-md-6">
{% if i == 0 %}<img data-cke-saved-src="{{ post.featuredImage.ratio(315, 215) }}" src="{{ post.featuredImage.ratio(315, 215) }}" style="margin-bottom: 20px;">{% endif %}
<h4><a data-cke-saved-href="{{ su.page.url }}" href="{{ su.page.url }}">{{ post.title }}</a></h4>
<p>{{ post.description ?: post.content|striptags|pretty_truncate(200) }}</p>
</div>
{% endfor %}
</div>
{
"success": true,
"page": 1,
"page_max": 1,
"results_per_page": 20,
"count": 5,
"results": [
{
"Id": 12,
"Title": "Blog Post 5",
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
// via Paul Irish
// https://www.paulirish.com/2009/throttled-smartresize-jquery-event-handler/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
@su-narthur
su-narthur / compile-less.sh
Created December 13, 2017 15:40
Attempt at creating a bash script that would inject variables and compile out css from less files to allow for more complete static analysis of SUFramework themes
#!/usr/bin/env bash
echo "hi"
VARS=""
while read -r line
do
VARS="${VARS}--global-var=${line}=red "
done < <(cat theme/SUThemeSpruce/style/*.less | egrep -o 'config-\w+')
{% set getParamDateFormat = "Y-n-j" %}
{% set today = "now"|date(getParamDateFormat) %}
{% set devotionalDate = ( su.request.query.date ) ? su.request.query.date : today %}
{% set dateFragment = devotionalDate|date("-m-d") %}
{% set devotional = su.collection( "devotionals" ).sort( "date", "desc" ).date("%"~dateFragment).limit(1).find()[0] %}
{% set displayDate = devotionalDate|date("l, F j, Y") %}
<div class="devotional">
<h3>{{ (devotional.title) ? devotional.title : "Devotional for "~displayDate }}</h3>
{% set staffCollection = su.collection("staff") %}
{% set staffMembers = staffCollection.find() %}
<div class="staffListing">
{% for staffMember in staffMembers %}
<div class="staffMember">
{% if staffMember.photo %}
<img style="float: left; margin-right: 1.5rem;" src="{{ staffMember.photo }}" alt="{{ staffMember.name.first }} {{ staffMember.name.last }}" width=150 />
{% endif %}