Skip to content

Instantly share code, notes, and snippets.

public class EmailToCaseParser {
public static String parseEmails(String emailHeaders) {
Pattern p = Pattern.compile('Reply-To: \\s*([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})');
Matcher pm = p.matcher(emailHeaders);
string res = '';
if (pm.find()) {
res = pm.group(0).replaceAll('Reply-To: ','');
}
return res;
}
@jeanbaptistebeck
jeanbaptistebeck / tacos-comparison.md
Last active July 25, 2022 08:31 — forked from Piotr1215/tacos-comparison.md
Below table provides a high level overview of various IaC capabilities and their support by a given provider.
Capability/Tool terraform Cloud terraform Enterprise Scalr Env0 Spacelift
Compliance ISO 27001, SOC 2 ISO 27001, SOC 2 SOC 2 SOC 2 ISO 27001, SOC 2
GitLab Integration
Hosting SaaS SaaS, On-Prem SaaS, On-Prem SaaS SaaS
Policy as Code Sentinel
@jeanbaptistebeck
jeanbaptistebeck / list_git_repos.md
Created October 31, 2018 09:59
Lsi all git repositories on a machine
find / -name ".git"
@jeanbaptistebeck
jeanbaptistebeck / mount_hdd.md
Created October 31, 2018 09:57
Access hard drive from Ubuntu USB
cd /
cd mnt
mkdir hdd
sudo fdisk -l

Find the missing letter

def find_missing_letter(arr)
  arr.each_cons(2) do |letter, next_letter| 
    return letter.next if letter.next != next_letter
  end
end

def find_missing_letter(arr)
def duplicate_count(text)
('a'..'z').count { |c| text.downcase.count(c) > 1 }
end
def play_pass(str, n)
str
.downcase
.tr('a-z', ('a'..'z').to_a.rotate(n).join)
.tr('0-9', '9876543210')
.gsub(/(..|.$)/, &:capitalize)
.reverse
end
@jeanbaptistebeck
jeanbaptistebeck / import_heroku_db.md
Last active March 11, 2016 18:34
Import Heroku Postgres database into local database

Import Heroku Postgres database into local database

heroku pg:backups capture
curl -o latest.dump `heroku pg:backups public-url`

If you didn't create a role for your local database, then do :

createuser -s -r <role_name>
@jeanbaptistebeck
jeanbaptistebeck / update_columns.rb
Created February 27, 2016 09:26
Active Record Update Columns
TargetUserStat.all.update_all(gender: nil, age: nil, pcs: nil, city_size: nil, salary: nil, segment_association: nil)
@jeanbaptistebeck
jeanbaptistebeck / observers.md
Last active February 16, 2016 18:03
Active Record Observer

Observers in Rails

gem 'rails-observers'

Life without observers

class Application < ActiveRecord::Base