Skip to content

Instantly share code, notes, and snippets.

View xzyfer's full-sized avatar

Michael Mifsud xzyfer

View GitHub Profile
@paulirish
paulirish / readme.md
Last active April 2, 2024 20:18
resolving the proper location and line number through a console.log wrapper

console.log wrap resolving for your wrapped console logs

I've heard this before:

What I really get frustrated by is that I cannot wrap console.* and preserve line numbers

We enabled this in Chrome DevTools via blackboxing a bit ago.

If you blackbox the script file the contains the console log wrapper, the script location shown in the console will be corrected to the original source file and line number. Click, and the full source is looking longingly into your eyes.

@andrewk
andrewk / jasmine.md
Last active January 3, 2018 21:49
Jasmine 2.0 quick reference

Spies

Create a spy

// "bare" spy
var spy = jasmine.createSpy('spyName');

// Mock object of spies: spy.next(), spy.current(), etc
// Imports zip.sass, zip.scss, or zip.css *nontransitively* with a "zip" prefix.
@use "zip";
// Uses the "foo" mixin from zip.
@include zip-foo;
// The prefix is now "zap".
@use "zip" as zap;
// Everything is in the global namespace.
@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@chriseppstein
chriseppstein / existence-check-shim.scss
Created September 2, 2014 23:49
How to shim sass 3.3 existence checks in older versions.
@function -my-function-exists($name) {
$name: unquote($name);
$result: function-exists($name);
@if $result == "function-exists(#{$name})" {
@return false;
} @else {
@return $result;
}
}
@scottjehl
scottjehl / noncritcss.md
Last active August 12, 2023 16:57
Comparing two ways to load non-critical CSS

I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.

TL;DR: Here's the solution I ended up with: https://github.com/filamentgroup/loadCSS/


For async JavaScript file requests, we have the async attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: https://gist.github.com/igrigorik/2935269#file-notes-md ).

Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:

@larsyencken
larsyencken / aws_profile
Created June 5, 2014 04:23
Switch between AWS accounts
#!/bin/bash
#
# aws_profile
#
# Manages multiple AWS accounts through symlinks.
#
if [ ! -d ~/.aws ]; then
echo "ERROR: can't find \${HOME}/.aws directory" 1>&2
exit 1

OpenCart Issue #1286

This is the full version of the thread for opencart#1286, archived from notification emails.
The discussion has since been deleted almost entirely by OpenCart's developer.
Everyone who posted in it has also been blocked from the OpenCart repo.


Damian Bushong

@shama
shama / favorite_module_pattern.js
Last active August 29, 2015 13:57
My favorite node.js module pattern
function Animal(name) {
if (!(this instanceof Animal)) return new Animal(name);
this.name = name || 'unknown';
}
module.exports = Animal;
Animal.prototype.feed = function(food) {
food = food || 'food';
return 'Fed ' + this.name + ' some ' + food;
};
@chriseppstein
chriseppstein / generalized_memoizer.scss
Last active August 29, 2015 13:57
Memoization in Sass
// This approach lets you generically memoize any function by changing the call site:
@function something-slow-to-compute($arg-1, $arg-2) {
@return ... slow calculation ... ;
}
$cached-values: ();
@function cached($function-name, $args...) {
$cached-value: map-get($cached-values, ($function-name, $args));
@if $cached-value {