Skip to content

Instantly share code, notes, and snippets.

View simonoff's full-sized avatar
💭
KUBER!!!!

Oleksandr Simonov simonoff

💭
KUBER!!!!
View GitHub Profile
platforms/
plugins/
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]

Alexander Simonov

Contact details

Speaker bio

I'm software engeneer with more then 10 years experience. Last 7 years I'm using Ruby for my projects.

# Adapted from a C# example here:
# http://stackoverflow.com/questions/43224/how-do-i-calculate-a-trendline-for-a-graph
# And thanks to John Esser for helping figure out how to
# calculate the targets to stabilize a negative slope!
class LinearRegression
attr_accessor :slope, :intercept
# Pass in an array of values to get the regression on
# RSpec matcher to spec delegations.
# Forked from https://gist.github.com/ssimeonov/5942729 with fixes
# for arity + custom prefix.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:name).to(:author).with_prefix(:any) } # post.any_name
# it { should delegate(:month).to(:created_at) }
task :teamcity => ['teamcity:clean', 'teamcity:setup', 'barista:brew', 'fork:spec', 'teamcity:cucumber', 'jasmine:ci']
namespace :teamcity do
task :setup do
RAILS_ENV = 'test'
Rake::Task['db:drop'].invoke
Rake::Task['db:create'].invoke
Rake::Task['db:schema:load'].invoke
end
  • This creates a 560mb ramdisk. Adjust the size accordingly. I think the number at the end of the command is the number of disk blocks. They are 2kb in size for me.
  • Restarting postgres is not necessary; you can create the ramdisk and tablespace while postgres is running.
  • You will lose all data in the ramdisk tablespace when you shut your machine down

  $ diskutil erasevolume HFS+ "postgres_ramdisk" `hdiutil attach -nomount ram://1165430`
  Started erase on disk1
  Unmounting disk
  Erasing
 Initialized /dev/rdisk1 as a 569 MB HFS Plus volume
@simonoff
simonoff / gist:4564560
Last active December 11, 2015 07:09 — forked from xslim/hash.rb
class Hash
def select_and_sort_by(whitelist)
whitelist.inject({}) do |m,k|
k = k.to_sym
m[k] = self[k] if self.has_key?(k)
m
end
end
#!/usr/bin/env ruby
require 'net/smtp'
FILE = File.readlines("foo1")
class Email
def initialize
@smtp = Net::SMTP.new('127.0.0.1', 2025)
end
def post(from, to)
msgstr = <<EOF
From: <#{from}>
@simonoff
simonoff / calling-code-demo.html
Created December 7, 2012 16:15
Calling Code Plugin for jQuery
<div id="selection"><a href="#"><span class="icon 44"></span>United States<span class="code"> +1</span></a></div>
<label id="phoneNum">
Phone Number:
<input type="text" />
</label>
<div id="dropdown">
<div class="countryMenu">
<a href="#"><span class="icon 44"></span>United States<span class="code"> +1</span></a>
<a href="#"><span class="icon 2311"></span>Afghanistan<span class="code"> +93</span></a>
<a href="#"><span class="icon 1034"></span>Albania<span class="code"> +355</span></a>