Skip to content

Instantly share code, notes, and snippets.

View alecperkins's full-sized avatar

Alec Perkins alecperkins

View GitHub Profile
@alecperkins
alecperkins / gist:4263031
Created December 11, 2012 22:44
CoffeeScript-friendly Backbone.Marionette module definition pattern.
# Since CoffeeScript wraps everything in a closure by default, the module
# definition function pattern that Marionette normally uses is unnecessary.
# (And cumbersome with having to indent everything.) Instead, creating the
# module at the very begining makes it available to everything in the file, and
# the initializers and exported classes can be added at the end of the file.
# (This relies on things like the App and Backbone being on window, but they
# already have to be for CoffeeScript-based code to work.)
# Create the module.
Foo = App.module 'Foo'
@defunctzombie
defunctzombie / browser.md
Last active July 15, 2024 04:13
browser field spec for package.json
@blackfalcon
blackfalcon / sassJunkDrawer.md
Last active March 23, 2022 20:09
Clean out your Sass junk-drawer

by Dale Sande

CSS has had a long and sordid past. A developer never sets out with the goal of making a complete and total mess of things. Their intention is not to build something that is practically illegible, impractical to maintain and is limited in scale. But somehow, this is where many inevitably end up. Luckily, all is not lost. With some simple strategies, organizational methods and out-of-the box tools, we can really help get that junk-drawer inline.

For many of us getting started with Sass, at one time or another have created a junk-drawer of files. For most, this was a rookie mistake, but for others, this is a continuing issue with our architecture and file management techniques. Sass doesn't come with any real rules for file management so developers are pretty much left to their own devices.

Large CSS files and increased complexity

CSS started out with very simple intentions, but as [tableless web design][1.1] began to really take a foothold, o

@joyrexus
joyrexus / ives.coffee.md
Last active October 25, 2018 07:13
Self-interpolating-litcoffee rendering hack.

St Ives

class Slider
  constructor: (@i, @range) -> 
    @ui = '<span class="slider">' + @i + '</span>'

slider = (i, range) -> new Slider i, range

There are #{sacks} sacks
Every sack had #{cats.ui} cats

@svallory
svallory / sass-one-time-importer.rb
Last active December 18, 2015 21:58
Sass custom importer which only imports the same file once. Requires colorize to make it easy to debug. You can remove it safely (but make sure to remove all the .red, .blue etc. calls also)
require 'colorize'
module Liftr
module Importers
class ImportOnce < ::Sass::Importers::FilesystemFilesystem
attr_accessor :root, :debug_level, :staleness_check, :imported, :original_filename
# Creates a new filesystem importer that imports files relative to a given path.
#
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active March 12, 2025 01:22
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@clifff
clifff / dogs.markdown
Created October 9, 2013 20:48
dog gifs

@scottkellum
scottkellum / SassMeister-input.sass
Created October 15, 2013 16:44
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.7)
// ----
=e($name)
@at-root #{&}__#{$name}
@content
=m($name)
@at-root #{&}--#{$name}
@una
una / SassMeister-input-HTML.html
Created November 15, 2013 05:44
Generated by SassMeister.com.
<!-- @una made this -->
<ul class="color-list">
<li class="color-box brick-red"></li>
<li class="color-box strawberry"></li>
<li class="color-box deep-orange"></li>
<li class="color-box tangerine"></li>
<li class="color-box gold"></li>
<li class="color-box sunshine"></li>
<li class="color-box grass-green"></li>
@alexchung
alexchung / Blockout.py
Created February 9, 2014 23:11
Blockout encryption/decryption methods ported to Python
# -*- coding: utf-8 -*-
import sys
import os
import base64
import bcrypt
from Crypto import Random
from Crypto.Cipher import AES
from Crypto.Hash import SHA256
class Blockout: