Skip to content

Instantly share code, notes, and snippets.

View Indy9000's full-sized avatar
🏠
Working from home

Indy M. Indy9000

🏠
Working from home
View GitHub Profile
@Indy9000
Indy9000 / concurrency-kata.cpp
Created October 1, 2019 12:23
difference between threads and async
// worker threads vs async/futures
//
// This demonstrates that for heavy compute that require multiple workers that
// send the results in a queue to the caller, using async/futures is
// much simpler than using worker threads
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
@Indy9000
Indy9000 / index.html
Created April 17, 2019 08:34
barebones html template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My HTML App Template</title>
<meta name="description" content="My HTML App Template">
<meta name="author" content="indy9000">
@Indy9000
Indy9000 / ActiveObject.cpp
Last active November 13, 2017 16:06
Active Object Pattern
#include <functional>
#include <queue>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <iostream>
class Active {
public:
using Message = std::function<void()>;

docker save | gzip > .tar.gz zcat .tar.gz | docker load

This loads the docker image with as the name and tag. Have to set the tag after loading

@Indy9000
Indy9000 / Vim Fu
Last active June 11, 2017 11:38
Lesser known Vim Magic
Execute currently saved .py file
`:! python %`
Count the number of words in the saved file
`:!wc %`
Read a file in to Vim
`:!r filename`
Insert output of a shell command to current file
@Indy9000
Indy9000 / median-of-two-sorted-vectors.cc
Created February 12, 2017 16:23
Median of two sorted vectors
// median of two sorted arrays
#include <iostream>
#include <vector>
#include <queue>
std::vector<int> merge(const std::vector<int>& v1, const std::vector<int>& v2){
std::vector<int> result(v1.size()+v2.size());
int i=0;
int j=0;
@Indy9000
Indy9000 / merge_two_sorted_vectors.cc
Created February 8, 2017 16:12
Merge two sorted vectors
#include <iostream>
#include <vector>
std::vector<int> merge_vec(const std::vector<int>& v1, const std::vector<int>& v2){
std::vector<int> result;
if(v1.size()==0) return v2;
if(v2.size()==0) return v1;
std::size_t i = 0; //v1 indexer
@Indy9000
Indy9000 / longest-palindome.cc
Last active February 6, 2017 23:57
Extract longest palindrome from a string of letters
#include <iostream>
#include <string>
std::string longest_palindrome(const std::string& word){
if(word.size()<3)
return std::string();
std::string longest("");
for(std::size_t i=1;i<word.size()-1;++i){
auto left = i - 1;
@Indy9000
Indy9000 / SplitCSV.fsx
Created January 24, 2017 22:17
CSV splitter for lines with escaped delimeters
(***
Converts a csv line which contain escaped elements delimited by for example ". The elements inside these delimters
can contain a , so a simple line.Split(',') would be incorrect.
example:
converts
val line : string = ""22 Dec 2014",BP,"EXPENSES ","1000.00", , "
to
val toks : string [] = [|"22 Dec 2014"; "BP"; "EXPENSES "; "1000.00"; " "|]
***)
@Indy9000
Indy9000 / weasels.m
Created September 10, 2016 23:04
Exploration of fast convergence of Genetic Algorithms
%% Exploration of fast convergence of Genetic Algorithms
% This matlab script contains the code for the results presented in the
% above paper.
%%
function weasels()
% Test main hypothesis, if crossover speeds up convergence
experiment1()
% Effect of smaller population
experiment2()
% Effect of range of mutation over range of crossover probabilities