Skip to content

Instantly share code, notes, and snippets.

View vermilion1's full-sized avatar

Vitalii Petrychuk vermilion1

View GitHub Profile
// 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();
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;
#!/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:
/**
* 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;
/**
* 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;
@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 = []);
@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 / gist:af0a9acbcd24edcdc82c
Created August 21, 2014 17:38
Update search parameter
/**
* Update the param value of the passed URI.
* In case parameter wasn't found we have to add it.
* @param {string} uri - URI.
* @param {string} key - Parameter name.
* @param {string} value - Parameter value.
* @returns {string} Updated URI.
*/
var updateQueryStringParameter = function (uri, key, value) {
var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
/*global define */
/*jshint expr:true */
define([], function () {
'use strict';
var hasLocalStorageSupport = (function () {
var str = 'storage-test-' + Math.random();
try {
@vermilion1
vermilion1 / gist:7583811
Created November 21, 2013 15:38
Print image
@page {
size: auto;
margin: 0;
}
@media screen, print {
html,
body {
height: 100%;
}
body {