Skip to content

Instantly share code, notes, and snippets.

Avatar

criess

View GitHub Profile
View add_user_from_email.rb
require 'csv'
require 'net/http'
require 'optparse'
require 'securerandom'
##
# example csv:
# ```
# email;gender;lastname;firstname;role
# you@andme.com;other;Some;Name;admin
View clear_active_buyer_events_redirected_analytics.rb
force_delete = ARGV.find { |x| x == '--force-delete' }
from_date = Date.new(2021,4,1)
filter_item_type = 'BuyingProfile'
def lookup_lli(event)
LongListItem.find(event.context_id)
end
AnalyticsEvent.where(context_scope: :LongListItem)
@criess
criess / rails_rubocop_include_analyzer.rb
Created May 5, 2021
analyzes includes between two folders on a rails application
View rails_rubocop_include_analyzer.rb
#!/usr/bin/env ruby
#
# script can be run from rails runner like so:
# rails r this_file.rb -- <including_directory_path> <included_directory_path>
#
# for example on a rails concerns setup: rails r thisfile.rb -- app/models app/models/concerns
#
# rubocop is required to parse the code
#
@criess
criess / update_bubble_via_curl.rb
Created Apr 29, 2021
migration script for IN-1246
View update_bubble_via_curl.rb
require 'csv'
require 'active_support'
require 'active_support/core_ext'
def command(json, id)
"curl -v -s -X PATCH " \
"-H 'Authorization: Bearer #{ENV['BUBBLE_API_KEY']}' " \
"-H 'Content-Type: application/json' " \
"-d '#{json}' " \
"'https://#{ENV['BUBBLE_API_HOST']}/api/1.1/obj/project/#{id}'"
View connect_bq_and_pipedrive_on_csv.rb
#!/usr/bin/env ruby
# a dump of the funnel_exec table from big query is needed in line-separated-json format
# also we need a csv file with information about lead creation, email and pipedrive ids
#
# three positional parameters must be passed:
# * input json path
# * input csv path
View messages_to_user_interest.rb
#!/usr/bin/env ruby
PROJECT_ID_KEY = 'respectiveproject_custom_project'.freeze
USER_ID_KEY = 'sender_user'.freeze
MESSAGETYPE_MATCHER = lambda { |k, entry| entry['messagetype_text'] == 'RequestProjectData' }
# message downloader extending from
module Imports
module BubbleApi
class Message < Record
View bubble_migrate_investors.rb
#
# steps to migrate investors to user accounts:
#
# 1. generate users in correct state (can be declined if only declined profiles exist)
# 2. re-synchronize with bubble if necessary
# 3. send emails for password reset
#
# User generation
View csv_to_policy.rb
#!/usr/bin/env ruby
require 'csv'
require 'yaml'
require 'active_support/core_ext/string'
PUBLIC_ROLE = 'Public'
ROLES = ['Admin', 'Carl Employee', 'Investor', 'Advisor'].freeze
View kodi_player_open.sh
#!/bin/bash
# parse options
# a => Auth string formatted <user>:<pass>
# f => file location (hyperlink etc…)
# t => kodi/xbmc target in <ip>:<port>
while getopts 'a:f:t:' OPT; do
case $OPT in
a) AUTH=$OPTARG;;
f) URL=$OPTARG;;
View de_federal_states.yml
---
- de: Baden-Württemberg
en: Baden-Württemberg
- de: Bayern
en: Bayern
- de: Berlin
en: Berlin
- de: Brandenburg
en: Brandenburg
- de: Bremen