Skip to content

Instantly share code, notes, and snippets.

View bwedding's full-sized avatar

bwedding

  • Sweden
View GitHub Profile
@bwedding
bwedding / reverseString.cpp
Last active April 28, 2024 22:12
Compare hand-rolled strrev vs std::reverse
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <chrono>
#include <random>
#include <ranges>
#include <algorithm>
#include <string_view>
@bwedding
bwedding / main.cpp
Last active April 27, 2024 13:59
1000 random tasks
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <functional>
#include <chrono>
using namespace std::chrono;
constexpr size_t N = 1000;
@bwedding
bwedding / bits.cpp
Created January 30, 2024 09:12
Bitwise distribution Analysis
#include <iostream>
#include <random>
#include <vector>
#include <climits> // for UINT_MAX
class BitAccumulator {
public:
BitAccumulator() : bit_counts(32, 0) {}
// Method to accumulate bit counts
@bwedding
bwedding / die.cpp
Created January 30, 2024 08:32
Random Dice Roller
#include <iostream>
#include <random>
#include <vector>
#include <array>
class Die {
public:
// Constructor for a 6-sided die
Die() : Die(6) {}
@bwedding
bwedding / i_before_e.cpp
Last active December 18, 2023 23:37
I Before E except after C
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
// Uses this list of 470,000 English words
// https://github.com/dwyl/english-words
bool isValidWord(const std::string& word)
{
@bwedding
bwedding / Left Wing Study
Created June 3, 2023 20:40
Understanding left-wing authoritarianism: Relations to the dark personality traits, altruism, and social justice commitment
Understanding left-wing authoritarianism: Relations to the dark personality traits, altruism, and social justice commitment
Ann Krispenz & Alex Bertrams
Current Psychology (2023)Cite this article
Abstract
In two pre-registered studies, we investigated the relationship of left-wing authoritarianism with the ego-focused trait of narcissism. Based on existing research, we expected individuals with higher levels of left-wing authoritarianism to also report higher levels of narcissism. Further, as individuals with leftist political attitudes can be assumed to be striving for social equality, we expected left-wing authoritarianism to also be positively related to prosocial traits, but narcissism to remain a significant predictor of left-wing authoritarianism above and beyond those prosocial dispositions. We investigated our hypotheses in two studies using cross-sectional correlational designs. Two nearly representative US samples (Study 1: N = 391; Study 2: N = 377) completed online measures of left-wing authorit
@bwedding
bwedding / unclebob.cpp
Last active April 9, 2023 22:56
Cleanup of UncleBobs Code
#include <iostream>
#include <stdlib.h>
#include <chrono>
#include <vector>
#include <format>
using namespace std;
using namespace std::chrono;
const unsigned long N = 999983L;
@bwedding
bwedding / crazyboblee.cpp
Last active April 5, 2023 21:19
C++ Implementation of Crazy Bob Lee's clever solution to a coding challenge
// In honor of Crazy Bob Lee who was tragically murdered today
// https://www.beust.com/weblog/coding-challenge/
// I've ported his genius code to C++ and also created a non-recursive version, which is slightly faster on my system
// write a counter function that counts from 1 to max but only returns numbers whose digits don’t repeat.
// For example, part of the output would be:
// 8, 9, 10, 12 (11 is not valid)
// 98, 102, 103 (99, 100 and 101 are not valid)
// 5432, 5436, 5437 (5433, 5434 and 5435 are not valid)
// Also:
@bwedding
bwedding / RandomNumbers.cpp
Created March 9, 2023 20:14
Generate Random Numbers in C++
// RandomGenerator.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <random>
#include <array>
#include <cstdint>
class RandomNumbers
{
@bwedding
bwedding / CanEnums.cs
Created February 21, 2023 15:31
CanHeader
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SRHStressTester
{
public enum HeartCommand
{