Skip to content

Instantly share code, notes, and snippets.

@mitio
mitio / deploy.rb
Created August 23, 2013 15:38
Sidekiq + Capistrano + Ubuntu Upstart
# config/deploy.rb
namespace :upstart do
desc 'Generate and upload Upstard configs for daemons needed by the app'
task :update_configs, except: {no_release: true} do
upstart_config_files = File.expand_path('../upstart/*.conf.erb', __FILE__)
upstart_root = '/etc/init'
Dir[upstart_config_files].each do |upstart_config_file|
config = ERB.new(IO.read(upstart_config_file)).result(binding)
@mitio
mitio / devise.bg.yml
Last active December 1, 2018 09:55
Devise Bulgarian Translation
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
bg:
devise:
confirmations:
confirmed: "Вашият профил беше успешно потвърден. Влязохте успешно в него."
send_instructions: "Ще получите писмо с инструкции как да потвърдите вашия профил до няколко минути."
send_paranoid_instructions: "Ако вашият имейл адрес съществува в базата ни, ще получите там инструкции как да потвърдите вашия профил."
failure:
already_authenticated: "Вече сте влязъл в профила си."
@mitio
mitio / one_liners_from_hell.sh
Created April 2, 2013 13:54
Clumsy one-liners from hell
grep -E '^Listen ' /usr/local/etc/apache/httpd.conf | sed 's/:/./' | sed 's/Listen //' | ruby -e 'conns = []; while conn = gets; conns << conn.strip; end; system "netstat -an|grep tcp|grep -v LISTEN|grep -E \"\\b#{conns.join "\\b|\\b"}\\b\"";' | awk '{ print $5 }' | ruby -e 'conns = Hash.new(0); while conn = gets; parts = conn.strip.split("."); ip = parts[0..-2].join("."); port = parts[-1]; conns[ip] += 1; end; conns.sort_by { |ip, count| -count }.each { |ip, count| puts "IP: #{ip.ljust(25)} connections: #{count}" } ;nil'
@mitio
mitio / projects_instructions.md
Last active October 13, 2015 03:57
Указания за проектите към курса "Програмиране с Руби"

В този документ ще събираме някои указания, които да ви насочат в избора на тема и в писането на вашите проекти към курса "Програмиране с Ruby".

Игри и друг GUI intensive софтуер

Когато сте избрали да пишете неща, наподобяващи игри — или каквито и да е други проекти, изискващи сериозно GUI — постарайте се да "откачите" основния си код максимално много от рисуването/графиката/GUI-то. Целта ви е да имате много ясно разделение и абстракция между "ядрото" на вашия проект и графичния му интерфейс. Добре би било основната логика на проекта ви да се намира изцяло в "ядрото", под формата на класове, модули и прочее, като това ядро предоставя на своите позлватели някакво API. Тоест, стремите се да пишете въпросното ядро все едно пишете библиотека, която ще се преизползва в друг(и) софтуер(и). От там нататък, GUI-то се прави като wrapper на тази библиотека, ползва публичното й API и е един вид pluggable компонент към нея.

Можете да минете и само с кода от основното ядро, който имплементира

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<title></title>
<style type="text/css">
#wrapper { padding-top: 650px; background-color:#ddd;}
</style>
<script src="/javascripts/zepto.js"></script>
<script>
@mitio
mitio / backup_project.sh
Created October 21, 2012 18:11
Simple database backup script for our teaching websites' DBs
#!/bin/sh
PROJECT=$1 # E.g. pyfmi
EDITION=$2 # E.g. 2012
if [ -z "$PROJECT" ]
then
echo Usage: $0 project edition
echo E.g.: $0 pyfmi 2012
exit 1
@mitio
mitio / ByteArrayCopyTest.java
Created October 19, 2012 16:07
Tests for copying byte[] arrays
public class ByteArrayCopyTest {
private static long timeMark;
public static void main(String[] args) {
byte[] source = new byte[1000000];
byte[] target = new byte[1000000];
start();
for (int n = 0; n < 10000; n++) {
// System.arraycopy(source, 0, target, 0, source.length);
@mitio
mitio / gist:3766533
Created September 22, 2012 15:30
Deedee HDD drives
Drive serial number, Replacements/Status
Seagate 9QM26CQR -> "BSY" error, replaced with 9vmp5c4l
Seagate 9QM29AC6 -> failed, the heads are scratching the plates
Seagate 9QM29G0S -> repladed with 9qm8xcc6 -> replaced with 9vmgsjm8
Seagate 9QM2B8F7 -> failed, bad sectors after ~200th GB
@mitio
mitio / sync-bff-files.c
Created August 14, 2012 10:44
Quick sync tool to be run in "Set UID" mode for a specific purpose
#include <stdio.h>
int main()
{
setuid(0);
printf("Starting...\n");
// Create directories
system("find /wow/deian/BFF -type d | sed -e 's/\\/deian//' | while read folder; do echo Creating folder $folder; mkdir -p $folder; done");
@mitio
mitio / 37signals_ideology_and_profits.md
Created August 3, 2012 21:58
On 37signals' "No Free Accounts" Policy

I've always liked 37signals as a company a lot and today they just shattered my affection for them into pieces.

Teaching programming voluntarily

We're a small group of volunteers teaching programming at a university in Bulgaria. Today we asked 37signals if they would provide us with a free Basecamp account. The account would help us coordinate our team teaching efforts and let us provide the students with more knowledge more efficiently.

As we're not getting paid anything for this by the university (although students get credits for our courses) and as we don't have any budget for course expenses (on the contrary—we pay from our own pockets in order to bring Ruby, Python and Clojure to the curriculum), we asked for a non-trial basic account pro bono.

No free accounts, no matter what