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 / 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 / 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 / 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 / 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 / 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 / getelementbyxpath.js
Last active December 27, 2021 10:45
Javascript => getElementByXPath
document.getElementByXPath = function(sValue) { var a = this.evaluate(sValue, this, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); if (a.snapshotLength > 0) { return a.snapshotItem(0); } };
document.getElementsByXPath = function(sValue){ var aResult = new Array();var a = this.evaluate(sValue, this, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);for ( var i = 0 ; i < a.snapshotLength ; i++ ){aResult.push(a.snapshotItem(i));}return aResult;};
document.removeElementsByXPath = function(sValue) { var a = this.evaluate(sValue, this, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for ( var i = 0 ; i < a.snapshotLength ; i++ ) { a.snapshotItem(i).parentNode.removeChild(a.snapshotItem(i)); } };