Skip to content

Instantly share code, notes, and snippets.

@csilverman
csilverman / _visually-hidden.css
Created April 28, 2021 17:11
Accessibly hide text
.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
@csilverman
csilverman / newfolder.scpt
Created January 16, 2021 22:24
Create new folder on desktop
tell application "Finder"
set p to path to desktop -- Or whatever path you want
make new folder at p with properties {name:"New Folder"}
end tell
@csilverman
csilverman / array-iteration.php
Created September 5, 2020 23:30
Iterate over arrays
<?php
foreach ($array as &$item) {
// code
}
unset($item);
foreach ($array as $key => $value) {
// code
}
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("top-50pfrom-topOfWindow");
},
// context: document.getElementById('page-content'),
offset: '50%'
});
tell application "Finder"
try
set fileName to "eeee"
if length of fileName = 0 then
return 0
end if
set fileExt to "txt"
set thisFolder to "Macintosh HD⁩:Users:csilverman:Dropbox:⁨dev:Local Sites:csiprojects:app:public:playlists:assets:links"
-- the target of the front window as alias
-- H.Zimmerman, AppleScript.
-- Create text file in current Finder folder with a dialog.
tell application "Finder"
try
display dialog "name of doc please (without the .txt thing)" default answer ""
set fileName to the text returned of result
if length of fileName = 0 then
return 0
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|_/';
@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
);
/* 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
<?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.