This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import RevenueCat | |
struct Constants { | |
static let apiKey = "<your_api_key>" // Will look like: appl_bunchofotherstuffhere | |
static let entitlementName = "<your_entitlement_name>" // I use something like "pro" | |
} | |
@main | |
struct ATinySampleApp: App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// frontend - react | |
import { useState } from "react"; | |
import Alert from "@reach/alert"; | |
export default function Contact() { | |
const [name, setName] = useState(""); | |
const [email, setEmail] = useState(""); | |
const [message, setMessage] = useState(""); | |
const [messageSent, setMessageSent] = useState(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If the user has been on the page for over 12 hours, the next link | |
// click will do a full page transition to get new code | |
import React from "react"; | |
import { BrowserRouter, useLocation } from "react-router-dom"; | |
let hour = 3600000; | |
export default function StaleAppRouter(props) { | |
let [isStale, setIsStale] = useState(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { IncomingMessage } from 'http' | |
import { | |
NextApiRequestCookies, | |
NextApiRequestQuery, | |
} from 'next/dist/next-server/server/api-utils' | |
import { Socket } from 'net' | |
import { ServerResponse } from 'http' | |
import { NextApiRequest, NextApiResponse } from 'next' | |
import { Env } from 'next/dist/lib/load-env-config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const groupBy = (data, keys) => { // `data` is an array of objects, `keys` is the array of keys (or property accessor) to group by | |
// reduce runs this anonymous function on each element of `data` (the `item` parameter, | |
// returning the `storage` parameter at the end | |
return data.reduce((storage, item) => { | |
// returns an object containing keys and values of each item | |
const groupValues = keys.reduce((values, key) => { | |
values[key] = item[key]; | |
return values; | |
}, {}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- addons.js | |
- config.js | |
- webpack.config.js |
In yesterday's post I said, in relation to "how does .present? work on ActiveRecord::Relation", I said that present?
performs an existence check SELECT 1 AS one FROM ... LIMIT 1
because it calls exists?
underneath. This is actually wrong - it load
s the relation.
Jonathan Mast corrected me on Twitter. It turns out, I should have paid closer attention! Here is the actual implementation of blank?
on ActiveRecord::Relation on Rails master:
# Returns true if relation is blank.
def blank?
records.blank?
end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Because we're using an ORM (Objection), it's a pain to add a tsvector when inserting, | |
// since tsvectors and FTS aren't supported by Objection. Instead, I've added a hook that | |
// fires on insert which auto-generates the tsvector field for each newly inserted entry. | |
// This is an example knex migration file for said behavior. | |
const addUserIndex = ` | |
ALTER TABLE public.user ADD "document" tsvector; | |
CREATE FUNCTION my_trigger_function() | |
RETURNS trigger AS $$ |
- Create a new database instance attached to current application
- Restore latest database backup on newly created database
- Get the connection url of this backup database. Use this URL in later sql queries.
- Connect to database where we have incorrect data
heroku pg:psql --app ck-api-prod
- On postgres prompt run following queries. This will create copy table from data in backup database.
NewerOlder