Skip to content

Instantly share code, notes, and snippets.

@bobvanderlinden
bobvanderlinden / sanitise_rubocop.sh
Created July 9, 2018 09:46
Fix Rubocop configuration by replacing the category of cops
#!/usr/bin/env bash
RUBOCOP_CONF="$1"
cat "$RUBOCOP_CONF" | \
sed -e 's|^DuplicatedGem|Bundler/DuplicatedGem|g' | \
sed -e 's|^InsecureProtocolSource|Bundler/InsecureProtocolSource|g' | \
sed -e 's|^OrderedGems|Bundler/OrderedGems|g' | \
sed -e 's|^DuplicatedAssignment|Gemspec/DuplicatedAssignment|g' | \
sed -e 's|^OrderedDependencies|Gemspec/OrderedDependencies|g' | \
sed -e 's|^RequiredRubyVersion|Gemspec/RequiredRubyVersion|g' | \
@JoshCheek
JoshCheek / api_only_rails_example.rb
Last active July 17, 2024 08:23
How to configure API only Rails (esp how to deal with param parsing).
# I submitted a bug report https://github.com/rails/rails/issues/34244
# b/c Rails was not honouring my `rescue_from` block which was causing my API to
# be inconsistent. I was told this is expected behaviour. I think it's probably
# fine for an HTML app where you control the form inputs. But for an API app,
# the API is public facing and very important, so Rails shouldn't have its own
# special errors that bypass my app's configuration and make my API inconsistent.
#
# Decided it shouldn't be too difficult to handle this myself. So, here is my
# solution. It contains most of the important lessons I've learned about how to
# get a Rails API app setup. It removes Rails' params parsing and adds its own.
@nginx-gists
nginx-gists / Dockerfile
Last active May 2, 2025 14:42
Dockerfiles for NGINX Plus R32 (Debian bookworm -12- and Alpine Linux 3.20), from Deploying NGINX and NGINX Plus on Docker (https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-docker)
ARG RELEASE=bookworm
FROM debian:${RELEASE}-slim
LABEL maintainer="NGINX Docker Maintainers <[email protected]>"
# Define NGINX versions for NGINX Plus and NGINX Plus modules
# Uncomment this block and the versioned nginxPackages block in the main RUN
# instruction to install a specific release
# ARG RELEASE
# ENV NGINX_VERSION=32
@OZZlE
OZZlE / mysql-faster-imports.sh
Last active October 16, 2024 02:27
Linux Bash Script to toggle faster mysql db imports
#!/usr/bin/env bash
# USAGE: mysqlOptimizeForImports <- before importing
# mysqlDefaultSettings <- to go back to normal
# Based on https://dba.stackexchange.com/questions/83125/mysql-any-way-to-import-a-huge-32-gb-sql-dump-faster/83385#83385
mysqlStateFile="$HOME/mysql.optimized.for.exports"
mysqlConfigLocation="/etc/mysql/my.cnf" # <-- change to the correct for your system, should be for global mysql settings
@dteoh
dteoh / mysql2-gem-install.md
Created November 22, 2019 01:18
Installing mysql2 gem

Installing mysql2 gem

This is always an annoying process, especially when you are setting up a new computer. I assume you are using macOS + homebrew. I also assume that you want to run an older version of MySQL (although the instructions should be adaptable).

Installing MySQL

$ brew install [email protected] # change the version if needed
@wellington1993
wellington1993 / BrowserGlue.jsm
Created February 15, 2020 00:14
view-source:resource:///modules/BrowserGlue.jsm
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["BrowserGlue", "ContentPermissionPrompt"];
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
@blanklin030
blanklin030 / zsh_install.sh
Created April 17, 2020 07:08
zsh_install
#!/bin/sh
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# or wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#
# As an alternative, you can first download the install script and run it afterwards:
# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
# sh install.sh
@thuan1412
thuan1412 / ffmpeg_mkv_mp4_conversion.md
Created April 17, 2020 07:34 — forked from jamesmacwhite/ffmpeg_mkv_mp4_conversion.md
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

# Search filename in stash
function gitsearch()
{
searchCrit='stash\|'$1
git stash list | while IFS=: read STASH ETC; do echo "$STASH: $ETC"; git diff --stat $STASH~..$STASH --; done | grep -e $searchCrit
}
alias githunt=gitsearch
@jdecode
jdecode / youtube-thumbnail-url-from-video-id.md
Last active July 18, 2020 05:29
youtube-thumbnail-url-from-video-id

Stackoverflow answer link - https://stackoverflow.com/a/2068371/867451

Copied the content for quick reference


Each YouTube video has four generated images. They are predictably formatted as follows:

https://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg

https://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg