Skip to content

Instantly share code, notes, and snippets.

View bpceee's full-sized avatar
💭
In meditation

Ken Bi bpceee

💭
In meditation
  • Auckland, New Zealand
View GitHub Profile
@bpceee
bpceee / ybif.js
Last active October 28, 2023 07:14
youtube iframe injector
// ==UserScript==
// @name youtube frame
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
@bpceee
bpceee / cypressFileUpload.js
Created March 17, 2020 03:23
cypress file upload
const uploadFile = (fileName, fileType = '', selector) => {
cy.get(selector).then(subject => {
cy.fixture(fileName, 'base64')
.then(Cypress.Blob.base64StringToBlob)
.then(blob => {
const el = subject[0]
const testFile = new File([blob], fileName, { type: fileType })
const dataTransfer = new DataTransfer()
dataTransfer.items.add(testFile)
el.files = dataTransfer.files
let styleEl;
let keyframeID = 0;
const insertionObserver = function(selector, callback) {
if (!styleEl) {
styleEl = document.createElement('style');
document.head.appendChild(styleEl);
}
const curKeyframeName = `insertionObserver${keyframeID++}`;
const keyframesRule = `@keyframes ${curKeyframeName} { from { opacity: 0.99; } to { opacity: 1; } }`;
const styleRule = `${selector} { animation-duration: 0.001s; animation-name: ${curKeyframeName}; }`;
@bpceee
bpceee / stash-avatar-initials.js
Last active November 21, 2018 09:29
stash avatar initials
// ==UserScript==
// @name stash avatar initials
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://stash.bbpd.io/*
// @grant none
// ==/UserScript==
@bpceee
bpceee / redditAdBlock.js
Last active September 4, 2018 05:16
redditAdBlock
// ==UserScript==
// @name remove reddit ads
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.reddit.com/
// @grant none
// ==/UserScript==
@bpceee
bpceee / openOdestCommitPage.js
Created May 23, 2018 10:52
openOdestCommitPage
(function openOdestCommitPage([_, repo, branch='master']) {
return fetch('https://api.github.com/repos/' + repo + '/commits?sha=' + branch)
// the link header has additional urls for paging
// parse the original JSON for the case where no other pages exist
.then(res => Promise.all([res.headers.get('link'), res.json()]))
// get last page of commits
.then(([link, commits]) => {
if (!link) {
return;
}
set -g default-terminal "screen-256color"
# remap prefix to Control + a
set -g prefix C-a
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
#Force a reload of the config file
@bpceee
bpceee / jsType.js
Created August 22, 2017 03:43
get real js type
function type(obj) {
var toString = Object.prototype.toString;
var map = {
'[object Boolean]' : 'boolean',
'[object Number]' : 'number',
'[object String]' : 'string',
'[object Function]' : 'function',
'[object Array]' : 'array',
'[object Date]' : 'date',
'[object RegExp]' : 'regExp',
@bpceee
bpceee / scopeWalker.js
Last active March 31, 2017 06:37
walk angular 1.x scope tree
function scopeWalker(scope, op) {
var _walker = (scope) => {
op(scope);
var currentChildScope = scope.$$childHead;
while(currentChildScope) {
_walker(currentChildScope);
currentChildScope = currentChildScope.$$nextSibling;
}
}
_walker(scope);
@bpceee
bpceee / gist:5eebb82b40fb4abd450fab106352687d
Last active March 17, 2017 07:35
angular 1.x measure digest time
angular.element(document)
.injector()
.invoke(['$rootScope', function($rootScope) {
var a = performance.now();
$rootScope.$apply();
return performance.now()-a;
}])
angular.element(document)