Skip to content

Instantly share code, notes, and snippets.

@danyg
danyg / color-correction.js
Last active August 26, 2017 11:09
Webs Color Correction
let template = `
<div id="__COLOR__">
<label>
<strong>Contrast:</strong>
<input id="__COLOR__contrast" type ="range" min ="0" max="200" step ="1" value="100" data-initial="100"/>
</label>
<label>
<strong>Brightness:</strong>
<input id="__COLOR__brightness" type ="range" min ="0" max="200" step ="1" value="100" data-initial="100"/>
</label>
@danyg
danyg / PS1-git.sh
Created March 11, 2018 12:43
BASH Prompt PS1 colored with current GIT branch
# Define here your own colors.
# @see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
USER_COLOR='32'
ROOT_COLOR='31'
GITCOLOR='33'
RESET_COLORS='\[\e[0m\]'
[ $(whoami) = 'root' ] && DCOLOR=$ROOT_COLOR || DCOLOR=$USER_COLOR

Mayority of linux distributions contains a /etc/profile.d which contain a few bash script that are executed on bash login you could add the following file there, the name is not important just need to end in .sh e.g. /etc/profile.d/PS1-git.sh In order to add the file to /etc/profile.d you probably would need root access.

# Define here your own colors.
# @see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
USER_COLOR='32'
ROOT_COLOR='31'
GITCOLOR='33'
@danyg
danyg / requirejs-monkey-patch.js
Last active May 3, 2018 07:29
RequireJS monkey patching and dependency graph utils
(function(){
'use strict';
var DEBUG_DEPENDENCY_GRAPH = true;
var DEPENDENCY_GRAPH = {};
function proxyGetter(where, what, from) {
where.__defineGetter__(what, function() {
return from[what];
});
@danyg
danyg / jenkins-colorizer.js
Last active May 21, 2018 11:47
Colorizer for Jenkins Output
(function(){
var globalCode = '';
function getStyle(vt100Code) {
var tbc = false,
tmp = (globalCode + vt100Code).split(';');
var style = '';
for (var i = 0; i < tmp.length; i++) {
@danyg
danyg / overrides.js
Last active December 1, 2018 07:57
Google Black Override for Custom Javascript 2
// Here You can type your custom JavaScript...
if(window.location.toString().indexOf('https://www.google.es/maps') === -1) {
injectDarkStyles();
}
function injectDarkStyles() {
var s = document.createElement('style');
s.type = 'text/css';
s.innerHTML = `
@danyg
danyg / waitFor.js
Created January 3, 2019 11:13
Wait for something to happend.
export default (conditionFn) => new Promise((resolve) => {
const check = () => {
if (!conditionFn()) {
setImmediate(check);
} else {
resolve();
}
};
});
@danyg
danyg / youtube-override.js
Created February 24, 2019 10:25
YouTube Overrides CJS
(function() {
const TOPLAYER = '#page-manager';
const TRANS_TIME = '333';
const LEFT_BUTTON = 0b0001;
const RIGHT_BUTTON = 0b0010;
const WHEEL_BUTTON = 0b0100;
const STEP = 5;
const videoSelector = '.html5-main-video';
const videoPlayerAPISelector = '.html5-video-player';
const containerSelector = '.html5-video-container';
@danyg
danyg / wrappers.md
Last active August 8, 2019 08:05
How to use Wrappers in Tests

So in order to avoid this, we use wrappers which are easier to mock:

const defineGlobalWindow = (locationValue?: string) => {
  global.window = Object.create(window);
  const url = locationValue || "spTestHost";
  Object.defineProperty(window, "location", {
    value: { hostname: url },
    writable: true
  });
};
@danyg
danyg / .bash_profile.sample
Last active February 12, 2020 14:58
mac profile.d
#!/bin/bash
export USER_NAME='danyg'
source ~/profile.d/bash_profile
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion