Skip to content

Instantly share code, notes, and snippets.

@tegomass
tegomass / waitForKeyElementsSingle.js
Created March 5, 2021 12:53 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@tegomass
tegomass / s3-list.js
Created February 19, 2019 22:29
list S3 folder files as index.html
if (typeof AUTO_TITLE != 'undefined' && AUTO_TITLE == true) {
document.title = location.hostname;
}
if (typeof S3_REGION != 'undefined') {
var BUCKET_URL = 'http://' + location.hostname + '.' + S3_REGION + '.amazonaws.com'; // e.g. just 's3' for us-east-1 region
var BUCKET_WEBSITE_URL = location.protocol + '//' + location.hostname;
}
if (typeof S3BL_IGNORE_PATH == 'undefined' || S3BL_IGNORE_PATH != true) {
@tegomass
tegomass / cancelAJAX.js
Last active April 20, 2018 13:44 — forked from Integralist/cancelAJAX.js
Cancel all jQuery AJAX requests currently running
let xhrQueue = [];
$(document).ajaxSend(function(event,jqxhr,settings){
xhrQueue.push(jqxhr);
});
$(document).ajaxComplete(function(event,jqxhr,settings){
let i;
if((i=$.inArray(jqxhr,xhrQueue)) > -1){
xhrQueue.splice(i,1);
}
});
@tegomass
tegomass / aws-iot-tego.js
Created April 12, 2018 22:00
basical structure for aws-sdk's calls
const AWS = require('aws-sdk');
const fs = require('fs');
AWS.config.update({
region: 'eu-west-1'
});
var cloudwatchlogs = new AWS.CloudWatchLogs({apiVersion: '2014-03-28', region: 'eu-west-1'});
var iot = new AWS.Iot({apiVersion: '2015-05-28', region: 'eu-west-1'});
function listCertificates() {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Postman - Reports</title>
<style type="text/css">
html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-
@tegomass
tegomass / iziToast.min.js
Created November 4, 2017 12:48
iziToast JS version 1.2.0 (oct. 2017)
/*
* iziToast | v1.2.0
* http://izitoast.marcelodolce.com
* by Marcelo Dolce.
*/
!function(t,e){"function"==typeof define&&define.amd?define([],e(t)):"object"==typeof exports?module.exports=e(t):t.iziToast=e(t)}("undefined"!=typeof global?global:window||this.window||this.global,function(t){"use strict";var e={},o="iziToast",n=(document.querySelector("body"),!!/Mobi/.test(navigator.userAgent)),s=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor),i="undefined"!=typeof InstallTrigger,a="ontouchstart"in document.documentElement,r=["bottomRight","bottomLeft","bottomCenter","topRight","topLeft","topCenter","center"],l={info:{color:"blue",icon:"ico-info"},success:{color:"green",icon:"ico-success"},warning:{color:"orange",icon:"ico-warning"},error:{color:"red",icon:"ico-error"},question:{color:"yellow",icon:"ico-question"}},d=568,c={},u={id:null,"class":"",title:"",titleColor:"",titleSize:"",titleLineHeight:"",message:"",messageColor:"",messageSize:"",messageLineHeight:"",backgroundColor:"",theme
@tegomass
tegomass / iziToast.min.css
Last active November 4, 2017 12:48
iziToast CSS version 1.2.0 (oct. 2017)
/*
* iziToast | v1.2.0
* http://izitoast.marcelodolce.com
* by Marcelo Dolce.
*/
.iziToast-capsule{font-size:0;height:0;width:100%;transform:translateZ(0);backface-visibility:hidden;transition:transform .5s cubic-bezier(.25,.8,.25,1),height .5s cubic-bezier(.25,.8,.25,1)}.iziToast-capsule,.iziToast-capsule *{box-sizing:border-box}.iziToast-overlay{display:block;position:fixed;top:-100px;left:0;right:0;bottom:-100px;z-index:997}.iziToast{display:inline-block;clear:both;position:relative;font-family:'Lato',Tahoma,Arial;font-size:14px;padding:8px 45px 9px 0;background:rgba(238,238,238,.9);border-color:rgba(238,238,238,.9);width:100%;pointer-events:all;cursor:default;transform:translateX(0);-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;min-height:54px}.iziToast>.iziToast-progressbar{position:absolute;left:0;bottom:0;width:100%;z-index:1;background:rgba(255,255,255,.2)}.iziToast>.iziToast-progressbar>div{height:2px;width:100%
@tegomass
tegomass / gm_xhr.js
Last active October 28, 2017 08:28
GM_XHR - jQuery greasemonkey - Allow CORS with local $AJAX request
// allows using all Jquery AJAX methods in Greasemonkey
// inspired from http://ryangreenberg.com/archives/2010/03/greasemonkey_jquery.php
// works with JQuery 1.5
// (c) 2011 Martin Monperrus
// (c) 2010 Ryan Greenberg
//
// Usage:
// $.ajax({
// url: '/p/',
// xhr: function(){return new GM_XHR();},
@tegomass
tegomass / Convert CURL to JSON string
Last active March 2, 2017 12:54
Convert Firebug multipart/form-data key/value pair in JSON string
1) On firebug, navigate to the request.
2) Right-click on the content then select "Copy for CURL"
3) Paste the clipboard to a text editor (e.g. Sublime Text 2)
4) Use the function Search&Replace Regex with the following patterns :
Find : .*?form-data; name=(".+?").*?\\r\\n\\r\\n(.*?)\\r\\n-.*?
Replace with : \1:"\2",\n
@tegomass
tegomass / gmail_image_resizer.user.js
Last active January 15, 2019 23:14
Add a button in the top-left of Gmail to resize the image in the body of your mails if they are larger than a specified value
// ==UserScript==
// @name gmail image resizer
// @namespace https://gist.github.com/tegomass/61083a3ea54fb6327b9c11cedbf3d161
// @description Add a button in the top-left of Gmail to resize the image in the body of your mails if they are larger than a specified value
// @include https://mail.google.com/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
// @require https://gist.githubusercontent.com/tegomass/734b5a868f9222a6c1a89a42232768b5/raw/
// @exclude %exclude%
// @version 1.1
// @grant GM_addStyle