Skip to content

Instantly share code, notes, and snippets.

View karlkaebnick's full-sized avatar

Karl Kaebnick karlkaebnick

View GitHub Profile
@karlkaebnick
karlkaebnick / cleanup_branches.sh.md
Created January 9, 2020 18:40
Shell script to delete old git branches
#!/usr/bin/env bash

# Run the following 2 lines by hand - edit each output file to make sure there is nothing you want to keep

# git branch --all --sort=committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' > branch_info.txt

# cat branch_info.txt | sed -e "s/^  origin\///" -e "s/ .*//" > delete_me.txt
@karlkaebnick
karlkaebnick / php_debugger_install_howto.md
Last active December 9, 2019 18:00
steps to install php debugger

Note: see https://xdebug.org/docs/install for installation notes

  • Update your system modules:
    sudo apt-get update; sudo apt-get dist-upgrade
  • Install pecl:
    sudo apt install php-pear
  • Install Xdebug:
    sudo pecl install xdebug
  • add
    zend_extension=/usr/lib/php/20180731/xdebug.so
@karlkaebnick
karlkaebnick / apple_app_analytics.md
Created August 29, 2019 21:34
apple app analytics
  • can be graphed over time or aggregated over a period of time:
    • number of installations
    • number of deletions
    • number of users who were active in last N days
    • sessions in last N days
    • number of crashes
    • number of 'impressions' (the # of times your app showed up in the app store)
  • other:
  • where did the installer come from? (e.g., app store search? web referrer? app referrer?
@karlkaebnick
karlkaebnick / how_to_machine_translate.md
Last active July 19, 2019 21:58
How to run the machine translation script
  • Install python 3.6 on an environment with a bash terminal (e.g., linux, macos, or windows with cygwin or git bash installed)
    • (python 3.5 or python 3.7 should be ok if that is what you have installed currently)
  • clone the repo 'website_scripts' - https://github.com/CityOfDetroit/website_scripts
  • set up your environment dependencies in website_scripts:
    • in bash, navigate to wherever you cloned website_scripts (e.g., /home/kaebnickk/sites/website_scripts/) and run the following:
    • create a virtualenv in website_scripts:
      python3 -m venv .
    • activate the virtualenv you just created:
      source bin/activate (or source scripts/activate if you are in windows)
    • now install your dependencies:
      pip install -r requirements.txt
  • create a file named google_translate_key.json in the root of the repo (get the data to put in this file from edgar or karl - it contains keys and credentials and stuff that cannot go in the repo)
  • put your english content to be translated into a text
@karlkaebnick
karlkaebnick / add_acquia_domain.md
Last active March 8, 2019 20:39
How to add a new domain pointing at an acquia instance
  • Have acquia add the new site to our cloudflare account
    • The new site should have a "partial" DNS configuration
    • Generally this involves adding a TXT record to our DNS account to prove that we "own" the domain.
      • Note: to check if the TXT record has been added:
        host -t TXT <domain>
  • Once the new cloudflare site is added, figure out the correct IP that the domain should be pointed at in order to direct traffic for this domain to cloudflare:
    • Flush your local DNS cache:
      ipconfig /FLUSHDNS
    • Find the correct ip to point the domain at:
      dig .cdn.cloudflare.net
@karlkaebnick
karlkaebnick / edit_automated_web_pages.md
Last active July 18, 2019 20:08
How to add, update or remove data from automated web pages
  1. If you have a report to add or replace, then let's take care of that first:
    • navigate to the web page where the report is supposed to be added or replaced (e.g., https://detroitmi.gov/departments/office-chief-financial-officer/financial-reports)
    • copy a link to an existing report to figure out where the new report or replacement report is supposed to go - e.g., if the link to a report that is already available on the page is https://detroitmi.gov/sites/detroitmi.localhost/files/migrated_docs/financial-reports/CityofDetroitOCFOMonthlyFinancialReportMay19FinalCC.pdf, then that indicates your new or replacement report should be uploaded to /var/www/html/detroitmi/docroot/sites/detroitmi.localhost/files/migrated_docs/financial-reports
    • sftp to the web server, e.g., sftp detroitmi.prod@web-35153.prod.hosting.acquia.com
    • navigate to the destination foldeer, e.g., cd /var/www/html/detroitmi/docroot/sites/detroitmi.localhost/files/migrated_docs/financial-reports
  • upload the file, e
@karlkaebnick
karlkaebnick / drupal_git_chores.md
Last active March 9, 2019 21:04
How to create a new master branch for a drupal instance
  • verify the new branch has been tested in stage
  • make a backup of current master branch:
    • production drupal instance should be pointing at existing master branch right now
    • create a backup of current master and point production drupal instance to it:
      • checkout the master branch:
        git checkout master
      • make sure you have latest changes for master branch:
        git pull
      • create a backup of the current master branch:
        git checkout -b master_backup_<yyymmdd>
      • push this backup branch to the remote repo:
        git push origin master_backup_<yyymmdd>
    • now switch production drupal instance to the backup master branch you just created
  • now create the new master branch:
@karlkaebnick
karlkaebnick / detroitmi_content_instructions.md
Last active February 12, 2018 17:50
How to add content to the drupal city of Detroit website
  1. Login to the site as an editor: http://detroitmi.theneighborhoods.org/user/login

  2. Navigate to the taxonomy you are going to add content to:

  • Click on Structure -> Taxonomy -> Departments (or "Government" or "Initiatives")
  • Check if the term already exists (If the terms are out of order you can click "Reset to alphabetical" at the bottom of the page to sort them alphabetically). If so, click on the term, and choose "edit". Otherwise, choose "Add Term".
  1. Add the following values:
  • Title
  • Abbreviation (if there is an abbreviation for the department that is typically used)
  • Description
  • in drupal, rich text editors (like the one we use for the description field) you can copy / paste content from other websites (e.g., from the DNN version of detroitmi.gov) or from documents like word, pdf, etc., which actually works pretty well
@karlkaebnick
karlkaebnick / drupal_acquia_task_list.md
Last active January 10, 2018 15:31
Drupal / Acquia Task List
  1. Find resolution to issue with acquia not allowing multiple active SSL certs in a single environment - See https://docs.acquia.com/articles/multiple-ssl-certificates-single-balancer - See the Acquia Tam ticket - 2 options: use a SAN cert or a wildcard cert: - SAN requires us to have at most 5 secure websites (which, if we have edge protect and all of our website are secure, meaning we max out at 5 production websites, period) ~~- wildcard cert requires all our production, secure websites to have the same domain name (which is problematic)~~~~
  2. Get rhythm theme working in drupal 8.4 - It currently only supports up to version 8.2 - see ticket
  3. Get varbase installed
@karlkaebnick
karlkaebnick / detroitmi.gov_drupal_architecture.md
Last active December 8, 2017 22:11
Architecture for city of Detroit's drupal website

Overview:

Our aim is to build a highly-structured database. Doing so will involve a lot more work initially (in comparison with a purely aesthetic redesign) but will make changing the website easier and more fool-proof. This is also in keeping with Drupal website best practices.

Taxonomies:

  • Departments
    • e.g., 'health', 'ddot', 'ocfo', 'dpw'
    • May not always technically be departments - e.g., they may be agencies or authorities.
    • Includes offices / agencies within departments (e.g., 'web team', 'iet', 'office of civil rights')
    • Departments and sub-departments need to be associated with certain pieces of information, e.g.:
  • department contacts