Skip to content

Instantly share code, notes, and snippets.

Leo Romanovsky leoromanovsky

Block or report user

Report or block leoromanovsky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View contribution.scala
persons.flatMap(p => Seq((p.birthYear, 1), (p.deathYear, -1)))
.sorted
.foldLeft((0,0,0)){case ((mxYear,mxPop,curPop), (thisYear,dif)) =>
if (curPop+dif > mxPop) (thisYear, curPop+dif, curPop+dif)
else (mxYear, mxPop, curPop+dif)
}._1 //res0: Int = 2000
@leoromanovsky
leoromanovsky / original.scala
Last active Feb 19, 2018
Compute max population given a list of people's birth and death year
View original.scala
val persons = Seq(
Person(2000, 2010),
Person(2000, 2005),
Person(1990, 2005)
)
// Create an array of population change.
val births = persons.groupBy(_.birthYear).mapValues(_.length)
val deaths = persons.groupBy(_.deathYear).mapValues(_.length)
val populationChanges = (births.keySet ++ deaths.keySet).map { year =>
@leoromanovsky
leoromanovsky / single-page-app.js.coffee
Last active Dec 28, 2015
How I manage complex single page dynamic web apps.
View single-page-app.js.coffee
#content
= spinner_tag()
:javascript
jQuery.ready(function() {
var pageView = new PageView();
pageView.render()
});
@leoromanovsky
leoromanovsky / extract_sql.pl
Created Mar 11, 2012
Extract SQL tables from database dump
View extract_sql.pl
#!/usr/bin/perl -w
##############################################################################
##
## Written by: Jared Cheney <jared.cheney@gmail.com>
##
## Original Template written by:
## Brandon Zehm <caspian@dotconf.net> and Jared Cheney <elph@leph.net>
##
## License:
##
@leoromanovsky
leoromanovsky / deploy.rake
Created Oct 4, 2011 — forked from njvitto/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
View deploy.rake
#Deploy and rollback on Heroku in staging and production
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
task :production_migrations => [:set_production_app, :push, :off, :migrate, :restart, :on, :tag]
@leoromanovsky
leoromanovsky / about.md
Created Sep 6, 2011 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
View about.md
You can’t perform that action at this time.