Skip to content

Instantly share code, notes, and snippets.

@Shpigford
Shpigford / permissions.sql
Created September 8, 2024 18:06
Digital Ocean Postgres Permissions
REVOKE ALL ON DATABASE demo_database FROM demo_user;
GRANT CONNECT ON DATABASE demo_database TO demo_user;
GRANT USAGE, CREATE ON SCHEMA public TO demo_user;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO demo_user;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO demo_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO demo_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE ON SEQUENCES TO demo_user;
@Shpigford
Shpigford / .cursorrules
Last active September 17, 2024 20:38
Cursor Rules
# Original instructions: https://forum.cursor.com/t/share-your-rules-for-ai/2377/3
# Original original instructions: https://x.com/NickADobos/status/1814596357879177592
You are an expert AI programming assistant that primarily focuses on producing clear, readable SwiftUI code.
You always use the latest version of SwiftUI and Swift, and you are familiar with the latest features and best practices.
You carefully provide accurate, factual, thoughtful answers, and excel at reasoning.
- Follow the user’s requirements carefully & to the letter.
@Shpigford
Shpigford / content.js
Created August 25, 2022 00:18
Arc Boost for blocking distracting sites
const domains = ['cnn.com'];
const content = 'Nope!';
if (domains.includes(window.location.hostname.replace('www.',''))) {
document.body.style.backgroundColor = 'red';
document.body.style.color = 'white';
document.body.style.textAlign = 'center';
document.body.style.fontWeight = 'bold';
document.body.style.fontFamily = 'sans-serif';
document.body.style.textTransform = 'uppercase';
def filtered_tracks(current_user)
tracks = current_user.tracks.limit(500)
rules = filters['rules']
if rules.find {|h| h['id'] == 'track_name'}.present?
track_name = rules.find {|h| h['id'] == 'track_name'}['value']
tracks = tracks.where('tracks.name ILIKE ?', '%' + track_name + '%')
end
class BuildAlbumSpotifyJob
include Sidekiq::Worker
sidekiq_options :queue => :default
def perform(artist_id)
artist = Artist.find artist_id
albums = RSpotify::Artist.find(artist.spotify_id).albums(limit:50, album_type: 'album,single')
albums.each do |album|
@Shpigford
Shpigford / gist:7a1d48013d2dad64873c
Created September 8, 2014 11:21
Slack Sidebar Theme
// Paste in to Preferences > Sidebar Theme
#256BAD,#256BAD,#242E35,#FFFFFF,#242E35,#FFFFFF,#6DA94A,#DECC30
class LiveController < ApplicationController
include ActionController::Live
def stream
# Set the response header to keep client open
response.headers['Content-Type'] = 'text/event-stream'
begin
100.times {
response.stream.write("The temperature is #{ 100*rand} degrees\n")
def animals
sheep.each do |horse|
# get 'em
end
cows.each do |cow|
# then get these
end
pigs.each do |pig|
# Example to initialize gridster and handle resizing
# Module grid settings
WIDGET_BASE_DIMENSIONS_X = WIDGET_DESKTOP_X = 140
WIDGET_BASE_DIMENSIONS_Y = 20
WIDGET_CONTAINER_SELECTOR = '.widget-view'
WIDGET_MOBILE_CUTOFF_WIDTH = 768
NUM_WIDGETS = 15
$ ->
@Shpigford
Shpigford / Failed Bank Import email.
Last active December 24, 2015 12:29 — forked from lessallan/Failed Bank Import email.
Not really any shorter, but definitely less dry and more human.
Subject: Action Needed: Can't import your finacial data!
Hey <first name or friend>!
We're having trouble importing your financial bits in to LessAccounting.
Seems your login details are outdated for <insert bank name>.
So, to keep your financial details spot on, we need to make sure that data gets imported.