Skip to content

Instantly share code, notes, and snippets.

View leoromanovsky's full-sized avatar

Leo Romanovsky leoromanovsky

View GitHub Profile
@leoromanovsky
leoromanovsky / 00_README.md
Created November 11, 2021 08:28 — forked from LeZuse/00_README.md
Install node on Apple Silicon M1 both ARM and x86 (Rosetta)

Node.js on Apple Silicon

Node Version Manager (https://github.com/nvm-sh/nvm) works perfectly across native node installations as well as emulated Rosetta installations. The trick I am using here is to install one LTS version of node under Rosetta and another stable version as native binary.

TODO

  • find a way how to run the same node version on both platforms
@leoromanovsky
leoromanovsky / extract_sql.pl
Created March 11, 2012 06:59
Extract SQL tables from database dump
#!/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:
##
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 February 19, 2018 21:44
Compute max population given a list of people's birth and death year
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 December 28, 2015 02:09
How I manage complex single page dynamic web apps.
#content
= spinner_tag()
:javascript
jQuery.ready(function() {
var pageView = new PageView();
pageView.render()
});
@leoromanovsky
leoromanovsky / deploy.rake
Created October 4, 2011 17:28 — forked from njvitto/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#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 September 6, 2011 06:53 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer