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 / 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 / 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 / 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)
#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 / 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);
@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 / 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 / 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 / MainWindow.xaml
Created September 11, 2018 05:03
Simple async/await example in WPF
<Window x:Class="asyncawait.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:asyncawait"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="450">
<DockPanel>
<Button Name="buttonAsync"
@fearofcode
fearofcode / MainWindow.xaml
Created September 4, 2018 09:31
evaluating python code by shelling out and piping its output to a wpf window
<Window x:Class="databinding.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:databinding"
mc:Ignorable="d"
Title="MainWindow"
Height="800"
Width="800">