Skip to content

Instantly share code, notes, and snippets.

View vermilion1's full-sized avatar

Vitalii Petrychuk vermilion1

View GitHub Profile
@vermilion1
vermilion1 / timer.js
Created August 21, 2014 17:44
Advanced timer with ability to pause/resume the callback
/**
* Advanced timer with ability to pause/resume the callback.
* @param {function} callback - Callback to be executed after some delay.
* @param {number} delay - Delay.
* @returns {Object} Timer object with useful methods.
*/
var timer = function (callback, delay) {
var isPaused = true;
var timer, start, clear, pause, resume;
@vermilion1
vermilion1 / highlight.js
Last active August 29, 2015 14:13
Highlight string parts
/**
* Highlight passed array's strings in the passed string.
* @param {string} string - Original string.
* @param {Array<string>} matched - List of items to highlight.
* @returns {string} Highlighted string.
*/
highlightStr: function (string, matched) {
string || (string = '');
matched || (matched = []);
/**
* Get all items starting from the passed index that are located in the same top line.
* @param {jQuery} $items - List of elements.
* @param {Number} index - Index of the first element.
* @returns {Array|undefined} Found items.
*/
getLineItems: function ($items, index) {
var $first = $items.eq(index);
var items = [$first];
var $next, getNext, top;
/**
* Check if element fully visible.
* @param {jQuery} $el.
* @returns {boolean} Is visible or not.
*/
isScrolledIntoView: function ($el) {
var $window = $(window);
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $el.offset().top;
#!/usr/bin/env node
/**
* Hooks:
* https://www.kernel.org/pub/software/scm/git/docs/githooks.html#_prepare_commit_msg
*
* Colors:
* http://telepathy.freedesktop.org/doc/telepathy-glib/telepathy-glib-debug-ansi.html
*
* Message format:
const fs = require('fs');
const args = process.argv.slice(2);
const [filename] = args;
fs.readFile(filename, 'utf8', (err, data) => {
if (err) {
return console.log(err);
}
let r = 0;
// Name: Make a fkn break
// Menu: Make a fkn break
// Schedule: */15 * * * *
import "@johnlindquist/kit"
const duration = 15; // 15 seconds
const openFrame = async () => {
const startDate = Date.now();