Skip to content

Instantly share code, notes, and snippets.

View alanhogan's full-sized avatar

Alan Hogan alanhogan

View GitHub Profile
@alanhogan
alanhogan / failon.sh
Created May 5, 2022 15:44
Fail on pattern match of output while showing output. zsh + macOS compatible
# Allow failing on regex pattern match
# See https://superuser.com/a/1717757/60337
failon() (
pattern="$1"
shift
[ "$#" -eq 0 ] && set cat
FAILON_STATUS="${FAILON_STATUS:-125}"
set -o pipefail
{ "$@" \
| "$@" >&3 \

npm shrinkwrap is useful, but maddening (once it's in place and you want to update a package).

Say you've got a package.json with module ember-cli as a devDependency currently at version 1.13.1. And you have an npm-shrinkwrap.json file too, generated with the --dev flag.

If you change the version of ember-cli to, say, 1.13.8 in package.json and run npm install, nothing will happen.

If you do that and manually change references in the shrinkwrap file, you will still have trouble (as nested dependencies may now be incorrect).

So what do we actually do?

@alanhogan
alanhogan / remove-scss-files.rb
Created October 26, 2018 23:58
Very good Ruby broh
#!/usr/bin/env ruby
require 'find'
puts "Deleting all .scss files !!!! !!11"
deleted = 0
Find.find('.') do |path|
if FileTest.directory?(path)
@alanhogan
alanhogan / sass-filenames-to-comments.rb
Created October 26, 2018 23:56
Convert // comments to /* */ (for .scss files)
#!/usr/bin/env ruby
require 'find'
puts "Yo dawg, i only work on .scss files, not .sass. just a warning."
nonMatchingFiles = 0
def fileContents(filename)
data = ''
@alanhogan
alanhogan / safari_cant_find_the_server.html
Created May 26, 2018 01:41
Interesting HTML for a Safari error page
<!-- LOCALIZERS: Each localizable piece of the page is marked with a comment -->
<html>
<head>
<link rel=stylesheet type="text/css" href="page-load-errors.css">
<!-- LOCALIZERS: You might want to change the font family. You can also add styles to override sizes, etc. -->
<style>
body {font-family:'-apple-system-font';}
</style>
<!-- LOCALIZERS: The next line contains the page title that appears in the window's title bar -->
<title>Failed to open page</title>
@alanhogan
alanhogan / compass-retina-sprites.scss
Created June 5, 2012 23:21 — forked from thulstrup/compass-retina-sprites.scss
Using Compass to generate normal and retina sprite maps
$sprites: sprite-map("sprites/*.png");
$sprites-retina: sprite-map("sprites-retina/*.png");
@mixin sprite-background($name) {
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
display: block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));

Keybase proof

I hereby claim:

  • I am alanhogan on github.
  • I am alanhogan (https://keybase.io/alanhogan) on keybase.
  • I have a public key ASBsuC4ft6MgMV-UB77lHthuXxHIhQhvcYqMt_RY1Sl70go

To claim this, I am signing this object:

payWithTweet is a jQuery plugin that makes you go tweet something to unlock an action on the page. You can bypass it by running:

function createCookie(name,value,days){var expires;if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+ date.toGMTString();}else{expires="";}
document.cookie=encodeURIComponent(name)+"="+ encodeURIComponent(value)+ expires+"; path=/";}

createCookie("tweetToDownload",true,30);
- title "#{@module_name} Module"
- desc = Descss.new @module_name
.l-max-readable-width.l-h-center.l-v-spaced
.txt
%header
%h1
Module info:
- title "Modules"
%h1 CSS Modules
%ul
- @modules.each do |mod|
%li
- name = "<code><b>#{mod}</b></code>"
- desc = Descss.new mod
- name += ": <b>#{desc.name}</b>" if desc.has_name?