Skip to content

Instantly share code, notes, and snippets.

View fearofcode's full-sized avatar
🎵
Take that chance / All day long / Fucking up so fucking strong

Warren Henning fearofcode

🎵
Take that chance / All day long / Fucking up so fucking strong
View GitHub Profile
@fearofcode
fearofcode / MVVMToolkit.cs
Created September 17, 2018 09:31
MVVM toolkit in a screenful of code
namespace MVVMToolkit
{
public abstract class ObservableObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
@fearofcode
fearofcode / App.xaml
Last active September 19, 2018 07:49
Simple window switching example with windows passing data to one another. Also shows a working TestStack.White test.
<Application x:Class="LoginExample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:LoginExample"
StartupUri="StartingWindow.xaml">
<Application.Resources></Application.Resources>
</Application>
@fearofcode
fearofcode / rayon_test.rs
Created October 28, 2018 20:47
Simple embarassingly parallel Rayon example
/* sample output (on an 8 core machine):
time elapsed (parallel): 732.39394ms
999: false
time elapsed (serial): 5.857433675s
999: false
5.857433675 seconds / 732.39394 ms = 7.99765448 ~= 8
*/
@fearofcode
fearofcode / libpqxx_test.cpp
Created November 9, 2018 08:39
working libpqxx example
#include <iostream>
#include <chrono>
#include <pqxx/pqxx>
int main(int, char *argv[])
{
pqxx::connection c("dbname=arete user=postgres password=postgres");
{
pqxx::work txn(c);
#include <iostream>
#include <chrono>
#include <SQLiteCpp/SQLiteCpp.h>
int main() {
auto start = std::chrono::high_resolution_clock::now();
SQLite::Database db("example.db3", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
db.exec("create table if not exists test(id integer primary key autoincrement, name text, size integer)");
@fearofcode
fearofcode / pcg_benchmark_vs_std_lib.cpp
Created December 14, 2018 15:06
Sample benchmark of PCG code
/*
Sample output:
12/14/18 07:05:12
Running neuroevolution.exe
Run on (8 X 3492 MHz CPU s)
CPU Caches:
L1 Data 32K (x4)
L1 Instruction 32K (x4)
L2 Unified 262K (x4)
@fearofcode
fearofcode / simple_neuron.cpp
Created December 14, 2018 16:24
single artificial neuron with eigen
#include <iostream>
#include <random>
#include <cmath>
#include <Eigen/Core>
#include "pcg_random.hpp"
using namespace Eigen;
template<unsigned int Size>
struct neuron {
@fearofcode
fearofcode / server.go
Created January 20, 2019 23:17
simple usage of Gorilla Mux in Go
package main
import (
"encoding/json"
"log"
"net/http"
"strconv"
"time"
"github.com/gorilla/mux"
@fearofcode
fearofcode / .vimrc
Created April 27, 2019 22:18
new machine setup WIP
filetype plugin indent on
syntax on
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
set nocompatible
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
@fearofcode
fearofcode / win32_handmade.cpp
Created October 27, 2019 07:32
Handmade Hero Day 1 with DPI awareness
#include <windows.h>
#include <shellscalingapi.h>
int CALLBACK
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness
SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
MessageBoxA(0, "Message box text!", "Message Box information", MB_OK|MB_ICONINFORMATION);