Skip to content

Instantly share code, notes, and snippets.

View anaibol's full-sized avatar

Anibal anaibol

View GitHub Profile
@anaibol
anaibol / asd.sql
Created October 26, 2023 18:29
Get products per keyword count
SELECT k.name AS keyword, COUNT(kp."B") AS count
FROM "Keyword" k
LEFT JOIN (
SELECT DISTINCT "A" AS keywordId, "B"
FROM "_KeywordToProduct" -- Replace with the actual name of your intermediary table
) AS kp ON k.id = kp.keywordId
GROUP BY k.name
ORDER BY count DESC;
@anaibol
anaibol / createVercelApiAdapter.ts
Created December 7, 2022 00:13
Vercel adapter for tRPC
import { AnyRouter, TRPCError } from "@trpc/server";
import {
NodeHTTPCreateContextFnOptions,
NodeHTTPHandlerOptions,
nodeHTTPRequestHandler,
} from "@trpc/server/dist/adapters/node-http";
import { VercelApiHandler, VercelRequest, VercelResponse } from "@vercel/node";
import Cors from "cors";
const cors = Cors();
@anaibol
anaibol / array-find.js
Created August 20, 2017 11:37
Minimal Array.find polyfill
if (!Array.prototype.find) {
Array.prototype.find = function (predicate) {
return this.filter(predicate)[0]
}
}
@anaibol
anaibol / ImageTools.js
Last active November 8, 2016 10:31 — forked from dcollien/ImageTools.es6
Resize Images in the Browser, returns a Promise
let hasBlobConstructor = typeof(Blob) !== 'undefined' && (function () {
try {
return Boolean(new Blob());
} catch (e) {
return false
}
}())
let hasArrayBufferViewSupport = hasBlobConstructor && typeof(Uint8Array) !== 'undefined' && (function () {
try {
@anaibol
anaibol / debounce.js
Created October 20, 2016 20:27
ES6 debounce
export default function debounce(func, wait, immediate) {
let timeout
return function(...args) {
clearTimeout(timeout)
timeout = setTimeout(() => {
timeout = null
if (!immediate) func.apply(this, args)
}, wait)
if (immediate && !timeout) func.apply(this, [...args])
}
node:
image: "mhart/alpine-node:5.9.1"
redis:
image: "redis:3.0.7-alpine"
app:
build: app
api:
build: api
Atom sync settings
@anaibol
anaibol / gist:69e178356975fb1bb0d2
Created August 27, 2015 19:54
Target blank React link
<a href={data.link} target="_blank" className="image">
<span className="tag">ZG Instagram</span>
<img className="image" src={data.images.standard_resolution.url} width="100%" height="100%" />
</a>
<a href={data.link} target="_blank" className="image">
<span className="tag">ZG Instagram</span>
<img className="image" src={data.images.standard_resolution.url} width="100%" height="100%" />
</a>
@anaibol
anaibol / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console