Skip to content

Instantly share code, notes, and snippets.

View mzagaja's full-sized avatar

Matthew Zagaja mzagaja

View GitHub Profile

The other day we had an issue with scope when migrating from the Ruby 2 to Ruby 3 syntax for hash arguments. Previously we had something like:

def foo(**kwargs)
  kwargs[:value] += 1
end

In Ruby 2 you can then do:

rvm default
test -e {$HOME}/.iterm2_shell_integration.fish ; and source {$HOME}/.iterm2_shell_integration.fish
source {$HOME}/.config/fish/functions/nvm_auto_switch.fish
source {$HOME}/.config/fish/functions/rvm_auto_switch.fish
@mzagaja
mzagaja / Brewfile
Last active June 24, 2022 04:26 — forked from jhirbour/Brewfile
# specify a directory to install
cask_args appdir: '/Applications'
brew 'openssh'
# unix things
brew 'readline'
brew 'tmux'
# services
brew 'mysql'

Vector Tiles in Mapbox GL

Adding ESRI Vector Tiles to Mapbox GL JS by Jonah Adkins

Here we can see that adding an Esri vector tile service is a bit different from adding Mapbox tiles. For the Esri tiles, we’re referencing the pbf with the appropriate tiling scheme (z/x/y) using the tiles property instead of url property. To pull in each road type from Esri, I downloaded the style json and looked for references to road layers.

Appending resources/styles/root.json?f=pjson to the end of the service URL gives you the full style with layer names and such

https://tiles.arcgis.com/tiles/41TSzUbTxELRIXMD/arcgis/rest/services/2cool2school/VectorTileServer/tile/{z}/{y}/{x}.pbf

Import House Districts

ogr2ogr -f 'PostgreSQL' PG:"dbname=ctnj-vote_development user=mzagaja" housect_37800_0000_2010_s100_census_1_shp_wgs84.shp -nlt MULTIPOLYGON -nln ct_house_districts
system({dbname: Rails.configuration.database_configuration[Rails.env]['database']}, "ruby", "-e p ENV['rubyguides']")

Connecting to Google Analytics API - A Journey

There is a Google Ruby client for doing this. They also have documentation.

  1. Follow the instructions for creating a service account.
  2. Add the service account to your Google Analytics account user list.
  3. Create a Project for your new API project if you wish. I usually do and name it something related to the project.
  4. Create a service account.
  5. Enable the Google Analytics Reporting API
  6. In GSuite Domain Security Settings go to API Controls and check "Trust internal, domain-owned apps."

Latitude and Longitude

Well Known Text

POINT(X Y), X is latitude and Y is longitude

For ESRI Lat = Y Long = X

GDAL X= longtiude Y = latitude

# Matt Zagaja Rails Template
gem_group :development, :test do
gem 'dotenv-rails'
gem 'factory_bot_rails'
gem 'pry-byebug'
gem 'rspec-rails'
end
gem_group :development do
gem 'capistrano', '~> 3.10', require: false
@mzagaja
mzagaja / install-version-managers.sh
Last active January 29, 2020 21:16
Fish Shell Install Version Managers
#! /usr/bin/fish
curl -sSL https://get.rvm.io | bash -s stable
curl -L --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish
echo "rvm default" >> ~/.config/fish/config.fish
# brew install python@2 python
pip install virtualfish
'eval (python -m virtualfish)' >> ~/.config/fish/config.fish