Skip to content

Instantly share code, notes, and snippets.

View stungeye's full-sized avatar

Kyle Geske stungeye

View GitHub Profile
@stungeye
stungeye / lambda.cpp
Created January 27, 2022 21:32
Lambdas in C++
#include <iostream> // std::cout
#include <string> // std::string
#include <vector> // std::vector
#include <algorithm> // std::count_if, std::adjacent_find, std::sort
#include <numeric> // std::accumulate
#include <functional> // std::function
#include <array> // std::array
void printIt(const std::function<int(const std::string& word)>& fnc, const std::string& word) {
std::cout << fnc(word) << "\n";
@stungeye
stungeye / binary_files.cpp
Created January 20, 2022 20:07
Reading and Writing Strings From a Binary File
// ExploringFiles.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <filesystem>
#include <fstream>
#include <vector>
#include <string>
@stungeye
stungeye / money.cpp
Created January 18, 2022 15:53
Money Class
class Money{
static constexpr int centsPerDollar{100};
int mDollars{0};
int mCents{0};
// Ensure that we never have more than 99 cents.
void rollCentsIntoDollars() {
int additionalDollars = mCents / Money::centsPerDollar;
mDollars += additionalDollars;
mCents %= Money::centsPerDollar;
#include <iostream>
#include <filesystem>
#include <fstream>
#include <vector>
int main() {
std::cout << "CWD: " << std::filesystem::current_path() << "\n";
std::ifstream inputFile{"data.txt"};
@stungeye
stungeye / code_words.txt
Created January 6, 2022 22:39
Doorman's File
1-3 a: abcde
1-3 b: cdefg
2-9 c: ccccccccc
1-8 n: dpwpmhknmnlglhjtrbpx
11-12 n: frpknnndpntnncnnnnn
4-8 t: tmttdtnttkr
12-18 v: vvvvvvvqvvvvvqvvgf
3-4 c: cccc
17-18 z: zzzzzzzzdzzzzzzgzr
5-6 l: llltzl
@stungeye
stungeye / .p4ignore
Last active November 17, 2021 17:06
P4 Ignore File for Unreal Engine
Saved/
Intermediate/
DerivedDataCache/
FileOpenOrder/
obj/
.git/
*.pdb
*.vcxproj
*.sln
*-Debug.*
@stungeye
stungeye / random.md
Last active September 14, 2021 19:59
Random Number In Range

A simple way to generate a random number in C++ is by using the rand() method.

Here's an application that prints out 10 random numbers from a user specified range:

int randomNumber(const int min, const int max) {
    const int range = max - min + 1;
    return rand() % range + min;
}
@stungeye
stungeye / instructions.md
Last active September 11, 2021 12:40
Configure OBS Studio to Record / Stream a Portion of Your Screen

Want to Record / Stream a Portion of your Screen using OBS Studio?

  • Ensure you have a Display Capture source. (This source will default to capturing your entire display.)
  • Click on the Displau Capture source and hit CTRL-E to edit the scene transform.
  • Use the crop settings below (Crop Left, Right, Top, Bottom) to set the screen crop. You can also crop by ctrl-click-dragging the red points around the scene output preview.
  • Next go to the main OBS settings (above the exit button) and then to the Video settings section.
  • Change the Base and Output resolution to match the resolution of your cropped area.
  • You can now stream or record your cropped screen at full resolution.

It's also good to switch the Recoding Quality (in Output Settings) to Indistinguishable Quality to tame output file sizes.

@stungeye
stungeye / phonecall_tests.js
Last active June 15, 2021 18:46
Will you, Won't You Starter Code
function passOrFail(predicate, expectation, msg) {
const outcome = (predicate == expectation) ? "PASSED" : "FAILED";
console.log(`${msg}: ${outcome}`);
}
function expect(predicate, msg) {
return {
toBeFalsy: () => passOrFail(predicate, false, msg),
toBeTruthy: () => passOrFail(predicate, true, msg)
}
@stungeye
stungeye / leap_test.js
Last active September 9, 2024 16:05
Leap Year Testing Code p5js
function passOrFail(predicate, expectation, msg) {
const outcome = (predicate == expectation) ? "PASSED" : "FAILED";
console.log(`${msg}: ${outcome}`);
}
function expect(predicate, msg) {
return {
toBeFalsy: () => passOrFail(predicate, false, msg),
toBeTruthy: () => passOrFail(predicate, true, msg)
}