This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jsdom from 'jsdom'; | |
export const beforeParse = (window: any) => { | |
// Styled-Components doesn't write textNodes within ie `<style> .thing { font-weight: bold } </style>` | |
// instead it access the style element's `sheet` property and calls `insertRule` | |
// which is much faster, but that means it doesn't make innerText for us to scrape. | |
// These `insertRule` rules are available at `(theStyleElement).sheet.cssRules` and | |
// that's an array of `cssText` strings. | |
// | |
// See https://spectrum.chat/styled-components/help/why-is-the-inline-style-tag-empty~c43006f6-50d5-4d7d-857d-ca7fd6b68de3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* Bootstrap v4.0.0-beta (https://getbootstrap.com) | |
* Copyright 2011-2017 The Bootstrap Authors | |
* Copyright 2011-2017 Twitter, Inc. | |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | |
*/ | |
@media print { | |
*, | |
*::before, | |
*::after { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* Bootstrap v4.0.0-beta (https://getbootstrap.com) | |
* Copyright 2011-2017 The Bootstrap Authors | |
* Copyright 2011-2017 Twitter, Inc. | |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | |
*/ | |
@media print { | |
*, | |
*::before, | |
*::after { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Cache your selectors | |
Don't do this: | |
```JavaScript | |
$("body").on("click", function() { | |
$("body").addClass("clicked"); | |
}); | |
``` | |
Do this: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function querySelectArray(selector, el = document) { | |
// Usage: fn(selector, document.body) | |
// Returns [el1, el2, ...] | |
return Array.prototype.slice.call(el.querySelectorAll(selector)); | |
} | |
export function querySelectArrayByElementArray(selector, els, removeDuplicates=true){ | |
// Usage: fn(selector, [document.body, document.head]) | |
// Returns [elementFromBody1, elementFromBody2, elementFromHead1, ...] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* An HTML template in 180 bytes (minified) | |
Features: Escapes HTML, accepts either strings or functions as values, and that's all (it doesn't handle looping). | |
Usage: | |
OneEightyT( | |
"<h1>{name}</h1><div>{content} @ {currentTime}</div>", | |
{ | |
name: "Stella", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
pdf = open(sys.argv[1], "rb").read() | |
minimum_seek = 20 | |
startfix = 0 | |
endfix = 2 | |
i = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var is = { | |
get_type: function(thing){ | |
if(thing===null) return "[object Null]"; | |
else if(thing!==thing) return "[object NaN]"; | |
return Object.prototype.toString.call(thing); | |
}, | |
compare: function(type){ | |
return function(value){ | |
return this.get_type(value) === "[object " + type + "]"; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var get_type = function(thing){ | |
if(thing===null) return "[object Null]"; | |
else if(thing!==thing) return "[object NaN]"; | |
return Object.prototype.toString.call(thing); | |
}; | |
get_type([1]) // "[object Array]" | |
get_type({a:1}) // "[object Object]" | |
get_type(1) // "[object Number]" | |
get_type("test") // "[object String]" |
NewerOlder