Skip to content

Instantly share code, notes, and snippets.

View seanblanton's full-sized avatar

Sean Blanton seanblanton

View GitHub Profile
@seanblanton
seanblanton / css-debug.js
Created November 27, 2016 22:48
CSS Debug Classes
[].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
@seanblanton
seanblanton / sketchHistoryDelete
Last active February 11, 2017 19:23
Sketch nondestructive .DocumentRevisions-V100 delete
# Go through Sketch files and delete autosave history without removing other items from .DocumentRevisions-V100
mkdir -pv ~/.Trash/SketchAutosaveHistory && sudo find /Volumes/Macintosh\ HD/.DocumentRevisions-V100/ -name *.sketch -exec mv "{}" ~/.Trash/SketchAutosaveHistory/ \;
@seanblanton
seanblanton / serverTricks.txt
Last active March 2, 2017 02:20
Sever logging tricks
# look in server logs for a single keyword match
grep "file" /var/log/apache2/access.log
# IP lookup
ipinfo.io/IP_ADDRESS
@seanblanton
seanblanton / scrape-site
Created February 14, 2017 20:53
Scrape a site for all files
wget -m -k -K -E -l 7 -t 6 -w 5 http://www.website.com
A little clarification regarding each of the switches:
-m Essentially, this means “mirror the site”, and it recursively grabs pages & images as it spiders through the site. It checks the timestamp, so if you run wget a 2nd time with this switch, it will only update files/pages that are newer than the previous time.
-k This will modify links in the html to point to local files. If instead of using things like page2.html as links throughout your site you were actually using a full http://www.website.com/page2.html you’ll probably need/want this. I turn it on just to be on the safe side – chances are at least 1 link will cause a problem otherwise.
-K The option above (lowercase k) edits the html. If you want the “untouched” version as well, use this switch and it will save both the changed version and the original. It’s just good practise in case something is awry and you want to compare both versions. You can always delete the one you didn’t want later.
@seanblanton
seanblanton / post-receive
Created March 18, 2017 03:53
How to copy everything from a repo in a specific folder
#!/bin/sh
git --work-tree=/var/www/html/ --git-dir=/var/repo/repoName.git checkout -f master -- _site/
cd /var/www/html/
cp -rRp _site/. .
rm -rf _site
@seanblanton
seanblanton / post-receive folder
Created April 3, 2017 05:04
Extract a specific folder in a post-receive hook
#!/bin/sh
git --work-tree=/var/www/html/ --git-dir=/var/repo/site.git checkout -f master -- dist/
cd /var/www/html/
cp -rRp dist/. .
rm -rf dist
// -rRp recursive copy files from /dist to current folder. Then delete the empty folder
@seanblanton
seanblanton / germlins-console
Created April 20, 2017 18:14
Excecute a gremlins.js instance from the console
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://rawgithub.com/marmelab/gremlins.js/master/gremlins.min.js';
document.head.appendChild(script);
setTimeout(function(){
gremlins
.createHorde()
.unleash();
@seanblanton
seanblanton / alphaOverride.js
Created July 13, 2017 18:56
rgb(a) alpha value override function
# Overrides rgba alpha values with a new alpha
const alpha = (color, opacity) =>
color.replace(/[\d\.]+\)$/g, opacity+')')
alpha(gray100, 0.4)
@seanblanton
seanblanton / framerLayerOverlapping.coffee
Created December 8, 2017 18:12
Check to see if a layer is overlapping another layer (+/- some threshold) or is completely inside it
Layer::isOverlapping = (targetLayer, offset = 0) ->
if @screenFrame.x + @width + offset >= targetLayer.screenFrame.x &&
@screenFrame.x - offset <= targetLayer.screenFrame.x + targetLayer.width &&
@screenFrame.y + @height + offset >= targetLayer.screenFrame.y &&
@screenFrame.y - offset <= targetLayer.screenFrame.y + targetLayer.height
true
else
false
Layer::isInside = (targetLayer, offset = 0) ->
@seanblanton
seanblanton / mobile-cursor-override.css
Created February 9, 2023 04:39
Override traditional cursor for mobile emulation cursor. Great for prototyping
html, html * {
cursor:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE4AAABOCAYAAACOqiAdAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABmcSURBVHgB7VxZjFZFm67zddPQDTQ7ioKNgAI6iAvg7xhFMzqOmXChE00cMjEmxqiJTuKFMXOjziRzOzGDiRovjEtM3DEucV9wQQfjvrEvArI10DRNA31OzfNUv2/1e+o7Dd0s/vNP/krOd86pvZ5616o6n3N/DccUMvdnCt77DEGfS2mMlzgv75l51z77vuyZd39w+COBC20RAAWM4YEHHshwBUBwt/Gly8Z7g3Qvpj7TZ/cHhUZ3koMOioGk8eCDD4Zovt5www0BLN6ff/559+OPP4Z8O3bsYJonqJLXIy3TeNbB93PPPTdgiPcAftKWtnNSwkmhOENVmQ7Mpn/44Yc13q+44oqWM88889xarUYEWhobG9tQrgVJE5P6duDajqsL1wbkWQcQN3z22WfbmU4Aea+iRneSwgkFTvpckl1CDaSUQEmLFy8+p7m5eTbyLGhqapo8YsSIA0OHDj00cuTIg62trQcbGhrylpaWHq2SP11dXUO6u7uHHDp0qGHfvn1DOzo6WhA3NM/zTUVR/IR631y6dOkOTAip1AtrexUDMpEnFMQTDVwmgtwrlUnnh0+bNm0eKGshwJp56qmnto8ZM6Zr3LhxB6rqQT4HQHo7iOr4rLPBdz4zbteuXc0AbcTu3btHHjx4cGtPT88bDz300DJMgieIvV0KnYoK6EQBeNzAyWxmIo+iMFeZdMstt/wDWPCfRo0a5dra2naOHTu2i8C4Pg0ZtSN/CIgCJ/liU4jLGIcrPGs8y+7cubNlw4YN4/fs2dMF6nzp6aef/oiJEyZM8GTl+++/X9nh/wRwmcozuavsym6++ebZoK7bAFjLGWecsRMD6HInIFhqTOID