This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Place this file inside your ~/.idlerc/ folder | |
# or paste its contents inside | |
# /path/to/python/idlelib/config-highlight.def | |
# Adapted from SublimeText's Monokai | |
[monokai] | |
normal-foreground= #F8F8F2 | |
normal-background= #272822 | |
keyword-foreground= #F92672 | |
keyword-background= #272822 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if request.xhr? | |
# renders :template_partial without layout.html | |
slim :template_partial, :layout => false | |
else | |
# renders as normal inside layout.html | |
slim :template_partial | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'dm-core' | |
require 'haml' | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Message | |
include DataMapper::Resource | |
property :id, Serial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# В системе авторизации есть ограничение: | |
# логин должен начинаться с латинской буквы, | |
# состоять из латинских букв, цифр, точки и минуса, | |
# но заканчиваться только латинской буквой или цифрой; | |
# минимальная длина логина — один символ, максимальная — 20. | |
# Напишите код, проверяющий соответствие входной строки этому правилу. Придумайте несколько способов решения задачи и сравните их. | |
class AuthOne | |
def initialize login | |
@login = login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# paths | |
app_path = "/home/deployer/qna" | |
working_directory "#{app_path}/current" | |
pid "#{app_path}/current/tmp/pids/unicorn.pid" | |
# listen | |
listen "/tmp/unicorn.qna.sock", backlog: 64 | |
# logging | |
stderr_path "log/unicorn.stderr.log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Unicorn ### | |
check process unicorn | |
with pidfile "/home/deployer/qna/current/tmp/pids/unicorn.pid" | |
start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && RAILS_ENV="production" /home/deployer/.rbenv/bin/rbenv exec bundle exec unicorn -c /home/deployer/qna/current/config/unicorn/production.rb -E deployment -D'" | |
stop program = "/bin/su - deployer -c 'kill -0 `cat /home/deployer/qna/current/tmp/pids/unicorn.pid`'" | |
if memory usage > 90% for 3 cycles then restart | |
if cpu > 90% for 2 cycles then restart | |
if 5 restarts within 5 cycles then timeout | |
### Nginx ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://askubuntu.com/questions/505446/how-to-install-ubuntu-14-04-with-raid-1-using-desktop-installer | |
# http://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-64-bit-with-a-dual-boot-raid-1-partition-on-an-uefi%5D | |
sudo -s | |
apt-get -y install mdadm | |
apt-get -y install grub-efi-amd64 | |
sgdisk -z /dev/sda | |
sgdisk -z /dev/sdb | |
sgdisk -n 1:0:+100M -t 1:ef00 -c 1:"EFI System" /dev/sda | |
sgdisk -n 2:0:+4G -t 2:fd00 -c 2:"Linux RAID" /dev/sda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## just some ways to check if a url exists | |
# method 1 - from Simone Carletti | |
require "net/http" | |
url = URI.parse("http://www.google.com/") | |
req = Net::HTTP.new(url.host, url.port) | |
res = req.request_head(url.path) | |
# method 2 - from some kid on the internet | |
require 'open-uri' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04 | |
# Inspired from https://gist.github.com/faleev/3435377 | |
# Remove any existing packages: | |
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev | |
# Get the dependencies (Ubuntu Server or headless users): | |
sudo apt-get update |
OlderNewer