Skip to content

Instantly share code, notes, and snippets.

View alovak's full-sized avatar
🚀
Creating

Pavel Gabriel alovak

🚀
Creating
View GitHub Profile
@alovak
alovak / ar_validation.rb
Created June 25, 2012 10:15
active record two stage validation
module CertoPay
module ActiveRecord
extend ActiveSupport::Concern
module ClassMethods
def validate_further(*args, &block)
options = args.extract_options!
options = options.dup
options[:if] = Array.wrap(options[:if])
@alovak
alovak / tagit.js
Last active December 18, 2015 22:59
App.directive('tagIt', function ($timeout) {
return {
template: "<ul class='tagit'></ul>",
replace: true,
scope: {
tags: "=",
},
link: function(scope, element) {
$(element).tagit({
afterTagAdded: function(event, ui) {
@alovak
alovak / shit.coffee
Created July 31, 2013 10:30
CoffeeScript
class KoModel
indexed_error_for: (property_name, index, nested_property = null) =>
ko.computed(=>
if @errors() && @errors()[property_name]
error = jQuery.grep @errors()[property_name], (item) -> item.index == index
return '' unless error && error.length
if nested_property
@join_errors error[0].errors[nested_property]
else
@join_errors error[0].errors)
include_recipe "apt"
apt_repository 'precise-multiverse' do
uri 'http://us.archive.ubuntu.com/ubuntu'
distribution "precise"
components ['multiverse']
deb_src true
notifies :run, "execute[apt-get update]", :immediately
end
@alovak
alovak / specs.rb
Last active August 29, 2015 14:15
White specs
describe 'examples' do
describe 'POST /customers/:customer_id/cards' do
context 'when with card' do
it 'adds card to customer' do
post "/customers/#{customer[:id]}/cards", <<-JSON, headers
{
"card": {
"number": "4242424242424242",
"exp_year": 2020,
"exp_month": 11,
white.createToken({
number: $('.card-number').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val(),
cvc: $('.card-cvc').val()
}, whiteResponseHandler);
@alovak
alovak / ex.cs
Created November 25, 2015 08:01
var gateway = new StripeGateway("test_sec_k_4c3323cae84d75924f366");
charge = gateway.CreateChargeObject()
{
Amount = 100,
Currency = "USD",
Description = "Test Charge",
Card = "tok_4c3323cae84d75924f366s289943", // or CustomerId = "cus_xxxxx"
Capture = true
};
@alovak
alovak / gist:440d08fb35736634592c
Created March 6, 2016 13:35
plans-btfl-js.php
##################################
config.php
<?php
$plans = array(
'basic' => array('cents' => 1000, 'price' => '10.00'),
'pro' => array('cents' => 2000, 'price' => '20.00'),
);
// Install library before:
// > npm install node-rest-client
//
// More information about rest client: https://www.npmjs.com/package/node-rest-client
var Client = require('node-rest-client').Client;
var client = new Client({ user: "YOUR SECRET API KEY GOES HERE" });
var args = {
a = (1..100).to_a.rotate 7
x = 2
steps = 0
n = 0
l = 0
r = a.length
while true do
steps+=1