Skip to content

Instantly share code, notes, and snippets.

@mitio
mitio / generate_test.py
Created February 10, 2012 23:24
Testgen-based test generator
# -*- coding: utf-8 -*-
import sys
import os
import os.path
from os.path import join, realpath
import random
from buildFromTex import main as build
from lib.textreader import TextTestReader as Reader
@mitio
mitio / rails_asset_pipeline_compiled_files.rb
Created March 7, 2012 11:14
Where the Rails' asset pipeline searches for asset files and how the config.assets.precompile directive works
# Test the result of config.assets.precompile
#
# Check which files will be regarded as "manifests" and thus precompiled and be
# available for standalone use via the /assets/<asset> URL when in production.
# Execute this code in your Rails console.
# First, you'll probably be in development mode, so add here your
# additional production precompile patterns you want to test against.
precompile = Rails.configuration.assets.precompile + [/^.+\.css$/, 'active_admin.js']
@mitio
mitio / gist:2377761
Created April 13, 2012 15:36
Windows Instructions
Здрасти :)
Малко бележки относно това какво съм сложил и как да си поддържате компютъра във форма.
1. Сложил съм легален Windows XP със Service Pack 2 (не е пиратски, съвсем легитимен си е)
2. Сложил съм антивирусна програма - Microsoft Security Essentials. От Microsoft e и е безплатна за хората, които
имат легален Windows. Не слагайте друга антивирусна или защитна програма, тази ви стига.
3. Сложил съм два браузъра - Google Chrome и Mozilla Firefox. Можете да ползвате който искате от двата, за да
@mitio
mitio / Gemfile
Created June 12, 2012 20:21
Rails 3.2 + RSpec 2.8 + Spork + Guard + Growl
group :development, :test do
gem 'rspec-rails'
gem 'factory_girl_rails', :require => false
gem 'shoulda-matchers'
end
group :development do
gem 'guard-rspec'
gem 'guard-spork'
# For Growl notifications
@mitio
mitio / routes.rb
Created July 26, 2012 08:10
Rails Routes Constraints By Subdomain
constraints(lambda { |req| req.host.to_s =~ /\Aadmin./ }) do
namespace :admin, :path => '/' do
root :to => 'dashboards#show' # => that's Admin::DashboardsController#show in app/controllers/admin/dashboards_controller.rb
resources :users # => Admin::UsersController in app/controllers/admin/users_controller.rb
resources :posts # => Admin::PostsController in app/controllers/admin/posts_controller.rb
end
end
@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

@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 / 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 / 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 / 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