Skip to content

Instantly share code, notes, and snippets.

View auxiliary's full-sized avatar

Mohammad (Moa) Raji auxiliary

View GitHub Profile
@auxiliary
auxiliary / volume_rendering.py
Created October 9, 2016 03:57 — forked from kevin-keraudren/volume_rendering.py
Volume rendering in Python using VTK-SimpleITK
#!/usr/bin/python
import SimpleITK as sitk
import vtk
import numpy as np
import sys
from vtk.util.vtkConstants import *
filename = sys.argv[1]
// An OLN namespace
namespace = {
foo: function(){ alert('namespace.foo'); },
bar: function(){ alert('namespace.bar'); },
};
// A namespace
(function(projecto){
projecto.flag = true;
projecto.foo = function()
@auxiliary
auxiliary / python_in_cpp.cpp
Created April 13, 2017 01:34
Sample code to call a python function in cpp
#include <python2.7/Python.h>
#include <iostream>
int main(int argc, char *argv[])
{
PyObject *pModule, *pModuleName, *pDict, *pFunc, *pValue, *pArgs;
Py_Initialize();
pModuleName = PyString_FromString("pie");
pModule = PyImport_Import(pModuleName);
@auxiliary
auxiliary / filter_spark_logs.sh
Created April 30, 2017 02:11
Redirections needed to run a spark job without the annoying INFO logs
((<file submit command> 1>&3) 2>&1 | awk '/Error/') 3>&1
@auxiliary
auxiliary / vim_layouts.vim
Created May 2, 2017 18:32
Automatic Vim Layouts
" Vim Layouts (pure Vim version)
argdelete *
bufdo argadd %:p
let args = split(expand("##"))
let counter = 0
for i in args
if counter % 4 == 0
if counter == 0
silent exe "edit" i
else
@auxiliary
auxiliary / git_change_commit_alias
Created August 28, 2017 14:05
Git change commit alias
[alias]
change-commits = "!f() { VAR1=$1; VAR='$'$1; OLD=$2; NEW=$3; echo \"Are you sure for replace $VAR $OLD => $NEW ?(Y/N)\";read OK;if [ \"$OK\" = 'Y' ] ; then shift 3; git filter-branch --env-filter \"if [ \\\"${VAR}\\\" = '$OLD' ]; then export $VAR1='$NEW';echo 'to $NEW'; fi\" $@; fi;}; f "
# Usage:
# git change-commits GIT_AUTHOR_EMAIL "OLD EMAIL" "NEW EMAIL"
# git push --force --tags origin 'refs/heads/*'
@auxiliary
auxiliary / spawn.cpp
Created September 6, 2017 23:25 — forked from konstantint/spawn.cpp
Example of communication with a subprocess via stdin/stdout
//
// Example of communication with a subprocess via stdin/stdout
// Author: Konstantin Tretyakov
// License: MIT
//
#include <ext/stdio_filebuf.h> // NB: Specific to libstdc++
#include <sys/wait.h>
#include <unistd.h>
#include <iostream>
@auxiliary
auxiliary / mdiff.sh
Created September 9, 2017 22:32
Better diff for comparing directories (compares file dates)
#!/bin/bash
# Better diff for directories
if [ "$#" -ne 2 ]; then
echo -e "Usage:\t./mdiff.sh <dir1> <dir2>";
exit -1;
fi;
dir1=$1
@auxiliary
auxiliary / debug.py
Last active December 9, 2017 04:23
Catch exceptions anywhere and open the bpython interpreter
import os
import sys
import traceback
import code
import bpython
def print_banner():
message = "Select a frame to view using the select(<frame #>) command"
print '\n\x1b[0;34;40m' + message + '\x1b[0m'
message = "Reload the script using the reload() command"
@auxiliary
auxiliary / IEEEtran.cls
Last active February 6, 2018 16:54
IEEEtran.cls with support for listing's belowcaptionskip
%%
%% IEEEtran.cls 2015/08/26 version V1.8b
%%
%% This is the IEEEtran LaTeX class for authors of the Institute of
%% Electrical and Electronics Engineers (IEEE) Transactions journals and
%% conferences.
%%
%% Support sites:
%% http://www.michaelshell.org/tex/ieeetran/
%% http://www.ctan.org/pkg/ieeetran