Skip to content

Instantly share code, notes, and snippets.

View andrewagain's full-sized avatar

Andrew andrewagain

View GitHub Profile
@andrewagain
andrewagain / jsdom.js
Last active May 7, 2016 19:42
jsdom with mocha
var jsdom = require('jsdom')
// setup the simplest document possible
var doc = jsdom.jsdom('<!doctype html><html><body></body></html>')
// get the window object out of the document
var win = doc.defaultView
// set globals for mocha that make access to document and window feel
// natural in the test environment
@andrewagain
andrewagain / snippet.js
Last active March 28, 2023 13:18
Google Analytics Snippet Unminified
// Source
// https://developers.google.com/analytics/devguides/collection/analyticsjs/
// Original
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
// Unminified
@andrewagain
andrewagain / .gitignore
Created October 28, 2015 21:54
browsersync rewriterules not used
node_modules
<head>
<script type='text/javascript'>
console.log('main-tag');
document.write('<script type=\"text/javascript\" src="http://cdn.ahf.io/remote.js"><\/scr'+'ipt>');
</script>
</head>
<body>
Body
<script type='text/javascript'>
console.log('end-of-body-tag');
@andrewagain
andrewagain / .eslintrc
Created September 9, 2015 16:21
Our ESLint
{
"extends": "airbnb",
"env": {
"mocha": true,
"browser": true,
"node": true
},
"rules": {
"no-undef": 2,
"comma-dangle": 0,
import React, { PropTypes } from 'react'
import Emoji from 'emojione'
var Emojify = React.createClass({
convert(line) {
let data = line.match(/\<img class\=\"([^"]*)\" alt\=\"([^"]*)\" src\=\"([^"]*)\"\/\>/i)
//return data[2]
return (
@andrewagain
andrewagain / shrinkwrap-test.sh
Last active August 29, 2015 14:27
npm shrinkwrap validation errors
# ESLint is at 1.0.0 in package.json
$ cat package.json
{
"name": "npm-shrinkwrap-test",
"version": "0.0.1",
"dependencies": {
"eslint": "1.0.0"
}
}
/** @jsx createNode */
function createNode(tagName, attrs, ...children) {
const node = attrs || {};
node.name = tagName;
if (children && children.length > 0) {
node.children = children;
}
return node;
}
@andrewagain
andrewagain / README.md
Created June 3, 2015 22:16
Chokidar alwaysStat issue

Chokidar alwaysStat issue

Project for reproducing issue 9 in the chokidar library.

Running

First install the packages with:

@andrewagain
andrewagain / footer.m
Created May 1, 2015 05:47
animate footer up