Skip to content

Instantly share code, notes, and snippets.

View antenando's full-sized avatar

Fernando Bueno antenando

View GitHub Profile
@antenando
antenando / DefaultKeyBinding.dict
Created July 26, 2021 21:07 — forked from trusktr/DefaultKeyBinding.dict
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
# Usage: pdfcompress [input file] [output file] [screen*|ebook|printer|prepress]
pdfcompress() {
if [ -z "$1" ]||[ -z "$2" ]
then
echo "Usage: pdfcompress [input file] [output file] [screen*|ebook|printer|prepress]"
return 1
else
gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/${3:-"printer"} -dCompatibilityLevel=1.4 -sOutputFile="$2" "$1"
fi
}
@antenando
antenando / convert-encoding.sh
Created August 14, 2018 01:38 — forked from arpith20/convert-encoding.sh
Shell script to convert encoding of files to utf-8.
#!/bin/bash
if [ $# -lt 1 ]
then
echo "Usage: "$0" <file_name>"
echo "Convert files to utf-8"
exit
fi
for i in $*
do
@antenando
antenando / coverage.js
Created February 28, 2018 11:27 — forked from ebidel/coverage.js
CSS/JS code coverage during lifecycle of page load
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*
* Shows how to use Puppeeteer's code coverage API to measure CSS/JS coverage across
* different points of time during loading. Great for determining if a lazy loading strategy
* is paying off or working correctly.
*
* Install:
* npm i puppeteer chalk cli-table
@antenando
antenando / cloudSettings
Last active July 11, 2018 02:31
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-07-11T02:23:51.479Z","extensionVersion":"v2.9.2"}
@antenando
antenando / Infrastructure.js
Created December 30, 2017 00:25 — forked from idibidiart/Infrastructure.js
SynchronousAsync.js
const fetch = (url) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(url)
switch(url.match(/\d[aA-zZ]$/)[0]) {
case "1a":
resolve({name: "Seb"})
// or try this instead:
// reject({error: "something went wrong while fetching " + url})
break;
@antenando
antenando / Infrastructure.js
Created December 29, 2017 23:46 — forked from sebmarkbage/Infrastructure.js
SynchronousAsync.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
@antenando
antenando / script-loaded.js
Created December 21, 2017 00:28 — forked from AllThingsSmitty/script-loaded.js
Check if any given script has loaded
var myScript = document.createElement('script');
myScript.src = 'http://code.jquery.com/jquery-2.1.4.min.js';
myScript.onload = function() {
console.log('jQuery loaded.');
};
document.body.appendChild(myScript);
@antenando
antenando / cache_storage_size.js
Created December 15, 2017 23:46 — forked from ebidel/sw_caching_size.js
Print service worker cache sizes and overall bytes cached.
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*/
// Prints the size of each cache in the Cache Storage API and the overall bytes cached.
async function getCacheStoragesAssetTotalSize() {
// Note: opaque (i.e. cross-domain, without CORS) responses in the cache will return a size of 0.
const cacheNames = await caches.keys();
@antenando
antenando / Frame.js
Created December 12, 2017 12:44 — forked from robertgonzales/Frame.js
Use React portals to render inside shadow dom and iframes
class Frame extends Component {
componentDidMount() {
this.iframeHead = this.node.contentDocument.head
this.iframeRoot = this.node.contentDocument.body
this.forceUpdate()
}
render() {
const { children, head, ...rest } = this.props
return (