Skip to content

Instantly share code, notes, and snippets.

View vishvish's full-sized avatar
😷
coding

Vish vishvish

😷
coding
View GitHub Profile
@vishvish
vishvish / model.rb
Created April 18, 2023 14:46 — forked from cblunt/model.rb
A tiny concern for generating a UUID for a model. Code heavily based off Rails' `has_secure_token` method
class Model < ActiveRecord::Base
include UuidConcern
# uuid attribute is `:uuid` by default. Optionally pass in attribute name, e.g `has_uuid :unique_token`
has_uuid
end
@vishvish
vishvish / .Dockerfile
Created May 18, 2022 12:20 — forked from kinoute/.Dockerfile
Example of Ruby on Rails 6 Multi-stage builds with Docker. Development/production environments share the same Dockerfile.
FROM ruby:2.7.1-slim AS base
LABEL maintainer="Yann Defretin <yann@defret.in"
# Common dependencies
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq \
--no-install-recommends \
build-essential=12.6 \
gnupg2=2.2.12-1+deb10u1 \
@vishvish
vishvish / touchid_sudo.sh
Last active December 15, 2022 22:43 — forked from RichardBronosky/touchid_sudo.sh
Use TouchID for sudo on modern MacBook Pro machines
#!/bin/bash
# curl -sL https://gist.githubusercontent.com/vishvish/70d12682c29927dabbeb48fa7b3defca/raw/touchid_sudo.sh | bash
# This script is ready to copy-paste in whole, or just the line above (without the leading #)
# Use TouchID for sudo on modern MacBook Pro machines
# This script adds a single line to the top of the PAM configuration for sudo
# See: https://apple.stackexchange.com/q/259093/41827 for more info.
touchid_sudo(){
BEGIN MESSAGE.
QToRZq5xNPOCbk6 76O8qSUhSYoOZPt pRDgCS1h8NU2P3D 1Co8n1HbCR9DaXN
R6laWuVeSH1w3Vq PxTUldi9XPOTCKq 6Xr2MZHgg6nttCc rkJHQIBswLfnyXA
KOBk0FAAOQedKrM oZODVGsRgnkjidY ub6e1ssXVw7VIAn vOw3VUgN2szOPtw
zgTftFxn0qdavlP 4vGjwEmzu8H3Nen 2mCY90Qz5Z.
END MESSAGE.
@vishvish
vishvish / recovery.sh
Created July 21, 2019 19:02 — forked from jonathantneal/recovery.sh
Create or update macOS Mojave Recovery Partition Without Reinstalling
#!/bin/sh
# Set the macOS installer path as a variable
MACOS_INSTALLER="/Applications/$(ls /Applications | grep "Install macOS")"
MOUNT_POINT="$MACOS_INSTALLER/Contents/SharedSupport"
echo "macOS installer is \"$MACOS_INSTALLER\""
# Set the target disk as a variable
TARGET=$(diskutil info "$(bless --info --getBoot)" | awk -F':' '/Volume Name/ { print $2 }' | sed -e 's/^[[:space:]]*//')
echo "Target disk is \"$TARGET\""
{"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36","environment":{"networkUserAgent":"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36(KHTML, like Gecko) Chrome/71.0.3559.0 Mobile Safari/537.36","hostUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36","benchmarkIndex":654},"lighthouseVersion":"3.2.0","fetchTime":"2019-05-17T07:46:53.844Z","requestedUrl":"https://tom-bradford.com/","finalUrl":"https://tom-bradford.com/","runWarnings":[],"runtimeError":{"code":"NO_ERROR","message":""},"audits":{"is-on-https":{"id":"is-on-https","title":"Uses HTTPS","description":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and your users, and is a prerequisite for HTTP/2 and many new we
@vishvish
vishvish / golang-scheduling.md
Created May 16, 2019 11:57
Go lang scheduling stuff

After coming unstuck with Golang code that worked differently between an IDE and a terminal, then fixing it with some sleep, I decided to look into how the scheduling works.

I found some very useful stuff.

Part 1, 2 and 3 are excellent: https://www.ardanlabs.com/blog/2018/08/scheduling-in-go-part1.html

I read in Part two these words:

"The Go scheduler is part of the Go runtime, and the Go runtime is built into your application. This means the Go scheduler runs in user space, above the kernel. The current implementation of the Go scheduler is not a preemptive scheduler but a cooperating scheduler. Being a cooperating scheduler means the scheduler needs well-defined user space events that happen at safe points in the code to make scheduling decisions."

@vishvish
vishvish / hosts
Created December 17, 2017 22:39 — forked from consti/hosts
/etc/hosts to block shock sites etc.
# This hosts file is brought to you by Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file for non-commercial uses,
# as long the original URL and attribution is included.
#<localhost>
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
255.255.255.255 broadcasthost
::1 localhost
# change default command binding
unbind C-b
set -g prefix C-a
set-option -ga terminal-overrides ",xterm-256color:Tc"
#set -g default-terminal "screen-256color"
# but send it through if pressed twice (i.e. using screen in an ssh session)
#bind C-a send-prefix
@vishvish
vishvish / docker_command
Created July 6, 2016 01:28 — forked from likwid/docker_command
Postgres with ssl in docker
#This isn't very secure, but its for demo purposes
docker run --name postgres -e POSTGRES_PASSWORD=password -d -p 54320:5432 \
-v $(pwd)/postgresql.conf:/srv/postgresql.conf \
-v $(pwd)/server.crt:/srv/server.crt \
-v $(pwd)/server.key:/srv/server.key \
-v $(pwd)/reconfigure_postgres.sh:/docker-entrypoint-initdb.d/reconfigure_postgres.sh \
postgres:9.5