Skip to content

Instantly share code, notes, and snippets.

View holywarez's full-sized avatar
👨‍💻

Anatoly Lapshin holywarez

👨‍💻
View GitHub Profile
package models.processing
import com.itextpdf.text.io.RandomAccessSource
import play.api.libs.ws._
import concurrent.Await
import concurrent.duration._
class S3RandomStream(remoteUrl:String) extends RandomAccessSource {
override def close(): Unit = {}
override def get(position: Long): Int = {
object Experimental extends Controller {
implicit def FiniteDuration2Long(value: FiniteDuration) = value.toMillis
def test = Action {
Ok(views.html.experimental.test(longCalculations))
}
def longCalculations: String = {
val future = flow {
Thread.sleep(10.seconds)
class Publish::ProcessingTask < ProcessingTask
attr_accessible :product, :action
def action= action_name
self.name = action_name
end
private
def lookup_background_worker
@media screen and (max-width:780px) {
.remix-ui {
.remix-cart .cart.wrapper {
.promo.for-intro {
display: none !important;
}
}
.drop-zone {
font-size: 80%;
def star_for(rating, star_number)
if rating > star_number
'empty.png'
elsif rating > star_number - 1
'half.png'
else
'full.png'
end
end
RSpec.configure do |config|
config.before(:each, mailer: true) do
ActionMailer::Base.deliveries.clear
end
RSpec::Matchers.define :send_email do
chain :to do |target|
@target = target
end
git log --date=short --pretty=format:'%an%x09%ad%x09%s' | grep 'Anatoly Lapshin' | grep -E '(fix: )|(done: )'
@holywarez
holywarez / ability.rb
Created April 5, 2012 19:30
Paradigm App
# lib/ability.rb
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
case user.role
when 'manager':
can [:cancel, :delivery_initiated, :received], Order
@holywarez
holywarez / capybara cheat sheet
Created February 22, 2012 09:00 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=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')
@holywarez
holywarez / dsl.rb
Created February 17, 2012 18:52
Fears
module ::Fears
mattr_accessor :enabled
self.enabled = true
class JustifiedException < ::RuntimeError
end
class Result
attr_accessor :result
def initialize result