Skip to content

Instantly share code, notes, and snippets.

@aminin
aminin / example.rb
Created July 25, 2013 13:02
Multithread amazon s3 bucket copier + EventMachine patch for Fog::Connection
require './s3-bucket-copier'
credentials = {
:provider => "AWS",
:region => "eu-west-1",
:aws_access_key_id => "<KeyId>",
:aws_secret_access_key => "<KeySecret>"
}
connection = ::Fog::Storage.new(credentials)
# Годный метод для сериализации в yaml Mail::Message
class Mail::Message
# @return [String]
def to_yaml
hash = {}
hash['headers'] = {}
header.fields.each do |field|
hash['headers'][field.name] = field.value
end
@aminin
aminin / install.sh
Created January 15, 2013 09:30
English Russian Full Dictionary for Stardict on Ubuntu 12.04
# Установка англо-русского словаря на Ubuntu
sudo apt-get install stardict
wget http://sourceforge.net/projects/xdxf/files/dicts-stardict-form-xdxf/002c/stardict-comn_sdict05_eng_rus_full-2.4.2.tar.bz2/download
tar -xjf download
sudo mv stardict-eng_rus_full-2.4.2/ /usr/share/stardict/dic/
sudo chmod -R a+r /usr/share/stardict/dic/
# Спасибо http://forum.ubuntu.ru/index.php?topic=2587 и http://sourceforge.net/projects/xdxf/
@aminin
aminin / git.md
Last active October 30, 2019 21:48
RTFM по Git. Отрыл в старых записях.

Правила работы с Git

Источники

Имена и адреса авторов правок

@aminin
aminin / Gemfile
Last active December 10, 2015 06:39
Тестовое приложение на Синатре
# A sample Gemfile
source "https://rubygems.org"
gem "sinatra"
gem "sinatra-synchrony"
gem "thin"
@aminin
aminin / branch-killer.sh
Created June 29, 2012 10:51
Убийца слитых веток
#!/bin/bash
# Чистит локальные слитые ветки
for i in `git branch | grep "^[^*]\+"`; do git branch -d $i; done;
# Чистит слитые ветки в удалённом репозитории
git log --pretty=format:%H HEAD~1 > /tmp/git-history.txt
for i in `git br -r | grep -o "[^ \/]\+$" | sort | uniq`;
do
@aminin
aminin / README.md
Created June 28, 2012 14:49
Приложение к задаче по SQL

Приложение к задаче по SQL

Задача

В БД есть пользователи и группы, между ними связть многие ко многим, нужно выбрать группы, где есть и Коля и Петя.

Порядок решения

@aminin
aminin / .gitignore
Created May 11, 2012 11:25
Vagrant box builder for ubuntu-12.04
build/
*.box
*.iso
@aminin
aminin / Event.php
Created March 28, 2012 17:59
Пример применения докблоков
<?php
/**
* Событие с полезной нагрузкой
*
* PHP 5.3
*
* Это докблок файла.
* Если бы этого блока не было, phpDocumentor был бы недоволен.
* Здесь могла быть упомянута лицензия MIT.
*
@aminin
aminin / checkExceptionStackTrace.php
Created March 28, 2012 14:41
Стек вызовов при пробрасывании исключений
<?php
// Этот пример демонстрирует понятие "цепочки исключений"
// Показывает сохранение стэка вызовов (stack trace) при оборачивании исключений
function a()
{
try {
b();