Skip to content

Instantly share code, notes, and snippets.

View CrocoDillon's full-sized avatar

Dillon de Voor CrocoDillon

View GitHub Profile
@CrocoDillon
CrocoDillon / ApolloServer.js
Last active October 27, 2021 20:42
POC ApolloServer for Next.js
import {
ApolloServerBase,
convertNodeHttpToRequest,
isHttpQueryError,
runHttpQuery,
} from 'apollo-server-core'
import { parseBody } from 'next/dist/server/api-utils'
const setHeaders = (res, headers) => {
Object.entries(headers).forEach(([header, value]) => {
@CrocoDillon
CrocoDillon / Services and frameworks.md
Created January 16, 2015 08:47
Error logging services and frameworks

Error logging

Why? Because this is the only way to find all errors your users see but you don't. Only thing left that could fail without you knowing about it is the service or framework itself so let's hope that's well tested or... errorception!

I guess it should possible to log something like "okay, I'm loaded and ready to catch them errors" to make sure everything works as expected but I degress.

You can also read something like http://blog.meldium.com/home/2013/9/30/so-youre-thinking-of-tracking-your-js-errors about JS error tracking.

Below you will find some resources I collected during a very not extensive Google search, I might add more later.

@CrocoDillon
CrocoDillon / SassMeister-input.scss
Created November 20, 2014 15:14
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
@mixin center($max-width) {
width: 100%;
max-width: $max-width;
margin: 0 auto;
}
@CrocoDillon
CrocoDillon / SassMeister-input.scss
Created September 26, 2014 08:33
Generated by SassMeister.com.
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
$col-map: ();
@mixin col-span($cols, $total) {
$width: ($cols/$total) * 100%;
@if map-has-key($col-map, $width) {
@extend #{map-get($col-map, $width)};
@CrocoDillon
CrocoDillon / SassMeister-input.scss
Created September 26, 2014 08:17
Generated by SassMeister.com.
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
$col-map: ();
@mixin col-span($cols, $total) {
$width: ($cols/$total) * 100%;
@if map-has-key($col-map, $width) {
@extend map-get($col-map, $width);
@CrocoDillon
CrocoDillon / cookies.js
Last active February 11, 2024 22:42
Export your awesome module using AMD, CommonJS, Node.js or just as global.
/*
* Inspiration (well… copy pasting more or less) from:
* https://github.com/ScottHamper/Cookies/blob/0.3.1/src/cookies.js#L127-L140
*
* Thanks Scott!
*/
(function (global) {
'use strict';
var MyModule = function () {
@CrocoDillon
CrocoDillon / _blank.js
Last active August 30, 2023 21:27
Automatically open external links in new tab or window.
// vanilla JavaScript
var links = document.links;
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname) {
links[i].target = '_blank';
}
}
// or in jQuery
@CrocoDillon
CrocoDillon / _guides.scss
Created November 21, 2013 12:15
Creates guides, useful for prototyping.
$guides-default-color: #4e68c7;
$guides-default-orientation: horizontal;
/**
* Creates guides, useful for prototyping.
*
* @param $guide-sets List of guides, which can be numbers (uses default
* color and orientation) or lists in the form (color orientation guides),
* where guides can be a single number or a list of numbers.
*/
@CrocoDillon
CrocoDillon / Get all class names.js
Last active December 28, 2015 00:29
Get all class names of a document. Useful for... whatever.
var classes = [];
Array.prototype.forEach.call(document.querySelectorAll('*'), function(el) {
el.className.split(/\s/).forEach(function(cl) {
if (cl && classes.indexOf(cl) == -1)
classes.push(cl);
});
});
classes.sort();
classes.forEach(function(cl) {
console.log(cl);
/*
* http://christian-fei.com/tutorials/how-to-lazy-load-disqus-comments/
*
* <div class="comments"></div>
*/
var comments = document.getElementsByClassName('comments')[0],
disqusLoaded = false;
function loadDisqus() {