Skip to content

Instantly share code, notes, and snippets.

@mzdravkov
mzdravkov / hooks
Last active December 29, 2015 12:59
Hooks for videatra
Hooks in comments
@mzdravkov
mzdravkov / songs_to_videos.rb
Created December 7, 2013 23:06
A small script that takes source_dir, image, destination_dir. All it do is to get all mp3s from the dir and convert them to music videos with one image for the whole song. Like the most youtube videos are. It's really handy if you need to upload a lot of songs to youtube.
if ARGV.member? 'help'
print <<-help
first argument is directory with all the songs you convert to videos
second argument is the image you want to put on the videos
third argument is directory where videos will be saved
help
else
dir_with_songs = ARGV[0]
image = ARGV[1]
output_dir = ARGV[2]
@mzdravkov
mzdravkov / lxc-attach_error
Created January 19, 2014 14:35
lxc-attach error
lxc-attach: No such file or directory - failed to open '/proc/5789/ns/pid'
lxc-attach: failed to enter the namespace
lxc-attach: No such file or directory - failed to open '/sys/fs/cgroup//lxc/lxc/f242c76fdaddcf4c235a3deda646bc64d3ee3a72f71470ce902c5be19c6c6ba5/tasks'
server {
listen 41013;
server_name xyz.com;
rewrite ^(.*) http://llama.xyz.com/$1 permanent;
}
server {
listen 80;
server_name llama.xyz.com;
# some config...
@mzdravkov
mzdravkov / solver.rb
Last active August 29, 2015 13:58
A script to help us pass our DB exam. Created mostly by d0ivanov with a little bit of help from me.
#====================================================================================
#==============================HERE BE DRAGONS=======================================
#
#
# __----~~~~~~~~~~~------___
# . . ~~//====...... __--~ ~~
# -. \_|// |||\\ ~~~~~~::::... /~
# ___-==_ _-~o~ \/ ||| \\ _/~~-
# __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
# _-~~ .=~ | \\-_ '-~7 /- / || \ /
@mzdravkov
mzdravkov / session.sh
Created April 28, 2014 01:08
wonders
# HERE I have network-manager and network-manager-gnome
me@hello-human:~$ sudo apt-get install ppp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
network-manager network-manager-gnome
The following NEW packages will be installed:
ppp
0 upgraded, 1 newly installed, 2 to remove and 163 not upgraded.
@mzdravkov
mzdravkov / math1
Last active August 29, 2015 14:06
2003's math olympiad
Can one find 4004 positive integers such that the sum of any 2003 of them is
not divisible by 2003?
Proof?:
Suppose we have 4004 positive integers (lets call them the set W), so that 2002 of them (the set T1) are of the type n∙2003 + 1 (where n is different for each of them) and 2002 of them (the set T2) are of the type m∙2003 + 2 (where m is different for each of them).
When we choose 2003 numbers from W, there will be an even number of T1s and an odd number of T2s or an odd number of T1s and an even of T2s.
So the two cases are:
Case 1:
nodes = %w[1 2 3 4 5 6 7 8]
constraints = {"1" => %w[3 6],
"2" => %w[1],
"4" => %w[3],
"5" => %w[3 4],
"6" => %w[1 3]}
edges = nodes.combination(2).to_a
nodes.map { |n| constraints[n].map { |c| edges.delete([n, c].sort) } if constraints[n] }
@mzdravkov
mzdravkov / schedule.jl
Last active August 29, 2015 14:22
schedule problem
# our schedule is 3D array with (5 workdays, 8 workhours, 4 positions) for dimensions
schedule = Array(Int, 5, 8, 4)
day = hour = position = 0
while true
schedule = Array(Int, 5, 8, 4)
remaining_hours = fill(20, 8)
bad_schedule = false
for day = 1:5, hour = 1:8, position = 1:4
intern = rand(1:8)
@mzdravkov
mzdravkov / schedule2.jl
Last active August 29, 2015 14:23
schedule problem 2
function pickrand(col)
index = rand(1:length(col))
col[index]
end
function isbusy(intern, busy, day_hours, day, hour)
for i = 1:length(busy[intern])
if busy[intern][i][1] == day && (busy[intern][i][2]-day_hours) <= hour < (busy[intern][i][3]-day_hours)
return true
end