Skip to content

Instantly share code, notes, and snippets.


Ibraheem Alhashim ialhashim

View GitHub Profile
ialhashim /
Last active Jan 11, 2021
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. Enable GatewayPorts yes as mentioned here and restart sshd as mentioned.
  5. On the local workstation (e.g. GPU workstation) run the following command: ssh -i "YOUR_PEM_FILE.pem" -R AWS_PUBLIC_IP:2222:localhost:8888 ubuntu@AWS_PUBLIC_IP
ialhashim / azure_kinect_capture.cpp
Last active Aug 26, 2020
Azure Kinect basic capturing and visualization on Windows
View azure_kinect_capture.cpp
The most basic example to capture matching RGB and Depth images from an Azure Kinect DK device.
CImg is used to visualize the matching RGB and Depth.
#pragma comment(lib, "gdi32.lib")
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "shell32.lib")
ialhashim / firebase_storage_web.dart
Created Jan 8, 2020
Flutter + Firebase storage on the web, work around
View firebase_storage_web.dart
// 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 {
ialhashim /
Last active Oct 19, 2020
Resize or interpolate tensors to any spatial dimension in Keras
import tensorflow as tf
import keras.backend as K
from keras.layers import Lambda
# Keras + TensorFlow
# Resize 'tensorA' to be of the same size as 'tensorB' using 'tf.image.resize_bilinear'
# Very useful for skip-connections and 'Concatenate' layers that might complain about being off by one column
# Only works when dimensions are provided since we use ' K.int_shape' that returns the static shape
ialhashim /
Last active Mar 3, 2020
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
# ...
from joblib import Parallel, delayed
import numpy as np
from skimage.transform import resize
files = list(data.keys())[1:]
def coords(filename):
filename = filename.replace('11_1024/', '').replace('.jpg', '').replace('11_', '')
filename = filename.replace('[','').replace(']','').split('_')
ialhashim /
Last active Mar 2, 2021
Python implementation of depth filling from NYU Depth v2 toolbox
# Original Matlab code
# Python port of depth filling code from NYU toolbox
# Speed needs to be improved
# Uses 'pypardiso' solver
import scipy
import skimage
ialhashim / screencapture.cpp
Last active Dec 7, 2020
Portable screen capture using C++ under Windows 10 (or 8)
View screencapture.cpp
#include "screengrab.h"
void capture()
CComPtr<ID3D11Device> pDevice;
CComPtr<IDXGIOutputDuplication> pDeskDupl;
//(...)create devices and duplication interface etc here..
ialhashim /
Created May 24, 2018
Download the Earth from World Imagery (Esri)
import subprocess
import pathlib
# Source
map_server = ''
# Output directory
outdir = 'images/'
pathlib.Path(outdir).mkdir(parents=True, exist_ok=True)
ialhashim / woocomerece_wpml.php
Created Dec 28, 2016
WooCommerce Multilingual Create Products
View woocomerece_wpml.php
// Product in default language
global $sitepress;
// Add the product (a post of type 'product')
$post_id = wp_insert_post($post_data);
// Attach media to it
set_post_thumbnail( $post_id, get_post_id_by_title( $code, 'attachment' ) );