Skip to content

Instantly share code, notes, and snippets.

@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 / 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 /- / || \ /
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 / 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'
@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 / hooks
Last active December 29, 2015 12:59
Hooks for videatra
Hooks in comments
@mzdravkov
mzdravkov / rails_associations_rocks.rb
Last active December 26, 2015 14:19
Some associations code that doesn't want to work.
class GroupCalendar < Calendar # Calendar inherits ActiveRecord:Base
has_and_belongs_to_many :users
has_many :sub_inheritances
# has_many :sub_calendars, through: :sub_inheritances, as: :calendarable # <- this line should be as the following:
has_many :sub_calendars, through: :sub_inheritances, source: :calendarable, source_type: :Calendar
end
class SubInheritance < ActiveRecord::Base
@mzdravkov
mzdravkov / pathfinder
Last active December 24, 2015 02:19
An attempt (fail) to create ultra simple path finding algorithm in maze in Clojure.
; 'from' is the current point of search, 'to' is the target, level is the maze/2DMatrix
(defn pathar
([level from to] (pathar level from to []))
([level from to path]
(if (= from to)
path
(let [nb (valid-neighbours level from)] ;valid neighbours returns the indexes of all valid (in the 2dmatrix) neighbour elements.
(pmap #(pathar level % to (cons from path)) nb)))))
(defn move-boxes
([[box & cboxes] pos] (move-boxes box cboxes pos))
([box cboxes pos]
(do some things)
(if (> pos 0)
(move-boxes box cboxes (dec pos))
(move-boxes cboxes (dec pos)))))
@mzdravkov
mzdravkov / .profile
Created September 26, 2013 07:59
My .profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022