Skip to content

Instantly share code, notes, and snippets.

View rafaltrojanowski's full-sized avatar
🛰️
KISS (BUZI), DRY, SOLID, YAGNI, TDD

Rafał Trojanowski rafaltrojanowski

🛰️
KISS (BUZI), DRY, SOLID, YAGNI, TDD
View GitHub Profile
require 'time'
input = "07:05:45PM"
puts Time.strptime(input, "%r").strftime("%H:%M:%S")
input = "saveChangesInTheEditor"
def count_words(string)
s = string.split /(?=[A-Z])/
s.size
end
puts count_words(input)
@rafaltrojanowski
rafaltrojanowski / ffmpeg-install.sh
Created November 14, 2017 05:51 — forked from clayton/ffmpeg-install.sh
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
# Easy Peasy
ffmpeg -i video.mp4 video.webm
def solution(A):
for i, v in enumerate(sorted(A)):
if i + 1 != v:
return 0
return 1
def solution(x, a)
hash = {}
(1..x).each do |v|
hash[v] = 1
end
a.each_with_index do |value, index|
if hash[value]
hash.delete(value)
@rafaltrojanowski
rafaltrojanowski / MaxCounters
Last active November 26, 2017 09:24
MaxCounters
def solution(n, a)
arr = [0] * n
max = 0
a.each do |element|
if element <= n
arr[element-1] += 1
if arr[element-1] > max
max = arr[element-1]
def solution(a)
# write your code in Ruby 2.2
i = 1
hash = {}
a.each do |element|
hash[element] = 1
end
while 1 do
def solution(a)
sum = 0
sum = a.inject(&:+)
l = 0
r = 0
p = 0
ret = nil
def solution(a)
((1..a.size + 1).to_a - a).first
end
def solution(a)
hash = {}
a.each do |element|
if hash[element].nil?
hash[element] = 1
else
hash[element] += 1
end