Skip to content

Instantly share code, notes, and snippets.

View rafaltrojanowski's full-sized avatar
🌴
WHERE 1=1

Rafał Trojanowski rafaltrojanowski

🌴
WHERE 1=1
View GitHub Profile
@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(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)
def solution(A):
for i, v in enumerate(sorted(A)):
if i + 1 != v:
return 0
return 1
@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
input = "saveChangesInTheEditor"
def count_words(string)
s = string.split /(?=[A-Z])/
s.size
end
puts count_words(input)
require 'time'
input = "07:05:45PM"
puts Time.strptime(input, "%r").strftime("%H:%M:%S")
sample_input_0 = """
10
2
"""
sample_input_1 = """
100
2
"""
sample_input_2 = """
@rafaltrojanowski
rafaltrojanowski / weather_o_rama.rb
Created August 6, 2018 10:45 — forked from wulab/weather_o_rama.rb
Weather-O-Rama Inc.’s next generation, Internet-based Weather Monitoring Station
module Subject
def register_observer()
raise NotImplementedError
end
def remove_observer()
raise NotImplementedError
end
def notify_observers()
@rafaltrojanowski
rafaltrojanowski / .gitignore
Created August 6, 2018 16:24 — forked from zilkey/.gitignore
curry example - a way to do dependency injection using lambdas
Gemfile.lock
junk.*
@rafaltrojanowski
rafaltrojanowski / rotate.md
Created August 16, 2018 09:51 — forked from abhinavmsra/rotate.md
Rotating Server Logs

#Rotating Server Logs with LogRotate

Logrotate is a UNIX utility that does following operations:

  1. Rotates the log file when file size reaches a specific size or after a specified duration
  2. Continues to write the log information to the newly created file after rotating the old log file
  3. Compresses the rotated log files
  4. Specifies compression option for the rotated log files