Skip to content

Instantly share code, notes, and snippets.

@serge1
serge1 / getmemory.cpp
Created November 14, 2022 14:30
Measures the current (and peak) resident and virtual memories usage of Linux C/C++ process
/*
* Measures the current (and peak) resident and virtual memories
* usage of your linux C process, in kB
*/
void getMemory( int* currRealMem,
int* peakRealMem,
int* currVirtMem,
int* peakVirtMem )
{
@serge1
serge1 / winkeyboard.py
Created May 31, 2020 07:51
Send Windows keyboard events from Python script
import ctypes
from ctypes import wintypes
import time
import msvcrt
user32 = ctypes.WinDLL('user32', use_last_error=True)
INPUT_MOUSE = 0
INPUT_KEYBOARD = 1
@serge1
serge1 / DynamicCompiler.java
Last active February 17, 2017 10:00
Eclipse View project that demonstrates JavaScript and Java dynamic compilation and inter operability
package jstest.views;
import javax.tools.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.security.SecureClassLoader;
import java.util.ArrayList;
@serge1
serge1 / ScriptTest.java
Created February 17, 2017 09:34
Using JavaScript from Java class (and vice versa)
import java.util.List;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class ScriptTest {
public final String hello = "Hello";
@serge1
serge1 / property_map_test.cpp
Created October 25, 2015 06:21
Boost property map usage example
#include <boost/property_tree/ptree.hpp>
#include <boost/any.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/foreach.hpp>
#include <list>
#include <string>
#include <iostream>
using namespace boost::property_tree;
@serge1
serge1 / xtext_in_multi_page_editor.java
Last active September 27, 2015 15:46
Xtext Dsl Editor in Multi-Page Editor
To add you Xtext Dsl Editor to Multi-Page Editor
Getting the instance of XText editor
MyDslActivator activator = MyDslActivator.getInstance();
final Injector injector = activator.getInjector("org.shashwat.xtext.mydsl.MyDsl");
XtextEditor xtextEditor = injector.getInstance(XtextEditor.class);
Remember to have editor input instance of IFileEditorInput. XtextEditor uses XtextDocumentProvider which extends FileDocumentProvider
// public domain
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <windows.h>
@serge1
serge1 / label.cpp
Created July 7, 2014 13:24 — forked from 7shi/label.cpp
// public domain
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <windows.h>
@serge1
serge1 / GitChangeMail.txt
Last active August 29, 2015 14:02
A command to change credentials of the whole Git repository
git filter-branch -f --commit-filter 'GIT_COMMITTER_NAME="Serge Lamikhov-Center"; GIT_AUTHOR_NAME="Serge Lamikhov-Center"; GIT_COMMITTER_EMAIL="[email protected]"; GIT_AUTHOR_EMAIL="[email protected]"; git commit-tree "$@";' HEAD
@serge1
serge1 / HPTimer.hpp
Created May 11, 2014 12:00
High Precision Timer for Windows
#include <windows.h>
class HPTimer
{
public:
HPTimer( std::string name ) : total(0.0), name_(name)
{
}
void reset()