Posted on 7 mins read

Schedule

  • The Magic Behind Engineers.SG — Michael Cheng
  • An Unexpected Use for a Cardboard Box: Listening to the Moon — Roland Turner
  • Evolving Careers: How I Switched My Role from an Admin to a Javascript Developer — Leticia Choo
  • Create a 3D Game Engine for Pebble Smartwatch — Shipeng Xu
  • Rust: Make System Programming Great Again! — Omer Iqbal
  • I left.

The Magic Behind Engineers.SG

Sharing about the magic behind the scenes. @coderkungfu

With Singapore Power now. link

Motivation: Marketing problem for engineers in Singapore.

Goal: Tell more about Engineers in Singapore via Videos

Streamline Capture Workflow

  • Capture all inputs (video, screen, audio)
  • Feed sources into a laptop via USB
  • Post production
Presenter laptop -> Video splitter -> Video input

Video splitter -> screen capture tool, webcam, condenser(microphone)

Important to hear what speaker is saying clearly. So process audio! Shell script for processing audio: ffmpeg, SoX.

Humans

Pre-meetup Procedures.

  • Get permissions from organizers and presenters.
  • Volunteers sign up for time slot.
  • Logistics.
  • Setup time.

Organizers don’t really have a pool of volunteers they can rely on. So it was better to setup a pool of volunteers to go around. (40+ now)

OBS: Open Broadcaster Software! Yes!

Considerations

He wanted to avoid having the presenter download software just to be able to do a screencapture. Tried to build a workflow with QuickTime (MAC).

Backup system. Why? Because it is running windows. Backup video and audio to reconstruct stuff. Slides and audio is most important.

Luggage for transporting gear. Lots of stuff and its heavy. Better to have something sturdy to transport stuff over difficult terrain. Go to mustafa!

Thoughts

Seems like a mash of hardware and software is needed to get things working. He started with something then improved it over time.

An Unexpected Use for a Cardboard Box: Listening to the Moon

Satellites.

Satellite Orbits

Polar LEO - where most ameteur satellies are. LEO: Low earth orbit

Objective

Bounce satellite signals off the moon.

Stuff

Listen to Jupiter. Source of HF radio emissions in the solar system.

You get a “nice” cup if you manage to establish 2 way communication with Mars.

Intermediate steps

Going from lower orbits to higher orbits.

  • LEO
  • GSO/Molniya
  • ?
  • EME

Special satellite dish to look for reconnaisse satellite orbitting the moon. Looks at 100th of all the sounds coming from the sky. eg. Gate3way

AA2TX: Close to spec of commercial dishes

  • 60cm cardboard box.
  • 2400MHZ
  • 20dBi
  • S-Band LNB/DC
  • Any coax
  • Amateur transceiver

Interesting stuff

Helical structure of antenna. Polarisation. Circular magnetic field. Better as you don’t know the orientation of the satellite.

Linear structure means you got to sync them. Must point right.

Signal recevied is a billionth of a watt. Cardboard box and LNA amplifiy it. Coax loses about 30% of it.

Noise is a problem. Entire sky is emitted radiation at a very low level. It matters in this case. Moon is freezing (here assumed to be -25C).

Evolving Careers: How I Switched My Role from an Admin to a Javascript Developer

BillHsu.github.io

Drawings. Life story. Bad dev practices. Learning journey.

Create a 3D Game Engine for Pebble Smartwatch

Todo:

  • Generic way of rendering 3d images for Pebble
  • Flexible
  • High frame rate

Breakdown the problem.

A smaller problem. Demonstrate concept of being able to create a game. Display 3D model on the watch.

First. Look at hardware specs. 64 epaper. 144x168. ST Micro STM32F439ZG 180MHz ARM (100MHz limit. Battery.) Bluetooth Module. Has a Lattice LP1K FPGA.

Watch side APIs: C, JavaScript (JerryScript, Samsung, IoT)

Phone side: JS, iOS, Android

2 ways:

Phone side rendering. Render on phone then send to watch. But bluetooth is slow.

Watch side rendering. Send the 3D vertices to watch. Rendering done on watch side. But CPU not very powerful.

Each pixel will be 1 byte(8bits) 144x168 = ~24 kilobytes for each image

Bluetooth 2.1 max rate is 3Mbps. ~360KB/s (kilobytes). So maybe 10FPS? But you can’t use all the bytes. Some checksum… etc.

Pebble max buffer size is 8KB? But he tested only could sent ~1.8KB.

Pebblekit JS

Create own WebGL as it is not supported.

Looking at a 3d bunny made of triangles. Just add more triangles to make it more realistic.

3D renderer you just need 1 function to draw a triangle then you can do anything you want. Every 3d triangle is mapped to a 2d triangle so after all we need a function to draw a 2d triangle. Process is called rasterization.

Previous talk “A 3D renderer in JavaScript”.

Sending buffer over took 8000ms while rendering took 250ms. Reducing image resolution… 400ms to send 250ms to render. So 2 FPS.

Rust: Make System Programming Great Again!

How many of you have touched systems programming since university? Well… It sucks.

Heartbleed

Buffer overflow. Missing bound check. if length < X. Shellshock. Goto fail gotofail.

c, c++ used to implement these libraries give you too much freedom.

We are concerned about memory safety.

  • Buffer overflows -> corrupt adjacents.
  • Buffer over-reads -> reveal sensitive data.
  • Dangling Pointers -> address of a deleted object
  • Double free -> Corrupt the heap

Garbage collection

Generational mark & sweep. JVM style. Non-deterministic destruction. Resource like video but you want to destroy a particular file. You don’t know when itll be destroyed. Needs a lot more memory to be efficient. (3-4 times of actual application) Sweep pass touches almost all RAM leading to power inefficiency. (Android!) GC pauses not acceptable for hard realtime systems (Airplanes!)

Enter Rust

fn main() {
    println!("Hello world! Easier than C! We win!");
}

! mark to distinguish macro from normal method/function calls.

Systems programming lang:

  • Safety
  • Speed
  • Concurrency

Immutability by default

let x = 9;
x = 10;
//fails

let mut y = 10;
y = 5;

Strongly typed w inference

let x: i32 = 42;
let y = 42;

Vectors. Resizable array. Store content on heap. Macros: Like C preprocessors.

let v = vec![1,2,3,4,5] // v: Vec<i32>

Rust philosopy

Zero cost abstractions Zero performance cost.

Rust memory model

Ownership

You own something. So you take care of it.

fn foo() {
    // variables own the resource.
    let v = vec![1, 2, 3];
}

Once binding goes out of scope, Rust will free the bound resources. Default behaviour.

There is only ONE binding to a given resource

let v = vec![1, 2, 3];
let v2 = v;
println!("v[0] is: {}", v[0]);

//error: use of moved value: v
//multiple bindings.

Ownership: move semantics

fn take(v: Vec<i32>) {

}
let v = vec![1 ,2, 3];
take(v);

//compile error. wtf?
let trumpVotes = vec![1, 2, 3];
let mut fakeMore = trumpVotes;
fakeMore.push(4);
// does not compile because your stack has different sizes (trumpVotes, fakeMore) for same heap address.

Primitives implement Copy

let v = 1;
let v2 = v;
println!("v is :{}", v);

Inefficient. So not used in production.

How to pass to function

let v1 = ...
let v2 = ...

let (v1, v2, ans) = foo(v1, v2)

Borrowing

fn foo(v1: &Vec<i32>, v2: &Vec<i32>) -> ...

let answer = foo(&v1, &v2);
fn foo(v: &Vec<i32>) {
    v.push(5)
}

You can’t mutate stuff easily.

fn main() {
    let mut x = 5;
    let y = &mut x;
    *y += 1;
    println!("x is :{}", x);
    // fails.
    // data race. println! creates an immutable reference.
    // y is mutable.
}
  • access content of the reference.

Borrowing Rules

  • Any borrow must last for a scope not greater than owner (Refence must not live longer than res they refer to)
  • You can only have 1 mutable reference at any time

‘data race’. 2 or more pointer accessing 1 memory location at the same time where at least 1 of them is writing and operations are not synchronized.

Immutability is a property of the binding not the data.

Static vs Dynamic Dispatch

Static

Dont need to manually calc address of function. Matters because of optimizations you can do like inlining.

add 3 5

Dynamic

Address of function has to be evaluated at compile time.

By default last expression will return.

Stuff

u8 is bytes.

monomorphization for static dispatch. Can bloat codesize.

Thoughts

Rust makes you fail a lot… with good intentions?