Skip to content

Instantly share code, notes, and snippets.

View michelson's full-sized avatar
🏠
Working from home

Miguel Michelson Martinez michelson

🏠
Working from home
View GitHub Profile
@pinksynth
pinksynth / get_file_type.ex
Last active April 28, 2022 03:19
Get missing file type from magic numbers in Elixir
defmodule Mix.Tasks.GetFileType do
use Mix.Task
def run([filename]) do
File.read!(filename)
|> check_magic_bytes()
|> IO.puts()
end
# Here's some basic file signatures, but you can easily add others as needed.
@jwietelmann
jwietelmann / build_mac_plugin_installer.sh
Last active August 23, 2020 14:23
Build and notarize an installer for multiple DAW plugin formats
#!/bin/bash -e
# REQUIREMENTS
# * jq - Used to extract values from notary service JSON responses
# * curl - Used to query notary service
signing_identity="Developer ID Installer: Your Name (ID)"
username="[email protected]"
password="@keychain:where-you-stored-your-app-specific-password"
output_dir=~/your_output_directory
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@dhh
dhh / tracker_blocking.rb
Last active June 30, 2024 14:35
Current list of spy pixels named'n'shamed in HEY, as of April 23, 2020
module Entry::TrackerBlocking
extend ActiveSupport::Concern
included do
has_many :blocked_trackers
end
email_service_blockers = {
"ActiveCampaign" => /lt\.php(.*)?l\=open/,
"AWeber" => "openrate.aweber.com",
@mattantonelli
mattantonelli / rails_snowflake_odbc_adapter.rb
Last active October 1, 2024 16:39
Snowflake in Ruby on Rails with the odbc_adapter gem
# Place in config/initializers
require 'active_record/connection_adapters/odbc_adapter'
require 'odbc_adapter/adapters/postgresql_odbc_adapter'
# Patch the Postgres adapter to remove the unsupported RETURNING clause from inserts
class ODBCAdapter::Adapters::PostgreSQLODBCAdapter
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
super
end
@joshnuss
joshnuss / active_record.ex
Last active January 18, 2022 07:26
ActiveRecord pattern with Ecto
defmodule ActiveRecord do
@doc false
defmacro __using__(_opts) do
quote do
use Ecto.Schema
import Ecto.{ Changeset, Query }
import ActiveRecord
Module.register_attribute(__MODULE__, :validations, accumulate: true, persist: true)
@baptx
baptx / instagram-api_send_message.js
Last active April 7, 2025 03:50
Instagram API: send direct messages from a web browser
/*
Instagram API: send direct messages from a web browser
Since April 2020, Instagram has a web version to send and read direct messages so my Instagram scripts are not longer needed and I would not recommend using them unless you really need it, to avoid being banned
(never happened to me with Instagram but WhatsApp is owned by Facebook also and they did it to users registering from an unofficial app like yowsup: https://github.com/tgalal/yowsup/commit/88b8ad9581fa22dac330ee3a05fec4e485dfa634#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5)
For browser setup, see script instagram-api_direct_messages_backup.js
Instagram web version sessionid cookie does not allow sending messages so we need to log in manually
Signature should match signed_body data (using HMAC-SHA256 with private key) but wrong signature or key may work also.
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active March 28, 2025 07:52
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
defmodule MyApp.Repo.Migrations.AddUuidOssp do
use Ecto.Migration
def up do
execute("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\" WITH SCHEMA public;")
end
def down do
execute("DROP EXTENSION \"uuid-ossp\";")
end
@thewheat
thewheat / Intercom Encrypted Mode.md
Last active March 21, 2021 19:05
Sample code to enable Intercom Encrypted Mode