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
/* bling.js */ | |
window.$ = document.querySelectorAll.bind(document) | |
Node.prototype.on = window.on = function (name, fn) { | |
this.addEventListener(name, fn) | |
} | |
NodeList.prototype.__proto__ = Array.prototype |
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
def sign_up(subdomain) | |
visit root_url(subdomain: false) | |
click_link 'Create Account' | |
fill_in 'Name', with: 'Denis' | |
fill_in 'Email', with: '[email protected]' | |
fill_in 'Password', with: 'pw' | |
fill_in 'Password confirmation', with: 'pw' | |
fill_in 'Subdomain', with: subdomain | |
click_button 'Create Account' |
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
# Пример файла в папке spec/factories | |
FactoryGirl.define do | |
factory :project do | |
sequence(:name) { |n| "My Project #{n}" } | |
client 'My Client' | |
archived false | |
end | |
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
RSpec.describe Account, type: :model do | |
describe 'validations' do | |
it { should validate_presence_of :owner } | |
it { should validate_presence_of :subdomain } | |
it { should validate_uniqueness_of :subdomain } | |
it { should allow_value('denis').for(:subdomain) } | |
it { should allow_value('test').for(:subdomain) } | |
it { should_not allow_value('www').for(:subdomain) } |
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://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
// MIT license | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; |
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
//events - a super-basic Javascript (publish subscribe) pattern | |
var events = { | |
events: {}, | |
on: function (eventName, fn) { | |
this.events[eventName] = this.events[eventName] || []; | |
this.events[eventName].push(fn); | |
}, | |
off: function(eventName, fn) { | |
if (this.events[eventName]) { |
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
import numpy as np | |
def cipher(text, alphabet='abcdefghijklmnopqrstuvwxyz', key=0): | |
result = "" | |
alphabet = alphabet.lower() | |
n = len(alphabet) | |
for char in text: | |
if char.isalpha(): | |
new_char = alphabet[(alphabet.find(char.lower()) + key) % n] |
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
import binascii | |
import itertools | |
def xor_strings(a, b): | |
return ''.join( | |
[chr(ord(x) ^ ord(y)) for x, y in zip(a, itertools.cycle(b))]) | |
def xor_hex_strings(a, b): |
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
import bitarray | |
import itertools | |
from collections import deque | |
class DES(object): | |
_initial_permutation = [ | |
58, 50, 42, 34, 26, 18, 10, 2, | |
60, 52, 44, 36, 28, 20, 12, 4, |
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
import json | |
from random import randint | |
class RSA(object): | |
def __init__(self): | |
self.p, self.q = self.gen_p_q() | |
self.N = self.p * self.q | |
self.phi = self.euler_function(self.p, self.q) |
OlderNewer