Skip to content

Instantly share code, notes, and snippets.

View dpaluy's full-sized avatar

David Paluy dpaluy

  • Majestic Labs
  • Austin, TX
  • X @dpaluy
View GitHub Profile
@dpaluy
dpaluy / free_geo_ip.rb
Created December 13, 2019 21:24
Free IP Geolocation API
# read more: https://freegeoip.app/
require 'uri'
require 'net/http'
require 'openssl'
# https://freegeoip.app/{format}/{IP_or_hostname}
url = URI("https://freegeoip.app/json/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
@dpaluy
dpaluy / binary_hash.rb
Created December 25, 2019 08:32
store large JSON in PostgreSQL with Rails Attributes API
# app/types/binary_hash.rb
class BinaryHash < ActiveRecord::Type::Binary
def serialize(value)
super value_to_binary(value.to_json)
end
def deserialize(value)
super case value
when NilClass
@dpaluy
dpaluy / README.md
Last active November 9, 2025 21:05
Download view only protected PDF from Google Drive

Step by step guide to downloading protected PDF from Google Drive

  1. Open the document in Google Docs
  2. Scroll to the bottom of the document, so all the pages are present
  3. Open Developer Tools on separate window and choose the Console tab
  4. Paste the code
  5. Have fun!
@dpaluy
dpaluy / large-commit.sh
Created September 11, 2020 19:00
Find largest objects in your repo
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field separator to line break, so that we can iterate easily over the verify-pack output
@dpaluy
dpaluy / Yahoo_Finance_Graph.py
Created November 25, 2020 04:19
Get Live Market Data from Yahoo Finance
# Raw Package
import numpy as np
import pandas as pd
#Data Source
import yfinance as yf
#Data viz
import plotly.graph_objs as go
@dpaluy
dpaluy / user_maielr.rb
Created December 2, 2020 07:48
Send confirmation token with Welcome email
class UserMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
default template_path: 'users/mailer' # to make sure that your mailer uses the devise views
def welcome_reset_password_instructions(user)
create_reset_password_token(user)
mail(to: user.email, subject: 'Welcome to the New Site')
end
@dpaluy
dpaluy / trix_shrine.md
Last active July 20, 2023 01:25
Trix and Shrine for WYSIWYG

How to use Trix and Shrine for WYSIWYG Editing with Drag-and-Drop Image Uploading

Building It

Install and Configure Shrine and Trix Dependencies

  1. Setup Shrine:

First, add the Shrine gem to your application's Gemfile:

@dpaluy
dpaluy / money_report.rb
Created January 11, 2021 16:46
Baremetrics alternative using Ruby
# retrieve subscription data
########################
Stripe.api_key = ENV.fetch('STRIPE_SECRET_KEY')
subscriptions =
Stripe::Subscription.list(status: 'all', limit: 100, expand: ['data.customer'])
# Retrieve all subscriptions, following pagination until complete.
.auto_paging_each
.to_a
@dpaluy
dpaluy / conic.css.html
Last active March 8, 2021 15:24
conic.css in Tailwind
<div class="bg-gray-600 p-20 h-screen">
<div class="grid grid-cols-2 gap-12 place-items-center">
<div class="rounded-lg border-8 border-white h-48 w-48 shadow-lg">
<div class="h-full w-full bg-gradient-conic-tr from-green-200 via-blue-100 to-green-600"></div>
</div>
<div class="rounded-lg border-8 border-white h-48 w-48 shadow-lg">
<div class="h-full w-full bg-gradient-conic-tl from-pink-500 via-purple-500 to-blue-500"></div>
</div>
<div class="rounded-lg border-8 border-white h-48 w-48 shadow-lg">
<div class="h-full w-full bg-gradient-conic-br from-orange-200 via-yellow-500 to-red-500"></div>
@dpaluy
dpaluy / _breadcrumb.html.erb
Created March 18, 2021 21:43
Breadcrumbs in Rails
<head>
<title>
<%= breadcrumbs.map(&:name).reverse.append("My App").join(" | ") %>
</title>
</head>
<nav>
<ol class="breadcrumbs">
<% breadcrumbs.each do |crumb| %>
<li>