Skip to content

Instantly share code, notes, and snippets.

View ialhashim's full-sized avatar

Ibraheem Alhashim ialhashim

View GitHub Profile
==============================
Expression: (id=\d)(.+?)(")
==============================
Python script to download:
import os.path
@ialhashim
ialhashim / screencapture.cpp
Last active February 5, 2026 21:04
Portable screen capture using C++ under Windows 10 (or 8)
#include "screengrab.h"
void capture()
{
CComPtr<ID3D11Device> pDevice;
CComPtr<IDXGIOutputDuplication> pDeskDupl;
//(...)create devices and duplication interface etc here..
DXGI_OUTDUPL_DESC OutputDuplDesc;
@ialhashim
ialhashim / fill_depth_colorization.py
Last active September 2, 2025 06:34
Python implementation of depth filling from NYU Depth v2 toolbox
# Original Matlab code https://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html
#
#
# Python port of depth filling code from NYU toolbox
# Speed needs to be improved
#
# Uses 'pypardiso' solver
#
import scipy
import skimage
@ialhashim
ialhashim / drawPointCloud.py
Last active September 2, 2025 06:34
Quick python script to draw a dynamic point cloud with changing colors and positions (e.g. RGBD frames)
from OpenGL import GL, GLU
from OpenGL.arrays import vbo
# Prepare point cloud once
def makeCloud(self):
width, height = self.rgb.shape[1], self.rgb.shape[0]
# ...
# Compute 3D positions from depth
# ...
@ialhashim
ialhashim / pt.sh
Created June 29, 2025 10:40
standard pytorch
conda create -n pt python=3.11 -y && conda activate pt && pip install tqdm codetiming glances[all] torch torchvision pillow
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba && mkdir -p ~/micromamba && mv bin/micromamba ~/micromamba/ && ~/micromamba/micromamba shell init -s bash -y && echo "alias conda='micromamba'" >> ~/.bashrc && source ~/.bashrc
@ialhashim
ialhashim / readme.md
Last active April 2, 2024 11:17
Reverse port forwarding via an AWS instance

If you want to connect to a local workstation behind a firewall you can do that by bouncing traffic off of an AWS instance.

An example would be accessing a Jupyter Lab from the outside world to a machine with no static IP or behind a firewall.

The steps are:

  1. Create a paid AWS Ubuntu instance and save the '.pem' file.
  2. Make sure the AWS instance's Security Rules allows traffic in.
  3. Test that you can connect to this instance from the outside world (e.g. python3 -m http.server or jupyter lab --ip=*) then visit the instance using its public IP.
  4. (optionally) Enable password login in /etc/ssh/sshd_config by setting PasswordAuthentication yes and sudo passwd $USER.
  5. Enable GatewayPorts yes and restart sshd. E.g. sudo nano /etc/ssh/sshd_config then sudo systemctl restart ssh.service.
@ialhashim
ialhashim / fitting3D.cpp
Created November 14, 2014 23:17
Fitting 3D points to a plane or a line
template<class Vector3>
std::pair<Vector3, Vector3> best_plane_from_points(const std::vector<Vector3> & c)
{
// copy coordinates to matrix in Eigen format
size_t num_atoms = c.size();
Eigen::Matrix< Vector3::Scalar, Eigen::Dynamic, Eigen::Dynamic > coord(3, num_atoms);
for (size_t i = 0; i < num_atoms; ++i) coord.col(i) = c[i];
// calculate centroid
Vector3 centroid(coord.row(0).mean(), coord.row(1).mean(), coord.row(2).mean());
@ialhashim
ialhashim / DBSCAN.hpp
Last active March 24, 2024 22:04
Portable Clustering Algorithms in C++ (DBSCAN) and (Mean-Shift) and (k-medoids)
#pragma once
// Code adapted from https://github.com/propanoid/DBSCAN
#include <vector>
#include <algorithm>
#include <omp.h>
// Any basic vector/matrix library should also work
#include <Eigen/Core>
@ialhashim
ialhashim / firebase_storage_web.dart
Created January 8, 2020 09:48
Flutter + Firebase storage on the web, work around
// Note this is just a workaround until the offical support of web
// We would need to add these as well
//// ignore_for_file: avoid_web_libraries_in_flutter
//import 'dart:html';
//import 'package:mime/mime.dart';
//import 'package:firebase/firebase.dart' as fb;
// Some upload button is pressed
onPressed: () async {