Skip to content

Instantly share code, notes, and snippets.

View Angelmmiguel's full-sized avatar

Ángel M Angelmmiguel

View GitHub Profile
@cameronblandford
cameronblandford / knexPostgresFullTextSearch.js
Last active November 8, 2023 07:35
Implement full text search using Knex + Objection
// 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 $$

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
@ghosh
ghosh / micromodal.css
Last active March 21, 2024 16:12
Demo modal styles for micromodal.js and corresponding expected html. If using this, set the `awaitCloseAnimation` in config to true
/**************************\
Basic Modal Styles
\**************************/
.modal {
font-family: -apple-system,BlinkMacSystemFont,avenir next,avenir,helvetica neue,helvetica,ubuntu,roboto,noto,segoe ui,arial,sans-serif;
}
.modal__overlay {
position: fixed;
@gauravtiwari
gauravtiwari / window-auth-popup.es6.js
Last active April 12, 2024 00:56
Promise based popup window for server oAuth
/* global window */
const popup = (url) => {
const windowArea = {
width: Math.floor(window.outerWidth * 0.8),
height: Math.floor(window.outerHeight * 0.5),
};
if (windowArea.width < 1000) { windowArea.width = 1000; }
if (windowArea.height < 630) { windowArea.height = 630; }
@danieleggert
danieleggert / GPG and git on macOS.md
Last active April 22, 2024 07:46
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@sparkprime
sparkprime / main.jsonnet
Last active March 15, 2021 06:43
Example of string templating within Jsonnet
{
template: (importstr "template.yaml") % {
name: "rabbitmq",
image: "whatever",
cookie: "XXXX",
data_volume: std.toString({ name: "thing", foo: [1, 2, 3] }),
nodes: std.toString(['rabbit@rabbitmq-%s' % shard_name for shard_name in [1, 2, 3]]),
},
}
@Remiii
Remiii / README.md
Last active March 6, 2024 19:52
How to delete Vault (AWS Glacier) 🗻

How to delete Vault (AWS Glacier)

This Gist give some tips in order to remove AWS Glacier Vault with AWS CLI (ie. https://aws.amazon.com/en/cli/).

Step 1 / Retrive inventory

$ aws glacier initiate-job --job-parameters '{"Type": "inventory-retrieval"}' --vault-name YOUR_VAULT_NAME --account-id YOUR_ACCOUNT_ID --region YOUR_REGION
@bomberstudios
bomberstudios / svgo-sketch.sh
Created April 16, 2015 14:07
SVGo options to clean up Sketch's SVG files without destroying them
svgo --pretty --enable=removeTitle --enable=removeDesc --enable=removeDoctype --enable=removeEmptyAttrs --enable=removeUnknownsAndDefaults --enable=removeUnusedNS --enable=removeEditorsNSData -f folder_with_svg_files
@branneman
branneman / better-nodejs-require-paths.md
Last active April 8, 2024 00:22
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

# sets the proxy cache path location, max size 2g
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:100m inactive=24h max_size=2g;
# transfers the `Host` header to the backend
proxy_set_header Host $host;
# uses the defined STATIC cache zone
proxy_cache STATIC;
# cache 200 10 minutes, 404 1 minute, others status codes not cached