Skip to content

Instantly share code, notes, and snippets.

Maxime Lapointe MaxLap

Block or report user

Report or block MaxLap

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 short_source_rabin_karp.cr
require "benchmark"
require "colorize"
require "http"
require "spec/dsl"
class String
private PRIME_RK = 2097169u32
def index_old(search : String, offset = 0)
offset += size if offset < 0
@MaxLap
MaxLap / rubocop.rb
Last active Nov 7, 2019 — forked from skanev/rubocop.rb
A Rubocop wrapper that checks only added/modified code
View rubocop.rb
#!/usr/bin/env ruby
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
#
# Here are some options you can pass in addition to the ones in rubocop:
#
@MaxLap
MaxLap / haml_helper.rb
Last active Dec 25, 2015
Helper to allow passing locales to :coffeescript filters and javascript filters if you wrap your javascript in (function() { ... without having to use interpolation, saving you against slow rendering on Windows servers.
View haml_helper.rb
module HamlHelper
def coffee_with_locals locals={}, &block
# This helper will set locals as values inside of the :coffeescript filter that follows.
# Doing this instead of using regular interpolation allows haml to keep a compiled version of the CoffeeScript
# instead of having to compile on every render after the interpolation is applied. On Linux, the impact is
# negligible because V8 is fast, but Windows environments don't have this chance and page rendering can be slowed
# heavily from having to compile CoffeeScript.
block_content = capture_haml do
You can’t perform that action at this time.