Skip to content

Instantly share code, notes, and snippets.

View emilk's full-sized avatar

Emil Ernerfeldt emilk

View GitHub Profile
{
"color_scheme": "Packages/Colorcoder/Monokai (Colorcoded).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Edlo",
"font_size": 12,
"gutter": true,
"highlight_modified_tabs": true,
"indent_guide_options":
[
"draw_normal",
@emilk
emilk / strprintf.hpp
Created March 15, 2015 14:18
strprintf
std::string strprintf(const char * __restrict, va_list) __printflike(1, 0);
std::string strprintf(const char * __restrict, ...) __printflike(1, 2);
std::string strprintf(const char* format, va_list vlist)
{
#if 1
char* buff = nullptr;
int ret = vasprintf(&buff, format, vlist);
ASSERT(ret >= 0);
std::string str = buff;
@emilk
emilk / clang_lint.py
Last active March 19, 2022 10:22
C++ linter in Python using libclang
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" C++ linter using libclang. Call with [filenames] """
from __future__ import print_function
from clang.cindex import Config, TypeKind, CursorKind, Index
from pprint import pprint
import platform
import sys
@emilk
emilk / read_write_mutex.hpp
Last active February 8, 2016 13:31
Mutex for many-readers, single writer
// Created by Emil Ernerfeldt on 2013-01-24.
// Cleaned up 2016-01-28.
#pragma once
#include <atomic>
#include <condition_variable>
#include <mutex>
#include <thread>
namespace util {
@emilk
emilk / xcode.sublime-build
Last active April 20, 2020 16:42
sublime-build for xcode projects
{
"working_dir": "${project_path:${folder}}",
"shell_cmd": "xcodebuild -project *.xcodeproj",
"file_regex": "^(.*):([0-9]*):[0-9]*:[fatal ]+error: ",
"selector": "source.c++",
"variants": [
{
"name": "Build & Run",
"working_dir": "${project_path:${folder}}",
@emilk
emilk / log.sh
Created July 12, 2016 13:42
Bash script to log what you are doing
#!/bin/bash
# Log your activity. View with tail log.txt
echo $(date +"%Y-%m-%d %H:%M:%S") $@ >> ~/log.txt
@emilk
emilk / daily_loguru.cpp
Created August 14, 2016 00:17
Daily log files with Loguru
// The first 10 bytes of message.preamble is the current date in YYYY-MM-DD.
#define DATE_LEN 10
struct DailyLogger
{
FILE* file = nullptr;
char date[DATE_LEN] = { 0 };
};
void daily_log(void* user_data, const loguru::Message& message)
sudo dd if=/dev/zero of=/root/myswapfile bs=1M count=65536
sudo chmod 600 /root/myswapfile
sudo mkswap /root/myswapfile
sudo swapon /root/myswapfile
{
"shell_cmd": "./build_and_run.sh",
"working_dir": "${project_path:${folder}}",
"file_regex": ".*?([^\\s]+?\\.[a-z]+?)\\b.\\b([0-9]+).*",
"selector": "source.rs4",
}
{
"file_regex": "([^\\s@]*?):([0-9]+):([0-9]+)(.*)$",
"selector": "source.rust",
"shell_cmd": "cargo check --lib --all-features",
"working_dir": "${project_path}",
}