Skip to content

Instantly share code, notes, and snippets.

View kghose's full-sized avatar
🕉️

Kaushik Ghose kghose

🕉️
View GitHub Profile
@kghose
kghose / .vimrc
Created February 13, 2024 02:59
Vim configuration
" ~/.vimrc
set mouse=a
set nu
set laststatus=2
set statusline=
set statusline+=%=
set statusline+=\[%c]
set statusline+=\ %l/
set statusline+=%L
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kghose
kghose / doublebuffer.cpp
Last active June 1, 2020 01:46
File writing buffering experiment
/*
g++ --std=c++17 -O3 doublebuffer.cpp -odoublebuffer
*/
#include <chrono>
#include <ctype.h>
#include <fstream>
#include <string>
#include <thread>
const size_t buf_size = 50000;
/*
Code to perform L1, L2 cache locality experiments
https://kaushikghose.wordpress.com/2020/01/27/profiling-and-improving-cache-performance/
*/
#include <iostream>
#include <vector>
const size_t N = 1200;
class Matrix {
@kghose
kghose / matmul.cpp
Created January 30, 2020 03:47
A certain awkwardness with C++ inheritance
/*
*/
#include <iostream>
#include <vector>
const size_t N = 1000;
class Matrix {
#include <iostream>
#include <vector>
struct Feet {
double f;
Feet(double f)
: f(f)
{
}
explicit constexpr operator double() const { return f; }
@kghose
kghose / strong.cpp
Last active January 7, 2020 17:48
Testing with units in C++
#include <iostream>
#include <vector>
#include "units.h"
using namespace units::literals;
using namespace units;
typedef units::length::meter_t Meters;
typedef units::length::foot_t Feet;
@kghose
kghose / embed.py
Last active September 23, 2022 11:09
Code for: Embed Ace editor in a Python QT app
import sys
from PySide2.QtCore import QObject, QUrl, Signal, Slot
from PySide2.QtWidgets import QApplication
from PySide2.QtWebChannel import QWebChannel
from PySide2.QtWebEngineWidgets import QWebEngineView
# We create this file as follows
# First create a .qrc file so we can include the ace editor code and the qqwebchannel.js in a form
# usable by the application. Delightfully QT doesn't allow wildcards or directories in the .qrc
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/*
* Compile with
* gcc -msse4.1 -ggdb -O3 -Wall -Wextra measure-dram.c -o measure-dram \
* && objdump -dx measure-dram | egrep 'movntdqa' -A 2 -B 2
*/
#define _GNU_SOURCE // setaffinity
#include <emmintrin.h>
#include <fcntl.h>
#include <sched.h>