Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tit's full-sized avatar

TIT tit

  • Russia, Rostov-on-Don
View GitHub Profile
@tit
tit / material-light-blue_patch.css
Created July 5, 2021 16:35
Patch for material-light-blue.css for Jenkins
@import url(https://fonts.googleapis.com/css?family=Roboto:400,700,500,300);@import url(https://fonts.googleapis.com/css?family=Roboto+Mono:400,700,500,300);@keyframes a{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes b{0%{opacity:1}50%{opacity:0}to{opacity:1}}[src$="blue.png"]{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjMDA5Njg4IiBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnptLTIgMTVsLTUtNSAxLjQxLTEuNDFMMTAgMTQuMTdsNy41OS03LjU5TDE5IDhsLTkgOXoiLz48L3N2Zz4=)}[src$="red.png"]{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjRjQ0MzM2IiBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnptMSAxNWgtMnYtMmgydjJ6bTAtNGgtMlY3aDJ2NnoiLz48L3N2Zz4=)}[src$="yellow.png
@tit
tit / set_sensitivity.ts
Last active February 1, 2021 07:29
Create AntiFool Button
function setSensitivity(element: HTMLElement, callback: () => void, timeout: number = 500): void {
let sensitivityTimer: number;
element
.addEventListener('mousedown', () => {
sensitivityTimer = setTimeout(callback, timeout);
});
element
.addEventListener('mouseup', () => {
@tit
tit / swing_lesson_generator.html
Last active January 21, 2020 08:51
Swing Lesson Generator
<head>
<meta charset="utf-8">
<script>
const notes = [
'<note applicature="left">♪</note>',
'<note applicature="kick">♪</note>',
'<pause>.</pause>'
];
@tit
tit / note_generator.rb
Created January 20, 2020 18:59
note generator
notes = %w[♪ .]
4.times do
3.times do
measures = []
4.times do
measures.push "#{notes.sample}.#{notes.sample} #{notes.sample}.#{notes.sample} #{notes.sample}.#{notes.sample} #{notes.sample}.#{notes.sample} | "
end
puts measures.join
end
@tit
tit / case_uri_regexp.rb
Created November 5, 2019 11:55
Case URI Regexp
# frozen_string_literal: true
url_string = 'https://example.com/foo'
url_object = URI url_string
# false
puts case url_object
when %r{^https://example\.com}
true
else
@tit
tit / just_a_fun.rb
Created November 1, 2019 09:53
just a fun
def print string
puts string
end
def to string
string
end
def console string
string
@tit
tit / numeric.rb
Created November 2, 2018 11:10
Convert numeric to formatted string with cash unit by format
# frozen_string_literal: true
# Numeric
class Numeric
# convert numeric (integer or float)
# to formatted string with cash unit
#
# @example
# 42_000.to_cash '$', ',', '.', '%<unit>s%<amount>.2f' # => $42.000,00
# 42_000.42.to_cash 'RUB', ',', ' ', '%<amount>.2f %<unit>s' # => 42 000,42 RUB
@tit
tit / calltools.rb
Last active September 1, 2018 12:39
CallTools API Client
# http-cookie need for Max-Age
# @see https://github.com/nahi/httpclient/issues/242#issuecomment-69020815
require 'http-cookie'
require 'httpclient'
require 'json'
require 'symbolize_keys_recursively'
# CallTools
module CallTools
# CallTools API Client
@tit
tit / coin.rb
Created June 1, 2017 12:49
To toss a coin and execute the code ... or not ...
# execute yield or not
# @return [Mixed]
# @example coin { Hamlet.new.to_be }
def coin
yield if [true, false].sample
end
@tit
tit / sleep.js
Created June 21, 2015 15:32
Sleep in JS
Number.prototype.times = function (cb) { for (var i = 0; i < +this; i++) {cb(i)} }
function sleep(ms) {var date = Date.now(); while (Date.now() - date < 1000*ms) {} }
/* example use/*
10..times(function(i){sleep(1); console.log(i);})