Skip to content

Instantly share code, notes, and snippets.

RED = True
BLACK = False
class Node:
def __init__(self, key, color=RED, left=None, right=None, parent=None):
self.key = key
self.color = color
self.left = left
self.right = right
self.parent = parent
@Rhernandez513
Rhernandez513 / quicksort.py
Created April 7, 2025 15:05
python quicksort
def qs(arr):
if not arr:
return []
len_arr = len(arr)
if len_arr <= 1:
return arr
xs = arr[0]
smaller = [x for x in arr[1:] if x <= xs]
larger = [x for x in arr[1:] if x > xs]
'https://www.howtogeek.com/660517/how-to-find-your-windows-10-product-key-using-the-command-prompt/
Set WshShell = CreateObject("WScript.Shell")
MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
{
// At time of writing, for use with Visual Studio Code Version 1.29.1 and above
//
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
<?php
try
{
$pdo = new PDO('mysql:host=localhost;dbname=company', 'cfn', 'naiman');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
$error = 'Unable to connect to the database server.';
@Rhernandez513
Rhernandez513 / sendEmail.sh
Last active August 12, 2023 19:31
Simple script to send emails with mailgun api
#!/bin/bash
# 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/.
set -o allexport
source .env
set +o allexport
/* 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/. */
#include "io.h"
#include <iostream>
// GET INPUTS from STDIN
std::vector<std::string> Get_STDIN_Strings(void) {
/* 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/. */
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
@Rhernandez513
Rhernandez513 / ctags-proj.sh
Last active November 1, 2017 20:10
Scripts in my \~/bin'
#!/bin/bash
# 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/.
#
# ctags-proj - A simple script to update ctags recursively up the directory structure
# using .gitignore as the "indicator" for where the project root is
#!/bin/bash
# update_repos - A simple script to update git repos within a directory
# Location where this script is stored in the filesystem
# STARTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# Location of the working directory of the calling shell
PARENTDIR=$PWD