Skip to content

Instantly share code, notes, and snippets.

View sasq64's full-sized avatar
⌨️
Coding

Jonas Minnberg sasq64

⌨️
Coding
View GitHub Profile
@sasq64
sasq64 / sertest.cpp
Last active May 7, 2018 13:08
Serialization
#include <string>
#include <tuple>
#include <cstdio>
template<typename UnaryFunction>
void invoke_with_arg(UnaryFunction)
{}
/**
@sasq64
sasq64 / clangtidy.py
Created October 30, 2017 20:06
clang-tidy wrapper that handles .h files
#!/usr/bin/env python
import os.path
import subprocess
import platform
osname = platform.system()
def which(program):
import os
def is_exe(fpath):
import std.stdio;
import std.conv;
import std.exception;
import diesel;
import ansi;
import textscreen;
import std.string;
// Why exceptions
int test()
{
strint contents = File("data.txt").readAllText();
File myRoot, otherRoot;
myRoot.forEachFile([](const File &f) {
if(f.suffix() == "xxx")
@sasq64
sasq64 / callback.cpp
Last active April 5, 2021 14:27
C++ Callbacks
#include <functional>
#include <vector>
#include <memory>
template<typename... X> struct Callback;
template <typename R, typename ...ARGS> struct Callback<R(ARGS...)>
{
struct BaseFx
{
virtual R call(ARGS...) = 0;
@sasq64
sasq64 / extra.vim
Created September 1, 2016 13:57
Find functions and classes using silver searcher from vim
function! FindFunction(name)
cexpr! system('ag --vimgrep -G ".(cs\|c\|cpp\|h\|java)$" "[A-Za-z\*]+\s+([A-Za-z_]+::)?' . a:name . '\s*\([^\)]*\)\s*(?=\{)"')
endfunction
function! FindClass(name)
cexpr! system('ag --vimgrep -G ".(cs\|c\|cpp\|h\|java)$" "(class\|struct\|interface)\s+([A-Za-z_]+\s+)*' . a:name . '\s+(?!;)"')
endfunction
nmap <leader>af "zyiw:call FindFunction(@z)<cr>
nmap <leader>ac "zyiw:call FindClass(@z)<cr>
@sasq64
sasq64 / v8test.cpp
Last active February 14, 2016 20:49
#include <coreutils/utils.h>
#include <coreutils/log.h>
#include "v8/v8.h"
#include <string>
using namespace std;
@sasq64
sasq64 / func.cpp
Last active October 1, 2017 08:16
C++ Type erased dispatch - or whatever
#include <cstdio>
#include <functional>
#include <string>
#if __cplusplus <= 201200L
namespace std {
// index_sequence
template <class T, int SIZE> struct vec {
template <class... S> vec(const S& ... args) : data {args...} {}
bool operator==(const vec &v) const {
for(int i=0; i<SIZE; i++)
if(v[i] != data[i]) return false;
return true;
}
#ifdef MUSIC
#include "ModPlugin.h"
#include "ChipPlayer.h"
#endif
#include <grappix/grappix.h>
#include <SDL/SDL.h>
using namespace grappix;
using namespace utils;