Skip to content

Instantly share code, notes, and snippets.

View ain's full-sized avatar

Ain Tohvri ain

View GitHub Profile
@ain
ain / gdpr_countries.vcl
Created July 19, 2022 17:46
VCL dictionary for GDPR-regulated EU countries (ISO 3166-1 Alpha-2)
table gdpr_countries {
"AT": "Austria",
"BE": "Belgium",
"BG": "Bulgaria",
"HR": "Croatia",
"CY": "Republic of Cyprus",
"CZ": "Czech Republic",
"DK": "Denmark",
"EE": "Estonia",
"FI": "Finland",
@ain
ain / hotfix.sh
Created November 19, 2018 21:00
Check last commit message for [hotfix]
#/bin/bash
if [[ `git log -1 --pretty=%B` == *"[hotfix]"* ]]; then
echo "HOTFIX!"
else
echo "NOT HOTFIX!"
fi
@ain
ain / wp-importer.rb
Created July 17, 2016 22:44
Wordpress data Import script for Jekyll 3
require "jekyll-import"
JekyllImport::Importers::WordpressDotCom.run({
"source" => "wp-export.xml"
})
@ain
ain / seed_migrate.patch.rake
Created November 10, 2014 17:20
Rake task to patch seed_migrate table reset failure on db:reset
# Call with rake app:db:reset
namespace :app do
namespace :db do
# Patches seed_migration issue #22
desc "Reset database incl. seeding migration"
task :reset => :environment do
puts "Resetting database..."
begin
@ain
ain / cssmin-font-family-regex.js
Created February 3, 2014 19:47
Regex for matching the font name within minified CSS class definition.
/(\}\.form-group>\.form-control\{)(.[^}]+)(?:font-family:([^,;}]+))/i
@ain
ain / Array.prototype.compare.js
Last active September 25, 2020 07:17
JavaScript compare() method for Array
Array.prototype.compare = function(array) {
if (!array) {
return false;
}
if (this.length !== array.length) {
return false;
}
for (var i = 0, l = this.length; i < l; i++) {
if (this[i] instanceof Array && array[i] instanceof Array) {
if (!this[i].compare(array[i])) {
@ain
ain / release-cleanup.sh
Created December 5, 2013 15:18
Release folder cleanup script for Capistrano-like folder structure
#!/bin/bash
KEPT_RELEASES=5
CWD=/Users/ain/temp
# Check for Bash config
# On FreeBSD/OS X GNU ls is required for -v option
if [ -f ~/.bashrc ]; then
shopt -s expand_aliases
source ~/.bashrc
@ain
ain / email-regex.js
Last active December 28, 2015 23:19
Email validation regex for emails likely to be used in Germany.
var emailRegex = /^([\wäöüÜÖÄß])+(([\.]{0,1}[\wäöüÜÖÄß])?)*(([\+]{0,1}[\wäöüÜÖÄß])?)*([\wäöüÜÖÄß-])*\@([\wäöüÜÖÄß-]+\.)+([\w]{2,})+$/;
@ain
ain / Keyboard-et.plist.part
Last active December 26, 2015 15:08
Mapping for PressAndHold.app for selecting special characters on press and hold Q key on Mac.
<key>Roman-Accent-Q</key>
<dict>
<key>Direction</key>
<string>right</string>
<key>Keycaps</key>
<string>` ^ ° • ★ “ ”</string>
<key>Strings</key>
<string>` ^ ° • ★ “ ”</string>
</dict>
@ain
ain / poster.php
Created August 23, 2013 15:34
PHP dummy parsing the REQUEST.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<pre><?php print_r($_REQUEST); ?></pre>
</body>
</html>