Skip to content

Instantly share code, notes, and snippets.

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

Oleksandr Simonov simonoff

💭
KUBER!!!!
View GitHub Profile

Grunt and Cordova 3

The advantages of using Grunt with Cordova:

  1. It simplifies working with the cordova cli.
  2. It provides a mechanism to copy platform customization to the platforms directory without having to commit the generated plugins and platforms directories to version control.
  3. It provides a way to watch resources and automatically run cordova commands.
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.

@simonoff
simonoff / gist:7792049
Last active December 30, 2015 06:49
in_groups_of faster then each_slice ?!!!
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]
n = 1000000
Benchmark.bm do |x|
x.report('in_groups_of') { n.times { a.in_groups_of(7, false).select{|x| x.size == 7} } }
x.report('each_slice') { n.times { a.each_slice(7).select{|x| x.size == 7} } }
x.report('each_slice with result') { n.times { res = []; a.each_slice(7) {|x| res << x if x.size == 7 }; } }
end
# user system total real
#in_groups_of 4.690000 0.010000 4.700000 ( 4.745116)
# 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