Skip to content

Instantly share code, notes, and snippets.

View atomkirk's full-sized avatar

Adam Kirk atomkirk

View GitHub Profile
@atomkirk
atomkirk / gcloud-function-printenv.sh
Created April 28, 2018 13:06
printenv of google cloud function
X_GOOGLE_FUNCTION_TIMEOUT_SEC=540
X_GOOGLE_FUNCTION_MEMORY_MB=2048
FUNCTION_TIMEOUT_SEC=540
SHLVL=1
FUNCTION_MEMORY_MB=2048
X_GOOGLE_FUNCTION_TRIGGER_TYPE=CLOUD_STORAGE_TRIGGER
PORT=8080
ENTRY_POINT=**********
OLDPWD=/var/tmp/worker/
HOME=/tmp
@atomkirk
atomkirk / endpoint.ex
Created February 23, 2018 16:50
raw body plug parser
plug Plug.Parsers,
parsers: [ZB.Parsers.RAWBODY, :urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison
@atomkirk
atomkirk / spectre.md
Last active June 3, 2020 23:10
Spectre

Here's my explanation of the Spectre vulnerability

Let's say you create an array numbers in javascript with length 4 and [1, 2, 3, 4] in it.

And lets say it ends up next to a sensative password, in memory belonging to your password manager app.

-----------------------------------------------
1 | 2 | 3 | 4 | p | a | $ | $ | w | o | r | d |
-----------------------------------------------
@atomkirk
atomkirk / ecto-url-validation.md
Last active August 4, 2024 03:51
validate url in elixir

Here's an ecto changeset validation for urls:

  @doc """
  validates field is a valid url

  ## Examples
    iex> Ecto.Changeset.cast(%ZB.Account{}, %{"website" => "https://www.zipbooks.com"}, [:website])
    ...> |> Utils.Changeset.validate_url(:website)
    ...> |> Map.get(:valid?)
@atomkirk
atomkirk / gist:539d902316727bde9a3f3021a7ac33e6
Created November 18, 2017 19:50
Custom default event duration on Fantastical

Custom default event duration on Fantastical 2

Run this in Terminal.app

defaults write com.flexibits.fantastical2.mac DefaultEventDuration 1200

1200 = 20 minutes * 60 seconds

PS

@atomkirk
atomkirk / analyze_compile.ex
Created November 5, 2017 00:27
a mix task to help figure out why elixir is recompiling every file
defmodule Mix.Tasks.AnalyzeCompile do
use Mix.Task
@shortdoc "Looks for problems in compile graph"
@moduledoc """
This is where we would put any long form documentation or doctests.
"""
def run(_args) do
@atomkirk
atomkirk / gist:18566d13eb3dbb395b7c1ec9f1f8ffae
Last active February 14, 2018 19:10
Install old version using Homebrew
  1. brew info [formula name] and look for From: to get url of current formula
$ brew info heroku                                                                                                                                                                                                 
heroku: stable 6.15.24 (bottled), HEAD
Command-line client for the cloud PaaS
https://cli.heroku.com
/usr/local/Cellar/heroku/3.42.10 (985 files, 6.2MB)
  Built from source on 2015-10-07 at 17:33:25
/usr/local/Cellar/heroku/3.42.20 (985 files, 6.2MB)
  Built from source on 2015-11-24 at 11:11:11
@atomkirk
atomkirk / customize-touch-bar.md
Created June 16, 2017 01:48
Customize the touch bar for apps with no support for touch bar
  1. In System Preferences > Keyboard > Shortcuts, Add the app to "Function Keys". This will make the function keys appear whenever you're using that app.

  1. Add short cut to "App Shortcuts"

@atomkirk
atomkirk / js-osa-mac-automation.md
Created May 14, 2017 01:54
Use javascript for Mac Automation

Repl

osascript -il JavaScript

Script

#!/usr/bin/env osascript -l JavaScript