Skip to content

Instantly share code, notes, and snippets.

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

Scott Lewis iconifyit

🏠
Working from home
View GitHub Profile
@iconifyit
iconifyit / get-set-as-json-object.sql
Last active February 24, 2024 22:08
(FUNC) Gets set data as single JSON object.
DROP FUNCTION IF EXISTS get_set_data;
CREATE OR REPLACE FUNCTION get_set_data(setId integer)
RETURNS jsonb AS $$
-- ---------------------------------------------
-- Selects set as JSON
-- ---------------------------------------------
select jsonb_build_object(
'set_id', s.id,
'set_name', s.name,
@iconifyit
iconifyit / build-family-json-object.sql
Last active February 19, 2024 20:18
Get Family Data (function)
DROP FUNCTION IF EXISTS get_family_data;
CREATE OR REPLACE FUNCTION get_family_data(familyId integer)
RETURNS jsonb AS $$
WITH counts AS (
SELECT
f.id AS family_id,
COUNT(DISTINCT i.id) AS icons_count,
COUNT(DISTINCT il.id) AS illustrations_count,
COUNT(DISTINCT s.id) AS sets_count
@iconifyit
iconifyit / gray-jsdoc-comments.jsonc
Created September 29, 2023 22:19
Gray out VS Code JSdoc
/* add this in your settings.json (command + shit +p > Preferences : Open User Settings (JSON) */
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "storage.type.class.jsdoc",
"scope": "storage.type.class.jsdoc,entity.name.type.instance.jsdoc,variable.other.jsdoc",
"settings": {
"foreground": "#7f848eff"
}
@iconifyit
iconifyit / accounting.sql
Created September 3, 2023 20:49 — forked from 001101/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@iconifyit
iconifyit / product-repository.tsx
Created December 21, 2022 15:02
Medusa ProductRepository override
import { ProductRepository as MedusaProductRepository } from "@medusajs/medusa/dist/repositories/product";
import { Repository as MedusaRepository, Utils } from "medusa-extender";
import { EntityRepository, In } from "typeorm";
import { Product } from "./product.entity";
@MedusaRepository({ override: MedusaProductRepository })
@EntityRepository(Product)
export default class ProductRepository extends Utils.repositoryMixin<Product, MedusaProductRepository>(MedusaProductRepository) {
public async bulkAddToSet(
productIds: string[],
@iconifyit
iconifyit / git-tag-and-release.sh
Last active December 15, 2022 19:02
Interactive bash script to push a new tag and release version. Automatically increments major, minor, or patch version based on the latest tag (assumes you are using {major}.{minor}.{patch} format)
#!/usr/bin/env bash
############################################################
# Help #
############################################################
Help()
{
# Display Help
echo "Increment the latest tag and create a new tag & release."
echo
@iconifyit
iconifyit / two-variable-swap.js
Created December 5, 2022 20:31
Swap two variables set to integers without using a third variable
// Swap two variables, set to integers,
// without using a third variable.
// Any language you want, but no Assembly.
// Register swaps are cheating for
// this riddle.
let x = 3
let y = 5
console.log(x, y)
@iconifyit
iconifyit / resize-artboards-dropdown.js
Created November 28, 2022 20:27
Example Illustrator script to create a pop-up with dropdown list to change artboards to pre-selected sizes.
var docRef = app.activeDocument;
var dialog = new Window("dialog");
dialog.text = "Escolha Cilindro";
dialog.preferredSize.width = 400;
dialog.orientation = "column";
dialog.alignChildren = ["left", "top"];
dialog.spacing = 10;
dialog.margins = 16;
@iconifyit
iconifyit / fn-resize-artboards.js
Created November 28, 2022 19:24
Function that takes width and height as arguments and resizes all Artboards in an Illustrator document with those dimensions.
function doResizeArtboards(width, height) {
if (app.documents.length === 0) {
alert("There are no open documents.");
return;
}
var theDoc = app.activeDocument;
try {
for (i = 0; i < theDoc.artboards.length; i++) {
/**
@iconifyit
iconifyit / delete_all_imessage_conversations.applescript
Created November 3, 2022 20:40 — forked from lexrus/delete_all_imessage_conversations.applescript
Delete all iMessage conversations. Compatible with macOS Monterey. Please check Reduce motion before launch this apple script.
# System Preferences -> Accessibility -> Display -> Reduce motion
tell application "Messages" to activate
tell application "Messages"
set chatCount to (count of chats)
end tell
tell application "System Events"
tell process "Messages"