Skip to content

Instantly share code, notes, and snippets.

View jasongabler's full-sized avatar

Jason Gabler jasongabler

  • San Francisco, CA, USA
View GitHub Profile
@jasongabler
jasongabler / calendar.twig
Last active January 17, 2018 21:26 — forked from aknosis/calendar.twig
Table based calendar only using Twig
{#
time can be any string acceptable by http://www.php.net/strtotime, the
template will output that time's month.
If you don't want to pass in a date you can set time like this:
{% set time = "now"|date("U") %}
{% set time = "December 2012"|date("U") %}
Data (in activityByDay) is collated by activityByDay[year][month][day], which holds a list
of activity data for each day. YMMV for your own needs.
@jasongabler
jasongabler / gist:3b638ea767336075e2d3
Last active August 29, 2015 14:24
A simple way to render Twig template from a string... ? Seems to work for me.
# This is pretty much pilfered from: http://twig.sensiolabs.org/doc/recipes.html#using-a-database-to-store-templates
# and then modified to use a given strings for templates instead of fetching from the database... even simpler!
# The loader as a component:
class TwigString implements \Twig_LoaderInterface {
public function getSource($name)
{
// get from database
@jasongabler
jasongabler / gist:94c093d154c46c01dbf9
Created October 14, 2014 18:12
Grabs vCard data from an HTML container "#vcard" and turns it into an downloading octect-stream
(function( $ ) {
$(function() {
$('.vcard-download').click(function() {
// Get the vcard data stored within the same result container
var vcard = $('#vcard');
// Generate a filename that is the person's fullname with all whitespace converted to dashes.
var filename = vcard.data('displayname').replace(/\s+/, '-') + '.vcf';
// Initiate the download of the data as a file
download(vcard.html(), filename, 'text/vcard');
});