Skip to content

Instantly share code, notes, and snippets.

View Rican7's full-sized avatar
😮
My dotfiles just keep getting better... and its been OVER 10 YEARS NOW! ⌚😮🤯

Trevor N. Suarez Rican7

😮
My dotfiles just keep getting better... and its been OVER 10 YEARS NOW! ⌚😮🤯
View GitHub Profile
@Rican7
Rican7 / binarygap.go
Created June 27, 2023 22:05
Find the longest "Binary Gap" within a positive integer. Where the "binary gap" is defined as a sequence of 0s surrounded by 1s in the binary format of a number.
package main
import (
"fmt"
)
func LongestBinaryGap(n int) int {
longestGap := 0
binN := fmt.Sprintf("%b", n)
@Rican7
Rican7 / KeepAwake.ps1
Last active January 25, 2021 10:50 — forked from jamesfreeman959/keepawake.ps1
KeepAwake - Keep Windows "awake" - A PowerShell script to keep Windows awake and make think the user is active on the keyboard
# KeepAwake - Keep Windows "awake"
#
# Useful for keeping awake during the running long/maintenance processes without
# having to change power or screen-saver options.
#
# See https://gist.github.com/jamesfreeman959/231b068c3d1ed6557675f21c0e346a9c
Write-Host @"
KeepAwake running...
@Rican7
Rican7 / build-m3u-files-for-roms.sh
Created November 12, 2020 07:54
Builds m3u files for ROM image files (.cue, .iso)
#!/usr/bin/env sh
#
# Builds m3u files for ROM image files (.cue, .iso)
find -type f \( -iname '*(*disc*.cue' -o -iname '*(*disc*.iso' -o -iname '*(*mode*.cue' -o -iname '*(*mode*.iso' \) -exec sh -c 'echo "$(basename -- "$0")" >> "$(echo "${0%.*}" | sed "s/ (disc [0-9]\+)\| ([A-Za-z]\+ disc)\| ([A-Za-z]\+ mode)//gI")".m3u' {} \;
@Rican7
Rican7 / internetarchive-download.md
Created October 29, 2020 01:58
Download multi-file items from the Internet Archive (archive.org)

Internet Archive (archive.org) multi-file item downloading

Finding an item to download

  1. Find an item that you'd like to download (for example: https://archive.org/details/SuperNintendoUSACollectionByGhostware)
  2. Grab its "identifier" (you can see it in the HTML of the page, but otherwise just use the last part of the URL for a "details" page)

Downloading the files

At this point, you could just download the files by clicking on them on the HTML page, but that's slow and concurrent-download-limited... Sooo...

@Rican7
Rican7 / windows-volume-clone.bat
Last active March 15, 2024 00:12
Windows built-in volume "clone"
robocopy <source> <destination> /E /COPYALL /DCOPY:DATE /SL /SJ /ZB /V
@Rican7
Rican7 / instagram-download-all-post-media.js
Last active November 7, 2019 00:01
Download all media of an Instagram post in new tabs (windows). (NOTE: Only works on direct post page links, not "lightboxed" posts from profile pages)
(function (scope) {
/* NOTE: Comments are all in "block" form for easier bookmark one-lining */
let download = async function (url) {
const filename = (new URL(url)).pathname.split("/").pop();
const fetched = await fetch(url);
const tempElement = document.createElement("a");
tempElement.target = "_blank";
@Rican7
Rican7 / instagram-open-all-post-media.js
Last active November 7, 2019 00:00
Open all media of an Instagram post in new tabs (windows). (NOTE: Only works on direct post page links, not "lightboxed" posts from profile pages)
(function (scope) {
/* NOTE: Comments are all in "block" form for easier bookmark one-lining */
/* Public pages will hold their entry data here */
let entries = scope._sharedData.entry_data.PostPage;
/* If the data doesn't exist there... */
if (entries[0].graphql === undefined) {
/* Logged in pages will have the data stored in a different location */
entries = Object.values(scope.__additionalData).map(x => x.data);
@Rican7
Rican7 / .bash_rc
Created March 9, 2018 21:11
Bash - Add multiple GOPATH bin locations to your PATH
#!/usr/bin/env bash
# Go language path
export GOPATH="$HOME/development/go:$GOPATH"
gopath_bins="${GOPATH//:/\/bin:}/bin"
export PATH="$gopath_bins:$PATH"
@Rican7
Rican7 / Enable Import Photos and Videos.bat
Created October 16, 2017 17:13
Enable the old style (Win 7) "Import pictures and videos" AutoPlay option for Windows 10
cd "C:\Program Files (x86)\Windows Photo Viewer"
regsvr32 PhotoAcq.dll
regsvr32 PhotoViewer.dll
@Rican7
Rican7 / strongly-typed-object-set.php
Created July 28, 2017 19:49
PHP Strongly Typed Object Set
<?php
declare(strict_types=1);
interface Set extends Countable, IteratorAggregate
{
public function add(...$members): void;
public function remove(...$members): void;
public function contains(...$members): bool;
public function clear(): void;