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 / learning_gtk.c
Created November 10, 2019 07:18
very first gtk program that checks that the library is installed
#include <gtk/gtk.h>
/* to compile in ubuntu:
*
* sudo apt install libgtk2.0-dev
*
* in bash: gcc `pkg-config --cflags --libs gtk+-2.0` learning_gtk.c -o learning_gtk
* in fish shell: gcc learning_gtk.c (pkg_config --cflags --libs gtk+-2.0 | perl -pe
* 's/\s+/\n/g) -o learning_gtk
*/
@fearofcode
fearofcode / dynamic_compilation.cs
Last active November 4, 2019 08:10
Simple example of dynamically compiled code that can access data in the program that compiles the assembly
using System;
using System.Diagnostics;
using System.Linq;
namespace csharpdynamiccompilationtest
{
public class RegularClass
{
public static int Get(int[] i) { return i.Sum() + Program.rng.Next(1, 5); }
}
@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);
@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 / 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
*/