Skip to content

Instantly share code, notes, and snippets.

View SourceCode's full-sized avatar
👽
Byte Inspector

Ryan R SourceCode

👽
Byte Inspector
  • Weyland-Yutani Corporation
  • USA
View GitHub Profile
@SourceCode
SourceCode / QueryChatGPT.js
Last active February 26, 2023 04:22
ChatGPT prompt to JSON output
// Importing the "axios" and "fs" modules
const axios = require('axios');
const fs = require('fs');
// Creating an instance of Axios with a "Bearer" token for authorization
const client = axios.create({
headers: {
Authorization: `Bearer ${fs.readFileSync('apikey.txt', 'utf-8').trim()}`
}
});
@SourceCode
SourceCode / RenderBinary.js
Created January 8, 2023 02:34
Render binary time representation into the chrome console
// Use in chrome console
function RenderBinary() {
const zeroChar = '🟢';
const oneChar = '🟠';
let frameNum = 0;
let pos = 0;
let timeStr = '';
let date = new Date();
let hours = date.getHours();
@SourceCode
SourceCode / DownloadFilesWithYoutubeDLandAria2c.sh
Created January 6, 2023 23:05
Use youtube-dl and aria2c to download videos in the file URL_LIST.txt while logging completed files to existing.txt
youtube-dl --external-downloader aria2c --external-downloader-args "-x 16 -j 16 -c --max-file-not-found=10 --max-tries=20 --retry-wait=20" --format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --merge-output-format mp4 -a URL_LIST.txt -i --download-archive ~/existing.txt -o '%(epoch)s-%(title)s.%(ext)s'
@SourceCode
SourceCode / ConsoleGetURLByFilter.js
Last active January 6, 2023 23:04
Creates a new window and select URLs by filter and write to list in window
// Run once in the console per page session
const NewWindow = window.open("NEW_LIST");
// Run each time to scrape URLS - they will be added to the window opened during the first run
// Replace foo.bar/baz with your filter
var x = document.querySelectorAll("a"), u = "foo.bar/baz", a = [];
for (let i = 0; i < x.length; i++) a.push([x[i].textContent.replace(/\s+/g, ' ').trim(), x[i].href]);
function g(f) {
let t = '';
for (let i = 0; i < a.length; i++) if (a[i][1].includes(f)) t += a[i][1] + '\n';
@SourceCode
SourceCode / flatten.es6
Created March 11, 2019 19:47
array flatten
const flat = (array, res) => {
// Short circuit the result if empty
if (array.length < 1 || !(array instanceof Array)) return res;
// Set start item
let s = array[0];
// Set remaining items
let r = array.slice(1);
@SourceCode
SourceCode / lambdaAMICleanup.py
Created December 18, 2017 11:03 — forked from bkozora/lambdaAMICleanup.py
AWS Lambda Function to Delete AMIs and Snapshots
# Automated AMI and Snapshot Deletion
#
# @author Robert Kozora <[email protected]>
#
# This script will search for all instances having a tag with "Backup" or "backup"
# on it. As soon as we have the instances list, we loop through each instance
# and reference the AMIs of that instance. We check that the latest daily backup
# succeeded then we store every image that's reached its DeleteOn tag's date for
# deletion. We then loop through the AMIs, deregister them and remove all the
# snapshots associated with that AMI.
@SourceCode
SourceCode / Graph.cs
Created October 1, 2017 22:28
Graph, GraphNode, NodeList, and Node for Graph data structure in C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
// This is based on the graph implementation found at: https://msdn.microsoft.com/en-us/library/ms379574(v=vs.80).aspx
// But is updated to work in the latest C# and Net Core
namespace Graph1
{
class Program
@SourceCode
SourceCode / TreeNode.cs
Created September 30, 2017 21:04
A tree data structure for C# Net Core
using System;
using System.Collections;
using System.Collections.Generic;
namespace Trees1
{
class Program
{
static void Main(string[] args)
{
@SourceCode
SourceCode / PermMissingElem.cs
Last active January 7, 2023 12:12
PermMissingElem - Codibility - C#
using System;
namespace PermMissingElem
{
class Program
{
static void Main(string[] args)
{
int[] A = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18 };
var S = new Solution();
@SourceCode
SourceCode / CyclicRotation.cs
Last active August 31, 2020 04:58
CyclicRotation of Array - Codibility - C#
using System;
namespace CyclicRotation
{
class Program
{
static void Main(string[] args)
{
var S = new Solution();
var A = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };