Skip to content

Instantly share code, notes, and snippets.

@socketbox
socketbox / gcloud_secret_revealor.sh
Last active June 15, 2022 23:53
Get all secrets and sensitive data for a GCP project
#!/usr/bin/env bash
set -eou pipefail
sec_list=$(gcloud secrets list --format="table[no-heading](name.basename())")
for s in ${sec_list[*]};
do
sec=$(gcloud secrets versions access latest --secret="$s")
printf "%s: %s\n" $s $sec
done
@socketbox
socketbox / looping_temp_test.sh
Created March 29, 2020 02:17
Raspberry Pi Cooling Test
#!/bin/bash
clear
for f in {1..10}
do
vcgencmd measure_temp
sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run > /dev/null 2>&1
done
vcgencmd measure_temp
@socketbox
socketbox / toggle_monitor_input.sh
Created January 11, 2020 23:34
Toggle monitor input from keyboard in linux
#!/usr/bin/env bash
#TODO: call ddcutil detect and parse output for actual devices; only constants should be VCP code and vars
# related to ddcutil
BUS_FLAG="-b"
I2C_ID=5
CMD="ddcutil"
GETTER=getvcp
SETTER=setvcp
@socketbox
socketbox / cube_solver.adoc
Last active May 23, 2022 21:17
Instructions for Solving Rubik's Cube as Presented by Robbie Gonzalez of Wired

Attributions

These instructions are an amalgam of steps presented by Wired’s Robbie Gonzalez, Phil of thecubicle.com, and JPerm of YouTube fame.

Definitions

A right trigger is R U R'

A left trigger is L' U' L

An r-alg is R U R' U'

@socketbox
socketbox / Exercise4Mod.java
Created November 1, 2019 01:52
Brute force method of arriving at values for modular hashing of a small set of strings
//Borrowed from https://github.com/reneargento/algorithms-sedgewick-wayne/blob/master/src/chapter3/section4/Exercise4.java
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
/**
* Created by Rene Argento on 19/07/17.
* Modified on 10/30/2019
*/
public class Exercise4Mod
@socketbox
socketbox / rngchk.c
Created October 23, 2019 22:40
Unbiased Random Integer Generator Over a Range
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <time.h>
/*
* generates an unsigned int between low and high, inclusive of both
* taken from: https://en.cppreference.com/w/c/numeric/random/rand
*
#include <iostream>
#include <stdio.h>
#include <limits>
int main()
{
std::cout << "Integers: \n";
std::cout << "\tType\t\tSize (Bits)\tLowest\t\tMin\t\tMax\n";
std::cout << "____________________________________________________________________________\n";

Keybase proof

I hereby claim:

  • I am socketbox on github.
  • I am chb (https://keybase.io/chb) on keybase.
  • I have a public key ASCl2ulrlMT_HOe0YGLssnXbJHQgK_JMMVU8zT64pIrrJAo

To claim this, I am signing this object:

@socketbox
socketbox / gist:17a3e90e836f09d71f99
Created September 22, 2015 12:39
Diff two directories on Windows Server with PowerShell
$fso = Get-ChildItem -Recurse -path C:\fso
$fsoBU = Get-ChildItem -Recurse -path C:\fso_BackUp
Compare-Object -ReferenceObject $fso -DifferenceObject $fsoBU
@socketbox
socketbox / drop_db_mssql2008.sql
Created November 11, 2014 16:13
Drop database in MS SQL Server 2008
USE master;
ALTER DATABASE [db_name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [db_name];