Skip to content

Instantly share code, notes, and snippets.

@A
A / gh-delete-repo.js
Created October 13, 2019 09:17
Just a js snippet to automagically remove opened repository
const sleep = (t) => new Promise((resolve, reject) => {
setTimeout(resolve, t);
});
(async () => {
$('a[data-selected-links*=key_links_settings]').click();
await sleep(3000);
document.querySelectorAll('summary.btn-danger')[2].click();
await sleep(3000);
const name = document.querySelectorAll('.Box-body.overflow-auto p strong')[2].textContent;
const toMs = (h, m) => {
let ms = 0;
ms += h * 60 * 60 * 1000;
ms += m * 60 * 1000;
return ms;
}
export const isInTimeRange = (from, to, date = new Date()) => {
const d = toMs(date.getUTCHours(), date.getUTCMinutes());
const start = toMs(from.hours, from.mins);
const nonUniqueArr = [1,2,3,4,5,4,3,5,6];
const indexOfUnique = (arr) => arr
.filter((item, index, a) => a.indexOf(item) === index);
const newSetUnique = (arr) => [...new Set(arr)];
const fromUnique = (arr) => Array.from(new Set(arr));
const seenUnique = (arr) => {
@A
A / lsmod
Last active May 10, 2017 19:29
Module Size Used by
btusb 36864 0
btrtl 16384 1 btusb
btbcm 16384 1 btusb
btintel 16384 1 btusb
bluetooth 323584 5 btbcm,btrtl,btusb,btintel
binfmt_misc 16384 1
mwifiex_usb 20480 0
mwifiex 196608 1 mwifiex_usb
cfg80211 348160 1 mwifiex
@A
A / index.js
Created December 6, 2015 10:07
var http = require('http'),
express = require('express'),
httpProxy = require('http-proxy'),
url = require('url');
var selects = [];
var simpleselect = {};
simpleselect.query = 'body';
@A
A / loop.js
Created November 4, 2015 13:34
var i = 0;
while (true) {
if ((i <= 9) === false) break;
console.log(i);
i = i + 1;
}
// put your evil code to break the loop here:
// …
@A
A / require.js
Created October 29, 2015 16:09
javascript:(function(){var body=document.getElementsByTagName('body')[0];var script=document.createElement('script');script.type='text/javascript';script.src='https://s3.amazonaws.com/s3.mathisonian.com/javascripts/requirify-browser.js';body.appendChild(script);})();
new Test('Hello World', 200); // try to change offset
function Test(str, offset) {
var i = 0;
var $search = $('.sel-search-input');
$search.val('').focus();
(function next() {
setTimeout(function() {
if (i >= str.length) return;
@A
A / fuck_you_books.ru.js
Created September 19, 2015 22:25
Just script to download all my purchases.
$('a.pdf').each(function(_,i) {
var i = $('<iframe />')
.attr('src', i.href)
.load(function () {
i.contents().find('[name="agreed"]').click();
i.contents().find('[type="submit"]').click();
})
.appendTo('body')
;
});
return !filterValue || this.props.matchPos === 'start'
? this.props.matchProp !== 'label'
&& valueTest.toLowerCase().substr(0, filterValue.length) === filterValue || this.props.matchProp !== 'value'
&& labelTest.toLowerCase().substr(0, filterValue.length) === filterValue
: this.props.matchProp !== 'label' && valueTest.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0
|| this.props.matchProp !== 'value' && labelTest.toLowerCase().indexOf(filterValue.toLowerCase()) >= 0;