Skip to content

Instantly share code, notes, and snippets.

View agirault's full-sized avatar
👨‍💻

Alexis Girault agirault

👨‍💻
View GitHub Profile
@agirault
agirault / nslookupAlert.sh
Last active May 3, 2018 19:23
run as `./nslookupAlert.sh ${domain}` on macos to receive an alert when a domain DNS is resolved
#!/bin/bash
domain=$1
echo -ne "Looking up $domain DNS: "
while true; do
nslookup $domain | grep -q "find"
retVal=$?
if [ $retVal -ne 0 ]; then
ip=$( nslookup $domain | awk -F': ' 'NR==6 { print $2 } ')
@agirault
agirault / vegToVtu.cxx
Created January 19, 2018 20:48
vegToVtu
// in iMSTK
auto vegaMesh = MeshIO::read("/Users/agirault/Downloads/mandible.veg");
auto writeStatus = MeshIO::write(vegaMesh, "/Users/agirault/Downloads/mandible.vtu");
std::cout << writeStatus << std::endl;
//--------------------------------------------------------------------------
void qMRMLSubjectHierarchyTreeView::updateItemsSelectableFlag()
{
Q_D(qMRMLSubjectHierarchyTreeView);
if (!d->SubjectHierarchyNode)
{
return;
}
qMRMLSubjectHierarchyModel* sceneModel = qobject_cast<qMRMLSubjectHierarchyModel*>(this->model());
auto picker = vtkSmartPointer<vtkPropPicker>::New();
picker->Pick(screen_x, screen_y, 0, renderer);
// Check if pick is in bounds
vtkAssemblyPath* path = picker->GetPath();
bool validPick = false;
if (path) {
vtkCollectionSimpleIterator sit;
path->InitTraversal(sit);
vtkAssemblyNode *node;
@agirault
agirault / __git_status_flag.bash
Last active August 2, 2019 14:59
To put in your bash_rc
# git status with a dirty flag
function __git_status_flag {
git_status="$(git status 2> /dev/null)"
clean_pattern="working tree clean" # For macOS. For Linux: "working directory clean"
remote_pattern="Your branch is (.*)"
diverge_pattern="Your branch and (.*) have diverged"
if [[ ! ${git_status} =~ ${clean_pattern} ]]; then
state="⚡ "
fi
const char* objPath = ""; //orientation cube
const char* jpgPath = ""; //orientation texture
vtkRenderWindow* renderWindow = self.vtkView.renderWindow;
// Create & add the renderer
renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(0., 0., 0.);
renderer->SetViewport(0., 0., 1., 1.);
renderer->InteractiveOn();
renderWindow->AddRenderer(renderer);
@agirault
agirault / reslice_vtkDICOM.cpp
Last active August 31, 2017 20:36
Reslice vtkImageData from vtkDICOMReader using patient matrix
// Directory
const char *folderASCII = [folder cStringUsingEncoding:NSASCIIStringEncoding];
auto dicomDir = vtkSmartPointer<vtkDICOMDirectory>::New();
dicomDir->SetDirectoryName(folderASCII);
dicomDir->Update();
// Reader
auto reader = vtkSmartPointer<vtkDICOMReader>::New();
reader->SetFileNames(dicomDir->GetFileNamesForSeries(0));
//reader->SetMemoryRowOrderToFileNative();
@agirault
agirault / vtkOpenGLVertexBufferObject.cxx
Last active June 27, 2016 18:09
Create VBO to support multitextures. Write byte after byte
//-----------------------------------------------------------------------------
void vtkOpenGLVertexBufferObject::AddDataArray(vtkDataArray *data)
{
if (!this->VertexCount)
{
this->VertexCount = data->GetNumberOfTuples();
}
else if (VertexCount != data->GetNumberOfTuples())
{
vtkErrorMacro("AddDataArray() can not add array with a different number of "
#!/bin/bash
# Download MacOSX SDK and link them into XCode
# Make sure to update XCode beforehand (xcode-select --install)
mkdir SDKs
cd SDKs
git clone https://github.com/phracker/MacOSX-SDKs.git MacOSX.platform
cd ..
git clone https://gist.github.com/f213c737c0b2b581b13c.git
@agirault
agirault / add-sdks.py
Last active December 17, 2015 22:28
Links all your SDKs to XCode
#!/usr/bin/python
# add-sdks.py
# Rob Napier <[email protected]>
# Alexis girault <[email protected]>
# Script to link in all your old SDKs to Xcode
# Needs to be run every time you update Xcode
#
# 1. Create a directory and store the SDKs: