Skip to content

Instantly share code, notes, and snippets.

@ryancdavison
ryancdavison / iPad-Pro-Magic-Keyboard-Portrait-Mode-DIY-Smart-Connector-Cable.md
Last active May 14, 2024 23:46
iPad Pro 12.9 (2020) Magic Keyboard Portrait Mode DIY Smart Connector Cable

iPad Pro 12.9" (2020) Magic Keyboard Portrait Mode DIY Smart Connector Cable

I wanted my iPad Pro to be able to use the Magic Keyboard in portrait mode, but the current Smart Connector configuration does not allow this. With too much time on my hands, I made a short jumper cable using a section of USB cable, 5-pin POGO connectors (the 5-pin works using pins 1, 3, and 5, and removing pins 2 and 4), a small electrical project box, 3mm N52 magnets, and some epoxy and Sugru to pack everything into place. My cable and connections orientation had more to do with the boxes I found to encase the connector (with holes on the small end) than anything else. Obviously, there will be many ways to do this.

WARNING: Getting any of these steps wrong will probably ruin your iPad.

Note: These measurements are for the 12.9" (2020) model. The magnets did not line up and the polarity was different for my wife's iPad Pro 11" (2021).

![iPad-Pro-MmagicKeyboard-Jumper-Cable-min](https://user-images.githubusercontent.c

@LockedJCE
LockedJCE / regex-email-matching.md
Last active May 14, 2024 23:45
This is a tutorial on how regex works to validate an email.

Regex-Tutorial

Welcome to this comprehensive guide on understanding how regular expressions (regex) can be utilized for email matching. Regular expressions are powerful tools for pattern matching in strings, and when it comes to validating email addresses, they offer a flexible and efficient solution. In this gist, we will delve into the intricacies of crafting regex patterns specifically tailored for matching email addresses, covering the nuances of email syntax and common pitfalls to avoid. Whether you're a beginner seeking to grasp the basics or an experienced developer looking to refine your regex skills, this guide aims to provide clarity and practical insights into the world of email validation with regular expressions.

Summary

Regex Pattern for Email Address Validation

I'll describe a regex pattern used for validating email addresses. The pattern ensures that the email address has a valid structure, including a local part, an "@" symbol, and a domain with a valid top-level domain (TLD). I'

@fractaledmind
fractaledmind / application_controller.rb
Created May 14, 2024 15:37
Example of minimal authentication requirements for Rails app
ass ApplicationController < ActionController::Base
before_action :authenticate!
helper_method :current_user
helper_method :user_signed_in?
private
def authenticate
@current_user = nil
@drewolbrich
drewolbrich / CoordinateSpaceAxesEntity.swift
Last active May 14, 2024 23:42
A RelaityKit entity that draws coordinate space axes
//
// CoordinateSpaceAxesEntity.swift
//
// Created by Drew Olbrich on 7/8/23.
// Copyright © 2023 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@juanbrujo
juanbrujo / PlayStationBIOSFilesNAEUJP.md
Last active May 14, 2024 23:41
Files for PlayStation BIOS Files NA-EU-JP

Disable:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Enable:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

@hoangsonww
hoangsonww / Blockchain.py
Created April 8, 2024 04:05
A basic blockchain structure in Python with proof-of-work consensus, transaction handling, and wallet functionalities.
import hashlib
import json
from time import time
import binascii
from collections import OrderedDict
from uuid import uuid4
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
from cryptography.exceptions import InvalidSignature
@Klerith
Klerith / README.md
Last active May 14, 2024 23:39
Deprecated Method - Decorador

@Deprecated - Method Decorator

En la definición del método, se puede marcar como obsoleto (deprecated) con la justificación. Esto ayudará a que otros developers sepán que deben de utilizar ya la alternativa.

@Deprecated('Most use speak2 method instead')
 speak() {
      console.log(`${ this.name }, ${ this.name }!`)
 }
@OrionReed
OrionReed / dom3d.js
Last active May 14, 2024 23:37
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except: