Skip to content

Instantly share code, notes, and snippets.

View gentoid's full-sized avatar
😃

Viktor Lazarev gentoid

😃
View GitHub Profile
<?php
class App_ArrayInterfaceTest extends PHPUnit_Framework_TestCase {
public function testArrayInterface() {
$mock = $this->getMock('App_ArrayInterface');
$this->assertTrue($mock instanceof App_ArrayInterface);
$interface = new ReflectionClass('App_ArrayInterface');
$this->assertTrue($interface->hasMethod('toArray'));
=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')
@gentoid
gentoid / new.html.haml
Created July 18, 2014 08:09
simple HAML temlate
= form_for :article, url: articles_path do |f|
= @article
- if @article.errors.any?
#error_explanation
%h2 Ошибки при создании статьи:
%ul
- @article.errors.full_messages.each do |msg|
%li
= msg
%p
@gentoid
gentoid / environment.rb
Last active August 29, 2015 14:07
Environment
class Environment
attr_reader :vars, :parent
def initialize(parent = nil)
@parent = parent
@vars = parent ? parent.vars.clone : {}
end
def extend_env
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCi5GB0RhKDDKGZ2zPjw7Mw13EF/KQIHcWqaZ5GZ+DCqXMky5qdK+JO0ZLFZha0a+K0zESbAIhi4FPNRccg3Bh+bFx9HWpyoXTgdQpYgpAIIuOJRLfdI3IUvXzrmejTKwBxYTl1wv3OvvWaFZTFSOaAf6Hfs5/MbNJoua1XuKv6jydehEmDhcfLWUixlOeojut8ehK8PB5A9NknztxmLs5QNygtVrOWbirJ4u2EgZbX3Y7trGBb9H1LdW1iJ6xG5QuvY9sxrBSFNd0/vitJ+dMR6WHQsQzzbZZbs6g849NqVpMb1g1mCyknkxCMsCbSNmo81BBoz3oQHMTjE0/6NWSX viktor@linux
@gentoid
gentoid / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gentoid
gentoid / introrx.md
Last active August 29, 2015 14:16 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@gentoid
gentoid / app.po
Created June 1, 2015 12:39
gettext
# English translations for Retina package.
# Copyright (C) 2015 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the Retina package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2015.
#
msgid ""
msgstr ""
"Project-Id-Version: Retina 0.33.2-26-g8a4bb2a\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-01 16:37+0400\n"
@gentoid
gentoid / sample.coffee
Created June 25, 2015 14:02
CoffeeScript + jQuery event handling
# 1. trigger events
$(document).trigger 'flash:message', { level: 'error', message: 'There was an error' }
# 2. catch events in another place
$(document)
.on 'flash:message', (e, params) =>
if params.level && params.message
@show params.level, params.message # call 'show' method doing something interesting :-)
body {
font-size: 5vw;
}
@media (max-width: 700px) {
body {
font-size: 35px;
}
}
@media (min-width: 3000px) {
body {