Skip to content

Instantly share code, notes, and snippets.

View OlivierPerceboisGarve's full-sized avatar

Olivier Percebois-Garve OlivierPerceboisGarve

View GitHub Profile
@OlivierPerceboisGarve
OlivierPerceboisGarve / mouse-plugin.js
Created September 6, 2019 11:47 — forked from OrganicPanda/mouse-plugin.js
Track the mouse position in Protractor
// Hook in to `addEventListener` to track the mouse and display it as a circle
exports.onPageLoad = function() {
return browser.executeScript(function() {
(function() {
var EventSniffer = function() {
this.history = [];
this.callbacks = {};
this.minCacheSize = 100;
this.maxCacheSize = 500;
};
@OlivierPerceboisGarve
OlivierPerceboisGarve / ES6 Angular Directive with injection
Created March 25, 2017 20:41 — forked from royto/ES6 Angular Directive with injection
Example of Angular Directive as ES6 class with injection
class myDirective {
constructor(userService) {
this.template = `<div>{{fullName}}</div>`;
this.restrict = 'E';
this.scope = {
user: '='
};
this.link = function(scope, element) {
scope.fullName = userService.getFullName(scope.user);
};
console.highlight = function(text, sample) {
var escapedSample = sample.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var reSample = new RegExp(escapedSample, 'g');
var args = [''];
var highlightedText = text.replace(reSample, function(match) {
args.push('background-color: #ffc', 'background-color: none');
return '%c' + match + '%c';
});
args[0] = highlightedText;
console.log.apply(console, args);
/*!
* $imple cache - v0.3pre - 07/15/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,window){
// Dump all document.styleSheets[*].cssRules[*].cssText to a div (easier to copy and paste):
(function(s,c,r,i,j){
var out = '';
for(i=0;i<s.length;i++){
c=s[i].cssRules;
for(j=0;j<c.length;j++){
r=c[j].cssText;
//console.log('document.styleSheets['+i+'].cssRules['+j+'].cssText = "'+r+'";')
out+= r+'<br>';