Skip to content

Instantly share code, notes, and snippets.

Avatar

Ain Tohvri ain

View GitHub Profile
@ain
ain / hotfix.sh
Created Nov 19, 2018
Check last commit message for [hotfix]
View hotfix.sh
#/bin/bash
if [[ `git log -1 --pretty=%B` == *"[hotfix]"* ]]; then
echo "HOTFIX!"
else
echo "NOT HOTFIX!"
fi
@ain
ain / wp-importer.rb
Created Jul 17, 2016
Wordpress data Import script for Jekyll 3
View wp-importer.rb
require "jekyll-import"
JekyllImport::Importers::WordpressDotCom.run({
"source" => "wp-export.xml"
})
@ain
ain / seed_migrate.patch.rake
Created Nov 10, 2014
Rake task to patch seed_migrate table reset failure on db:reset
View seed_migrate.patch.rake
# 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 Feb 3, 2014
Regex for matching the font name within minified CSS class definition.
View cssmin-font-family-regex.js
/(\}\.form-group>\.form-control\{)(.[^}]+)(?:font-family:([^,;}]+))/i
@ain
ain / Array.prototype.compare.js
Last active Sep 25, 2020
JavaScript compare() method for Array
View Array.prototype.compare.js
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 Dec 5, 2013
Release folder cleanup script for Capistrano-like folder structure
View release-cleanup.sh
#!/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 Dec 28, 2015
Email validation regex for emails likely to be used in Germany.
View email-regex.js
var emailRegex = /^([\wäöüÜÖÄß])+(([\.]{0,1}[\wäöüÜÖÄß])?)*(([\+]{0,1}[\wäöüÜÖÄß])?)*([\wäöüÜÖÄß-])*\@([\wäöüÜÖÄß-]+\.)+([\w]{2,})+$/;
@ain
ain / Keyboard-et.plist.part
Last active Dec 26, 2015
Mapping for PressAndHold.app for selecting special characters on press and hold Q key on Mac.
View Keyboard-et.plist.part
<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 Aug 23, 2013
PHP dummy parsing the REQUEST.
View poster.php
<!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>
@ain
ain / netbeans_ignore.regex
Last active Dec 18, 2015
Regex for Netbeans' Ignored Files Pattern to make Travis CI dotfile visible
View netbeans_ignore.regex
^(CVS|SCCS|vssver.?\.scc|#.*#|%.*%|_svn)$|~$|^\.(?!htaccess|jshintrc|DS_Store|gitattributes|gitignore$|.*\.yml$).*$
You can’t perform that action at this time.