Skip to content

Instantly share code, notes, and snippets.

View AndrewBarfield's full-sized avatar

Andrew Barfield AndrewBarfield

View GitHub Profile

HTML5 Web Terminal

A console for the Web written in completely in JavaScript. The console supports Web versions of some Linux commands. This work is based, in part, on earlier work by Eric Bidelman.

A Pen by Andrew Mitchell Barfield on CodePen.

License.

# Binaural Beats Generator
#
# Streamlit applet to generate binaural beats.
# User can set Duration (seconds), Carrier Frequency (Hz), and Beat Frequency (Hz).
# Generated WAV file can be downloaded from link below graphs.
#
import streamlit as st
import numpy as np
import scipy.io.wavfile
from scipy.signal import windows
@AndrewBarfield
AndrewBarfield / Output.txt
Created April 30, 2012 10:27
C#: Calculate the Exponential Function exp(x) using Taylor Expansion
CSC 340 Scientific Computing
Calculate exp(3.7) using Taylor's Expansion
Andrew M. Barfield
Thursday, January 15, 2009
1:56:36 PM
Answer calculated in 29 iterations.
exp(3.7) = 40.447
@AndrewBarfield
AndrewBarfield / gist:2556793
Created April 30, 2012 09:23
C#: System.Collections.IEnumerable: Custom Iterator Example
using System;
namespace IteratorsExample {
class Program {
static void Main(string[] args) {
// Create an instance of the collection class
EvenIntegers ei = new EvenIntegers();
// Iterate with foreach
foreach ( int num in ei ) {
@AndrewBarfield
AndrewBarfield / WikiJSPurgeHistory.py
Created December 30, 2021 11:58
Wiki.js: Purge History via GraphQL
import requests
import json
WikiJSGraphQLAccessToken = "replace_with_your_token"
WikiJSGraphQLEndpoint = f"http://192.168.xx.xx:1234/graphql"
# Purge history older than 2 hours
# See: https://en.wikipedia.org/wiki/ISO_8601#Durations
GraphQLPagePurgeHistoryQuery = """mutation Page {
@AndrewBarfield
AndrewBarfield / gist:2552137
Created April 29, 2012 17:31
PowerShell: Display file descriptions of all executables in the System32 folder
cls
# Change the current directory to the System folder
cd C:\Windows\System32\
# Display all executable files along with their file description
get-childitem * -include *.exe | foreach-object {
"{0}, {1}" -f $_.Name,
[System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).FileDescription }
@AndrewBarfield
AndrewBarfield / scan.sh
Created October 25, 2021 17:24
Scan region of RF spectrum using rtl_power_fftw
#!/bin/bash
reset
# FFT bin size for a sample rate of 2,400,000 Hz:
#
# Bin Count Bin Width (Hz) Bin Width (kHz)
# 4 600,000.000 600.000
# 8 300,000.000 300.000
# 16 150,000.000 150.000
@AndrewBarfield
AndrewBarfield / gist:2556782
Created April 30, 2012 09:19
C#: IDisposable: Cleaning up managed and unmanaged resources
public class MyResource : IDisposable {
// Pointer to an external unmanaged resource.
private IntPtr handle;
// Other managed resource this class uses.
private Component component = new Component();
// Track whether Dispose has been called.
private bool disposed = false;
@AndrewBarfield
AndrewBarfield / gist:2556767
Created April 30, 2012 09:16
C#: IComparable: Converting miles to kilometers
using System;
using System.Collections;
/*
* Sample Output
*
* 10 miles (16.09344 km)
* 86 miles (138.403584 km)
* 146 miles (234.964224 km)
* 214 miles (344.399616 km)
@AndrewBarfield
AndrewBarfield / gist:2557544
Created April 30, 2012 11:39
C#: Automating MS Excel to create a new Workbook and fill it with data
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
namespace ExcelTest
{
class Program