Skip to content

Instantly share code, notes, and snippets.

with import <nixpkgs> {
overlays = [
(self: super: rec {
beam = super.beam // { defaultVersion = "erlangR25"; };
elixir = super.elixir_1_14;
elixir_ls = super.elixir_ls.override { elixir = elixir; };
})
];
};
<?php
/**
* Напишите функцию intervals так, чтобы все тесты выполнились
* и в конце на экран было выведено 'OK'
*
* Функция принимает на вход отсортированный массив чисел,
* на выходе — массив интервалов, где интервал это массив из двух
* элементов, начало и конец интервала.
*/
@chooh
chooh / $README.md
Last active October 20, 2020 09:56
GitLab: How to build a docker image and run tests or generate documentation using the image

How to build a docker image and run tests or generate documentation using the image with GitLab

Let's say you have a ruby project. You write tests using rspec and you write documentation inside the code. And you are using awesome GitLab to host your git repo, run CI pipelines and store your docker images in registry.

Build an image.

First we need to build an image. But we want to leverage docker layer caching, because libraries (rubygems) doesn't update very often. That's why we do docker pull first, and docker build --cache-from after.

If you make a feature branch and update some libraries, you can't use layer with libraries form the master branch. That's why we try to docker pull for feature branch first, and docker pull for master branch after.

@chooh
chooh / dos2unix.md
Last active October 7, 2020 09:22
Dos 2 Unix

Convert CRLF to LF

for file in **/*.brs
do
  vi +':w ++ff=unix' +':q' "$file"
done

Remove BOM

FROM php:7.0-apache
RUN apt-get update && apt-get install -y \
git-core \
ssh-client \
unzip \
--no-install-recommends && rm -r /var/lib/apt/lists/*
# Install composer bin to /usr/local/bin
RUN curl -sS https://getcomposer.org/installer | \
function A(x) { this.x = x; };
function B(x,y) { A.call(this, x); this.y = y; };
B.prototype = new A();
B.prototype.what = function(){ return "hello"; };
var d = new B(5, 10);
A.prototype.say = function(){return "say " + this.what();};
B.prototype.say = function(){return ">> : " + A.prototype.say.call(this);};
@chooh
chooh / rdiscount.rb
Created December 29, 2011 14:36
Markdown handler with erb support
# put me in config/initializers/rdiscount.rb
class ActionView::Template
class RDiscountHandler < Handler
def self.erb_handler
@@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
end
def self.call(template)
compiled_source = erb_handler.call(template)
"::RDiscount.new(begin;#{compiled_source};end).to_html"
@chooh
chooh / config.ru
Created December 28, 2010 15:48
Simple Rack web server for static files with index.html
# This is the root of our app
@root = File.expand_path(File.join(File.dirname(__FILE__), "www"))
run Proc.new { |env|
# Extract the requested path from the request
req = Rack::Request.new(env)
index_file = File.join(@root, req.path_info, "index.html")
if File.exists?(index_file)
# Rewrite to index
@chooh
chooh / gist:219151
Created October 27, 2009 00:06 — forked from tomlea/gist:207938
require "net/http"
# Example Usage:
#
# use Rack::Proxy do |req|
# if req.path =~ %r{^/remote/service.php$}
# URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}")
# end
# end
#