Skip to content

Instantly share code, notes, and snippets.

@wickedshimmy
wickedshimmy / Levenshtein.cs
Created June 23, 2010 07:05
Damerau-Levenshtein algorithm in C#.
// Copyright (c) 2010, 2012 Matt Enright
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
@dhlavaty
dhlavaty / AbsoluteUrl.cs
Last active August 30, 2021 07:46
How to get an Absolute URLs in ASP.NET MVC without HttpContext and/or UrlHelper
public static class AbsoluteUrl
{
private static bool initializedAlready = false;
private static Object initlock = new Object();
// AbsoluteUrl without parameters
public static string MVC_Home_Index;
public static string MVC_MyArea_Settings_Index;
// AbsoluteUrl with parameters
@sskylar
sskylar / minify-liquid.html
Last active January 8, 2021 19:00
Simple HTML minify with Liquid/Siteleaf. Strips all line breaks, tabs, and extra spaces.
{% capture html %}
<html>
...
</html>
{% endcapture %}{{ html | strip_newlines | replace:' ','' | replace:' ','' | replace:' ',' ' }}
@rsutphin
rsutphin / tag_and_push_tag.cap
Last active April 18, 2018 13:08
A capistrano 3 task to tag the repo after every deploy
# Requires Capistrano 3.2 or later
namespace :deploy do
after :finishing, :tag_and_push_tag do
on roles(:app) do
within release_path do
set(:current_revision, capture(:cat, 'REVISION'))
# release path may be resolved already or not
resolved_release_path = capture(:pwd, "-P")
@jeffrafter
jeffrafter / rate_limits.rb
Created May 28, 2015 21:16
Handle Shopify API rate limits
# https://docs.shopify.com/api/introduction/api-call-limit
module ActiveResource
# 429 Client Error
class RateLimitExceededError < ClientError # :nodoc:
end
class Connection
RATE_LIMIT_SLEEP_SECONDS = 20 # number of seconds to sleep (by sleeping 20 you reset the clock to get 40 fresh burst calls with the default 2 calls/sec)