Skip to content

Instantly share code, notes, and snippets.

View emadehsan's full-sized avatar
🤸‍♂️
Overthinking about overthinking

Emad Ehsan emadehsan

🤸‍♂️
Overthinking about overthinking
View GitHub Profile
@emadehsan
emadehsan / Why-Java-First.md
Last active April 30, 2017 17:48
Advantages of Learning Java as First Programming Language

Why Learn Java as First Programming Language

Here I've tried to make my case on why should you start your Software Engineering Journey with Java. Java

Java is All Rounder

Java is Mobile

You can develop anything for Android the most widely used Operating System.

Java is Web

Start with:
Create a file `index.html` and paste the following code
```
<!doctype html>
<html>
<head>
<title>Chat Room</title>
</head>
# this is a comment
s = 'Quick brown fox jumps over lazy white dog'
scount = 0
for c in s :
if c == 'a' or c == 'o' or c == 'u' or c == 'i' or c == 'e':
# "count" in the following line is being used for the first time. It is one level deep i.e. inside the loop. So its value will not be available outside the loop.
# count += 1
@emadehsan
emadehsan / HowTo.md
Created October 4, 2018 06:41
Video.js Quality Selection with DASH (+HLS)

Radek has provided good example code that we would use.

  1. Include these libraries in the <head>
<!-- VideoJs CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.2.4/alt/video-js-cdn.min.css" />

<!-- Necessary libs. Video.js 7, Contrib Quality Levels, Jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.2.4/video.min.js"></script>
@emadehsan
emadehsan / Test.md
Last active August 14, 2019 13:02
Automatically set cookie in Postman

In the Tests tab of your request, type this code

let cookie = postman.getResponseHeader("Set-Cookie");
postman.setEnvironmentVariable("cookie", cookie);

This will set an environment vairable. In all the requests that need cookie, add to the Request Header

Key: Cookie

async function takePhoto(quality) {
// create html elements
const div = document.createElement('div');
const video = document.createElement('video');
video.style.display = 'block';
// request the stream. This will ask for Permission to access
// a connected Camera/Webcam
const stream = await navigator.mediaDevices.getUserMedia({video: true});
# Create model object in inference mode.
model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config)
# Load weights trained on MS-COCO
model.load_weights(COCO_MODEL_PATH, by_name=True)
# Load a random image from the images folder
file_names = next(os.walk(IMAGE_DIR))[2]
image = skimage.io.imread(os.path.join(IMAGE_DIR, random.choice(file_names)))
# Run detection
results = model.detect([image], verbose=1)
# Visualize results
r = results[0]
visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'],
Processing 1 images
image shape: (425, 640, 3) min: 0.00000 max: 255.00000 uint8
molded_images shape: (1, 1024, 1024, 3) min: -123.70000 max: 151.10000 float64
image_metas shape: (1, 93) min: 0.00000 max: 1024.00000 float64
anchors shape: (1, 261888, 4) min: -0.35390 max: 1.29134 float32
async function takePhoto(quality) {
// create html elements
const div = document.createElement('div');
const video = document.createElement('video');
video.style.display = 'block';
// request the stream. This will ask for Permission to access
// a connected Camera/Webcam
const stream = await navigator.mediaDevices.getUserMedia({video: true});