Skip to content

Instantly share code, notes, and snippets.

@madkoding
madkoding / install-docker-deepin.sh
Last active May 9, 2024 17:08
Install Docker-CE script for Deepin Linux
#!/bin/bash
echo "Starting Docker installation on Deepin Linux..."
# Define a mapping from Deepin version to Debian version
map_deepin_to_debian() {
if [ "$1" -lt 20 ]; then
echo "stretch"
elif [ "$1" -ge 20 ]; then
echo "buster"

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

class Admins::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def google_oauth2
admin = Admin.from_google(from_google_params)
if admin.present?
sign_out_all_scopes
flash[:success] = t 'devise.omniauth_callbacks.success', kind: 'Google'
sign_in_and_redirect admin, event: :authentication
else
flash[:alert] = t 'devise.omniauth_callbacks.failure', kind: 'Google', reason: "#{auth.info.email} is not authorized."
@stephancasas
stephancasas / toggle-ventura-sidecar.jxa.js
Last active May 9, 2024 17:05
Toggle sidecar or screen mirroring from Control Center in macOS Ventura
#!/usr/bin/env osascript -l JavaScript
/**
* -----------------------------------------------------------------------------
* Activate Sidecar/Screen Mirroring from Control Center
* -----------------------------------------------------------------------------
*
* Created on February 17, 2023 by Stephan Casas
* Updated on May 18, 2023 by Stephan Casas
*
@shunia
shunia / Send_Key_To_Background_Application.swift
Created July 9, 2021 09:39
MacOS send keystroke to background application
import Foundation
import CoreFoundation
// all keycodes: https://gist.github.com/swillits/df648e87016772c7f7e5dbed2b345066
let KeyCode_R: UInt16 = 0x0F;
let KeyCode_N: UInt16 = 0x2D;
let src = CGEventSource(stateID: CGEventSourceStateID.hidSystemState)
let kspd = CGEvent(keyboardEventSource: src, virtualKey: KeyCode_R, keyDown: true) // space-down
let kspu = CGEvent(keyboardEventSource: src, virtualKey: KeyCode_R, keyDown: false) // space-up
@dhh
dhh / linux-setup.sh
Last active May 9, 2024 17:04
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev mupdf mupdf-tools \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
@meyer9
meyer9 / skeleton.py
Created July 6, 2014 17:43
PyGame Skeleton
import pygame
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640, 480))
running = 1
while running:
for event in pygame.event.get():
@achesco
achesco / generate-mongo-ssl.md
Last active May 9, 2024 16:59
Generate self-signed SSL certificates for MongoDb server and client

CNs are important!!! -days 3650

Make PEM containig a public key certificate and its associated private key

openssl req -newkey rsa:2048 -new -x509 -days 3650 -nodes -subj '/C=US/ST=Massachusetts/L=Bedford/O=Personal/OU=Personal/emailAddress=example@example.com/CN=localhost' -out mongodb-cert.crt -keyout mongodb-cert.key
cat mongodb-cert.key mongodb-cert.crt > mongodb.pem
@mtisz
mtisz / mixtral-8x22B.yaml
Created May 9, 2024 14:57
Axolotl Config for Mixtral-8x22B
base_model: mistral-community/Mixtral-8x22B-v0.1
model_type: MixtralForCausalLM
tokenizer_type: AutoTokenizer
is_mistral_derived_model: false
trust_remote_code: true
load_in_8bit: false
load_in_4bit: true
strict: false
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 9, 2024 16:55
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example