Skip to content

Instantly share code, notes, and snippets.

@csilverman
csilverman / markupifier.php
Created March 15, 2018 22:31
Script to take line-delimited content and merge it with a template.
<?php
/* Item formatter
==============
This script takes data in a set of line-delimited items, as follows:
Arthur Arthurson
From: Phoenix, AZ
Major: Political Science
scss/.sass-cache
scss/.sass-cache/*
scss/*/.sass-cache
scss/*/*/.sass-cache
$( document ).ready(function() {
var discreteElements = document.getElementsByClassName('animate-this')
for (var i = 0; i < discreteElements.length; i++) {
new Waypoint({
element: discreteElements[i],
handler: function() {
this.element.classList.add("animation");
},
offset: '50%'
});
.full-bleed {
width: 100vw;
margin-left: 50%;
transform: translateX(-50%);
}
/* https://andy-bell.design/wrote/creating-a-full-bleed-css-utility/ */
<html>
<head>
<?php
function social_card($og_obj) {
/*
$og_obj = array(
"tw_username" => "vassar",
"preview_image" => "https://www.vassar.edu/assets/images/home-slideshow-sustainability-standard.jpg",
// https://stackoverflow.com/questions/7341865/checking-if-jquery-is-loaded-using-javascript
$(document).ready(function(){
if (jQuery) {
// jQuery is loaded
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
<?php
/* RSS2INSTA
=========
This scans a folder of images with specially formatted captions, and generates a generic RSS feed. You can then plug this feed into a Zapier workflow and have it send the images (with tags) to Buffer, which will post them to Instagram.
The caption format allows you to specify a plain-language caption as well as whatever hashtags you want to have. The different parts of the caption are delimited by %%, since that seems unlikely to occur in normal text.
Captions should be formatted as follows: [ID]%%[caption text]%%[image tags].jpg.
/* Here's the problem this is trying to solve.
Say an element is supposed to fade in after a Javascript event. It needs to be hidden and then
revealed. If JS is off or broken, though, the element will never be revealed. That
could be a problem.
To solve this, you'd set up a CSS animation that automatically reveals the element after a
certain period of time. (You won't know when exactly JS fails, or how long it
might take to load - that's the downside. You'd have to hardcode a delay, and
then hope that JS loads within that time. I think Typekit's wf-loading did something
@csilverman
csilverman / SassMeister-input.scss
Last active January 19, 2020 21:59
Single-rule mixin for generating breakpoints
// ----
// Sass (v3.4.25)
// Compass (v1.0.3)
// ----
$breakpoints: (
small: 34em,
medium: 50em,
large: 70em
);
function slugify($string){
// /[^A-Za-z0-9-]+/
// $final_string = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string), '-'));
// Get rid of multiple spaces
$final_string = str_ireplace(' ', ' ', $string);
// target all alphanumerics
// https://stackoverflow.com/a/17947853/6784304
$replace_pattern = '/\W|_/';