Skip to content

Instantly share code, notes, and snippets.

def greeting
puts 'hello, world!'
end
@yevgenko
yevgenko / big_money_spec.rb
Last active April 3, 2018 16:34
Forcing monetization to produce money in specific currency only
require 'money'
class BigMoney
class << self
attr_accessor :current_currency
def force_currency(currency_code)
self.current_currency = Money::Currency.new(currency_code)
yield
self.current_currency = nil
require 'active_record'
require 'database_cleaner'
require 'yaml'
connection_info = YAML.load(ERB.new(File.read("config/database.yml")).result)["test"]
ActiveRecord::Base.establish_connection(connection_info)
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
##
# Converts MTS files into m4v in a bulk
# with avconvert tool
#
# Usage:
# create directories ./in and ./out
# put files into in directory
# run the command:
# python bulk_convert.py
##
@yevgenko
yevgenko / animal_service_client_spec.rb
Created March 2, 2017 22:33
Example of using pact with webmock, i.e. to proxy connection via Rack application to mock service without changing base_url in client library
require 'httparty'
require_relative 'pact_helper'
require 'webmock/rspec'
require 'byebug'
require 'rack/proxy'
WebMock.disable_net_connect!(allow_localhost: true)
class Alligator
attr_reader :name
@yevgenko
yevgenko / useful_pandas_snippets.py
Created January 30, 2017 02:46 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@yevgenko
yevgenko / list_view_spec.js.coffee
Created January 26, 2016 00:10
Sample Spec for the View class of marionette module
describe 'ProductsApp.List', ->
List = App.module "ProductsApp.List"
describe 'Products', ->
productsView = new List.Products
collection: new Backbone.Collection []
describe 'click .publish_selected', ->
it 'triggers publish:selected:clicked event', ->
expect(true).toBeTruthy()
@yevgenko
yevgenko / template_renderer.rb
Created January 19, 2016 20:05
Sample class shows one way to wrap Liquid library
class TemplateRenderer
attr_reader :parsed_template
def initialize(template)
@parsed_template = template.respond_to?(:parase) ? template : _parse_template(template)
end
def render(params)
_render_template params
end
http://phpconfigure.com/
See before:
compile.mysql5.6.12.txt & compile.apache2.4.4.txt
Compile php 5.3.25
sudo mkdir /usr/local/php
sudo mkdir /usr/local/php/php_5.3.25
<header>
<script type="text/html" id="options-template">
<% for (i = 0; i < items.length; i++) { %>
<option value="<%= items[i].id %>"><%= items[i].value %></option>
<% } %>
</script>
</header>