This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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/*' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((<file submit command> 1>&3) 2>&1 | awk '/Error/') 3>&1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An OLN namespace | |
namespace = { | |
foo: function(){ alert('namespace.foo'); }, | |
bar: function(){ alert('namespace.bar'); }, | |
}; | |
// A namespace | |
(function(projecto){ | |
projecto.flag = true; | |
projecto.foo = function() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import SimpleITK as sitk | |
import vtk | |
import numpy as np | |
import sys | |
from vtk.util.vtkConstants import * | |
filename = sys.argv[1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import numpy as np | |
def getDegree(ref_id, grid_list): | |
results = np.zeros(grid_list[0].shape) | |
for i, grid in enumerate(grid_list): | |
results += (grid_list[ref_id] == grid) | |
return results / float(len(grid_list)) * 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import numpy as np | |
import sys | |
sys.path.append('/home/mohammad/Downloads/visit2_10_0.linux-x86_64/2.10.0/linux-x86_64/lib/site-packages') | |
import vtk | |
from vtk.util.vtkConstants import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In case you need byte arrays | |
import numpy as np | |
a = np.uint64(7640891576956014592) #64 bits | |
b = a.tostring() # '\x00\xd0\xbc\xf3g\xe6\tj' in bytes | |
b = bytearray(b) # bytearray(b'\x00\xd0\xbc\xf3g\xe6\tj') Byte array object | |
# Padding | |
a = [1, 1, 1, 1, 1] | |
a + [0] * (16 - len(a)) # [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |