Skip to content

Instantly share code, notes, and snippets.

View derekantrican's full-sized avatar

Derek Antrican derekantrican

View GitHub Profile
@derekantrican
derekantrican / Raspberry pi logo multicolor.gcode
Created October 28, 2023 17:56
Gcode for printing a raspberry pi logo on a BambLab P1P in 3 colors
; HEADER_BLOCK_START
; BambuStudio 01.07.04.52
; model printing time: 7m 41s; total estimated time: 13m 28s
; total layer number: 10
; model label id: 775
; HEADER_BLOCK_END
; CONFIG_BLOCK_START
; accel_to_decel_enable = 0
; accel_to_decel_factor = 50%
@derekantrican
derekantrican / encryptDecrypt.py
Created November 15, 2022 23:51
Encrypt or Decrypt a file using a password in python
from cryptography.fernet import Fernet
import base64, hashlib
def gen_fernet_key(passcode) -> bytes: # Modified from https://stackoverflow.com/a/72758959/2246411
hlib = hashlib.md5()
hlib.update(bytes(passcode, 'utf-8'))
return base64.urlsafe_b64encode(hlib.hexdigest().encode('latin-1'))
def encrypt_file(target_file, fernet): # https://www.geeksforgeeks.org/encrypt-and-decrypt-files-using-python/
with open(target_file, 'rb') as file:
@derekantrican
derekantrican / NamecheapAPI.ps1
Created October 17, 2022 20:47
An example to call the NameCheap API via powershell (and parse the result)
# This is just an example for the Get Hosts endpoint
# docs: https://www.namecheap.com/support/api/methods/domains-dns/get-hosts/
function GetNamecheapTarget
{
param
(
[string]$username,
[string]$apiKey,
[string]$domain,
@derekantrican
derekantrican / OCR.cs
Created May 23, 2022 18:42
.NET 6 & minimal code to perform OCR on a image using ocr.space
using Newtonsoft.Json;
//Add your filepath & ocr.space key below
string ocr = await DoOCR("screenshot.jpg", "OCR.SPACE API KEY");
Console.WriteLine(ocr);
static async Task<string> DoOCR(string fileName, string apikey)
{
string resp = null;
try
@derekantrican
derekantrican / VSToLine.cs
Last active May 13, 2022 22:57
Code to open Visual Studio to a specific line in a file
using System;
using System.Runtime.InteropServices;
//Usage: VSToLine.exe [full path to file] [line number] (eg VSToLine.exe fullPathToFile.cs 10)
//Original source: https://newbedev.com/open-a-file-in-visual-studio-at-a-specific-line-number
//Needed references:
// https://www.nuget.org/packages/envdte/17.2.32505.113
// https://www.nuget.org/packages/envdte80/17.2.32505.113
// https://www.nuget.org/packages/stdole/17.2.32505.113
@derekantrican
derekantrican / SpreadExample.cs
Last active May 12, 2022 21:21
An example of using a extension method to achieve a similar functionality to the ES6 spread operator (...)
using System.Collections.Generic;
namespace SpreadExample
{
public class SpreadExample
{
//Normally, this would take more lines, like:
/*
public List<string> InsertList(List<string> secondList)
{
@derekantrican
derekantrican / index.html
Last active May 10, 2021 23:45 — forked from RubaXa/index.html
String#includes vs. String#indexOf vs. RegExp (https://jsbench.github.io/#e7227d9e538d734f61129d449df3de9b) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>String#includes vs. String#indexOf vs. RegExp</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@derekantrican
derekantrican / Program.cs
Last active December 23, 2020 01:22
A template for a Reddit Bot written in C# using RedditSharp
using RedditSharp;
using RedditSharp.Things;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
@derekantrican
derekantrican / Program.cs
Created September 17, 2020 17:40
C# console app to set the top-most picture on a subreddit to the Windows lock screen
using System;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using Newtonsoft.Json.Linq;
namespace SubredditLockscreen
{
class Program
@derekantrican
derekantrican / Program.cs
Created September 17, 2020 17:05
C# console app to set Windows background image and lockscreen image (REQUIRES ADMIN PERMISSIONS)
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace LockScreen
{
/* ====================================================
*