Skip to content

Instantly share code, notes, and snippets.

View lisovskyvlad's full-sized avatar

Lisovskii Vladislav lisovskyvlad

View GitHub Profile

Blogging with octopress:

  • new post: bundle exec rake new_post["title"]
  • write stuff
  • bundle exec rake preview
  • git add .
  • git commit -m 'add awesome post'
  • git push origin source
  • bundle exec rake generate
  • bundle exec rake deploy
// SHA Hash presence web server.
//
// Requires a file containing sorted sha1s in binary form (20 bytes each).
package main
import (
"encoding/hex"
"fmt"
"io/ioutil"
#! /usr/bin/python
# coding: utf-8
import codecs
import re
from string import punctuation
import collections
import sys
punctuation_regexp = re.compile(r'[\s{}]+'.format(re.escape(punctuation)))
=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')
@lisovskyvlad
lisovskyvlad / counter.rb
Created November 23, 2015 23:56 — forked from lexmag/counter.rb
Terribly simple Sinatra streaming
require 'sinatra'
set server: :thin
get '/' do
erb :welcome
end
get '/stream', provides: 'text/event-stream' do
stream do |out|
loop do
@lisovskyvlad
lisovskyvlad / application.js
Created November 23, 2015 23:56 — forked from lexmag/application.js
Rails streaming
//= require jquery
//= require jquery_ujs
$(function() {
var source = new EventSource('/stream');
source.addEventListener('counter', function(e) {
$('body').after(e.data + '<br />');
});
});
@lisovskyvlad
lisovskyvlad / database.yml
Created February 3, 2013 10:59
dry database.yml
common: &common
encoding: unicode
adapter: postgresql
username: #{user_name}
password: #{password}
host: localhost
development:
<<: *common
database: db_dev
# encoding: UTF-8
require 'singleton'
class Cats
include Singleton
def initialize
@cat = { name: 'Alice', sex: 'F' }
end
require 'active_record'
require 'pg'
require 'roo'
ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:host => 'localhost',
:username => 'kevin',
:database => 'tinkov_dev',
:password => '123'
@lisovskyvlad
lisovskyvlad / Dockerfile
Created December 22, 2015 09:33
Good example of dockerfile for ruby in drone.
FROM ruby:2.2
RUN gem update --system && gem install bundler
RUN sed -i 's/deb http:\/\/httpredir.debian.org\/debian jessie main/deb http:\/\/httpredir.debian.org\/debian jessie main non-free/' /etc/apt/sources.list
RUN sed -i 's/deb http:\/\/security.debian.org jessie\/updates main/deb http:\/\/security.debian.org jessie\/updates main non-free/' /etc/apt/sources.list
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash - && apt-get install -y nodejs unrar && npm install -g phantomjs