Skip to content

Instantly share code, notes, and snippets.

View amalantony's full-sized avatar

Amal Antony amalantony

View GitHub Profile
@ljahier
ljahier / app.js
Last active November 5, 2022 01:18
Move all photos from google takeout into one directory.
const { mkdir, readdir, rename, stat } = require('fs/promises');
async function main() {
try {
await mkdir('./photos')
console.debug('Photo directory successfully created');
} catch (err) {
console.debug('Photo directory already exist');
}
@akovantsev
akovantsev / cursive-shadow-cljs-repl-setup.md
Last active April 8, 2025 22:35
Setting up shadow-cljs cljs REPL in Cursive
@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 $$
@NigelEarle
NigelEarle / Knex-Migrations-Seeding.md
Last active February 17, 2025 18:17
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

@ibraheem4
ibraheem4 / postgres-brew.md
Last active April 19, 2025 14:27 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@markerikson
markerikson / redux-timer-middleware.js
Last active January 5, 2021 17:37
Sample Redux timer middleware
function timerMiddleware({dispatch, getState}) {
const timers = {};
return next => action => {
if(action.type == "START_TIMER") {
const {action, timerName, timerInterval} = action.payload;
clearInterval(timers[timerName]);
function solution(N) {
return parseInt(N, 10).
toString(2).
replace(/^0+|0+$/g, '').
split('1').
reduce(function (a, b) {
return a.length > b.length ? a : b;
}).length
}
@mariotacke
mariotacke / README.md
Last active July 5, 2021 07:44
Gulp replace to invalidate cache

Gulp replace to invalidate cache

This demo replaces the string @@VERSION with the current unix timestamp when building with gulp. @@VERSION is a query parameter to bundle.js. To avoid caching bundle.js, we add the timestamp to it during each build.

Usage

npm install
npm run build
@Shashwat986
Shashwat986 / .vimrc
Created September 9, 2015 14:04
My vimrc
syntax on
set number
set ruler
set backspace=indent,eol,start
" Makes vim use the clipboard directly for yank, etc.
set clipboard=unnamed
" Tabs and Indentation