This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkill -f datetime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = 'aaaabbbbccccpqesrt'; | |
var compressedString = ''; | |
var s = input.match(/([a-zA-Z])\1*/g) || []; | |
s.forEach(function(value) { | |
var k = ''; | |
if(value.length > 1) { | |
k = value.length; | |
} | |
compressedString += value.charAt(0) + k; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= select 'time_range', 'id', Hash.map { |r| [r[:label], r[:name]] }, {selected: params[:time_range], include_blank: true}, {'data-placeholder': 'Select Time Range'} %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("textarea.growable") | |
.on('keyup paste input', function () { | |
let self = $(this); | |
let offset = self.innerHeight() - self.height(); | |
if (self.innerHeight() < this.scrollHeight) { | |
//Grow the field if scroll height is smaller | |
self.height(this.scrollHeight - offset); | |
} else { | |
//Shrink the field and then re-set it to the scroll height in case it needs to shrink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SignTool { | |
constructor() { | |
this.initVars(); | |
this.initEvents(); | |
} | |
initVars() { | |
this.canvas = $('#canvas')[0]; | |
this.ctx = this.canvas.getContext("2d"); | |
this.isMouseClicked = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var keys = [8, | |
46, | |
48, | |
49, | |
50, | |
51, | |
52, | |
53, | |
54, | |
55, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires https://medialize.github.io/URI.js | |
function updateURL(url, params) { | |
let new_url = new URI(url); | |
$.each(params, function (value) { | |
if (params[value] !== undefined) { | |
new_url.setSearch(value, params[value]); | |
} else { | |
new_url.removeSearch(value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let videos = $(".wpl-youtube"); | |
$.each(videos, function () { | |
let self = $(this); | |
let thumbnail = self.find('img'); | |
let play = self.find('.wpl-play'); | |
// Based on the YouTube ID, we can easily find the thumbnail image | |
thumbnail.attr('src', 'https://i.ytimg.com/vi/' + self.attr('data-id') + '/0.jpg'); | |
play.on({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PARENS = { | |
"(" => ")", | |
"{" => "}", | |
"[" => "]" | |
} | |
OPENING_PARENS = PARENS.keys | |
CLOSING_PARENS = PARENS.values | |
def valid_parentheses(string) | |
stack = [] | |
string.each_char do |ch| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str = "aabbbaa" | |
count = Hash.new(0) | |
str.each_char { |c| count[c] += 1 } | |
puts count |
OlderNewer