Skip to content

Instantly share code, notes, and snippets.

View cacheflowe's full-sized avatar
🏳️‍🌈

Justin Gitlin cacheflowe

🏳️‍🌈
View GitHub Profile
@cacheflowe
cacheflowe / SASS: Retina image media query mixin
Last active October 5, 2015 22:08
Media queries to load only 1 image per browser width / pixel density
// webkit-only .sass --------------------------------
@media (min-width: 20px) and (max-width: 480px) and (-webkit-min-device-pixel-ratio: 1.5)
#site-loader-inner
background: transparent url('mobile/loaders/loader-spin@2x.png', image)
@media (min-width: 20px) and (max-width: 480px) and (-webkit-max-device-pixel-ratio: 1.5)
#site-loader-inner
background: transparent url('mobile/loaders/loader-spin.png', image)
@cacheflowe
cacheflowe / Unix & Shell Commands
Last active December 24, 2018 16:28
Sweet Unix commands
# file copying & filesystem stuff ##############################
# copy massive directories
sudo cp -R -n -p /Volumes/RAID01/_backup_laptop /Volumes/RAID2TB/machine_backups/
# or use rsync
sudo rsync -rltgoDv /Volumes/RAID02/ /Volumes/RAID06/
# diff directories
diff -rq /Volumes/RAID01/_backup_laptop /Volumes/RAID2TB/machine_backups/_backup_laptop/
// check existence of a local file within an app bundle -------------------------------------
NSString *soundFile = @"sound.wav";
NSFileManager* manager;
manager = [NSFileManager defaultManager];
if([manager fileExistsAtPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:soundFile]])
printf("file Exists...\n\n");
else
printf("File not exist...\n\n");
@cacheflowe
cacheflowe / gist:7547942
Created November 19, 2013 16:20
CoffeeScript: Confine form input tabbing to a group of inputs
disableForms: (page) ->
@formInputs = page.$el.find('input[tabindex], textarea[tabindex]')
@formInputs.off 'keydown', @handleTab
@formInputs.blur()
enableForms: (page) ->
@formInputs = page.$el.find('input[tabindex], textarea[tabindex]')
@formInputs.on 'keydown', @handleTab
handleTab: (e) =>
@cacheflowe
cacheflowe / gist:7668084
Last active December 29, 2015 12:08
Show/hide sass/css toggle w/fade
.hide
opacity: 0
visibility: hidden
// to be added to .hide after init
.hide-ready
transition: visibility 0s linear 0.4s, opacity 0.4s linear
-webkit-transition: visibility 0s linear 0.4s, opacity 0.4s linear
.hide-ready.showing
@cacheflowe
cacheflowe / gist:323a74aad892542fdd9d
Created February 28, 2016 02:08
Download all .jpg attachments in an expanded gmail thread
var els = document.querySelectorAll('span[download_url]')
for(var i=0; i < els.length; i++){
(function(){
var attr = els[i].getAttribute('download_url');
if(attr.indexOf('jpg:https') != -1){
var url = 'https' + attr.split('jpg:https')[1];
setTimeout(function(){
document.location.href = url;
}, i * 1000)
}
@cacheflowe
cacheflowe / render-svg.js
Last active November 27, 2016 17:53
Render svg to bitmap
var renderSVG = function(svgEl, renderedCallback, jpgQuality) {
// WARNING! Inline <image> tags must have a base64-encoded image as their source. Linked image files will not work.
// transform svg into base64 image
var s = new XMLSerializer().serializeToString(svgEl);
var uri = 'data:image/svg+xml;base64,' + window.btoa(s);
// load svg image into canvas
var image = new Image();
image.onload = function() {
var canvas = document.createElement('canvas');
@cacheflowe
cacheflowe / remove-twitter-likes.js
Last active January 27, 2024 13:29
Remove your Twitter likes
// [Noted in the comments below on 2023-10 - this script might not work very well anymore due to Elon ruining Twitter]
// [Updated 2021-01-18 w/new selectors]
// go to your account Likes page and run this in the console:
function scrollToLoadMore() {
// keep scrolling if twitter tries to stop loading more.
// scroll up, then down to force infinite load.
window.scrollTo(0, 0);
setTimeout(function() {
window.scrollBy(0, 9999999999);