Skip to content

Instantly share code, notes, and snippets.

Alan Hogan alanhogan

Block or report user

Report or block alanhogan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View remove-scss-files.rb
#!/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 Oct 26, 2018
Convert // comments to /* */ (for .scss files)
View sass-filenames-to-comments.rb
#!/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
Interesting HTML for a Safari error page
View safari_cant_find_the_server.html
<!-- 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>
View keybase.md

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:

View Bypass 'pay with tweet' gates.md

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);
View Updating a package when you’re using NPM Shrinkwrap.md

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?

View this breaks libsass.scss
$four: "4";
$seven: "7";
$pi: 3.14159;
$phi: 1.618;
$null: null;
@if $seven > $four { // may only compare numbers on line 2 at column 9
.fourIsBiggerThanSeven {
color: green;
}
@alanhogan
alanhogan / autoselect.coffee
Created Aug 26, 2014
CoffeeScript Require.js Module for jQuery-based element selection on click
View autoselect.coffee
$ = require 'jquery'
module.exports = do ->
init = ->
$(document).on 'click', '.js-autoselect', (e) ->
range = document.createRange()
selection = window.getSelection()
range.selectNodeContents this
View coffeescript_gotcha.md

Here are some of the "gotchas" I've encountered when I converted all the javascript code into coffeescript. (BTW, this is gathered while coding for YourMechanic.com, a very cool mobile auto repair service.)

Disclaimer: Coffeescript is a great productivity booster for me personally. Even with all the things outlined below, it is still way better than javascript. None of these should discourage you from jumping into it right away.

Major gotchas

(Things that generate wrong code silently)

View modules.html.haml
- 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?
You can’t perform that action at this time.