Skip to content

Instantly share code, notes, and snippets.

View HQarroum's full-sized avatar
:octocat:

Halim Qarroum HQarroum

:octocat:
View GitHub Profile
@HQarroum
HQarroum / aws-iot-with-alpn.js
Last active May 4, 2020 15:05
Using the AWS IoT SDK with ALPN extensions to connect over MQTTS on port 443
const client = require('aws-iot-device-sdk');
// The options object to provision the MQTT client with.
// Update values between chevrons with the appropriate values.
const opts = {
host: "<aws-iot-endpoint>",
keyPath: "<path-to-private-key>",
certPath: "<path-to-device-certificate>",
caPath: "<path-to-root-ca>",
// We are specifying that we want to connect on the
### Keybase proof
I hereby claim:
* I am hqarroum on github.
* I am hqarroum (https://keybase.io/hqarroum) on keybase.
* I have a public key ASCwXPbkmeGc2VoIthKiwfRK_yciOT_dCayM_q2iBXv_Pwo
To claim this, I am signing this object:
@HQarroum
HQarroum / push_firehose_records.cpp
Last active October 14, 2018 00:45
Demonstrates how to publish records to a Kinesis Firehose stream from devices using the C++ AWS SDK.
#include <iostream>
#include <string>
#include <fstream>
#include <streambuf>
#include <chrono>
#include <thread>
#include <condition_variable>
#include <aws/core/Aws.h>
#include <aws/core/utils/Outcome.h>
@HQarroum
HQarroum / wifi-probe-monitoring-osx
Last active September 6, 2019 01:38
Enables the monitoring mode of your wireless adapter and dumps found Wi-Fi probe requests on OSX.
#!/bin/bash
# Stopping the script when a command's exit code signals a failure. \
set -e
set -o pipefail
# Variables. \
WLAN_INTERFACE='en0'
@HQarroum
HQarroum / iteration-with-pointer-arithmetics.c
Last active July 3, 2024 21:28
Pointer arithmetics - Iterating over an array
#include <unistd.h>
int main(void) {
const char array[] = "Hello world !";
const char* ptr = array;
while (*ptr) {
write(1, ptr++, 1);
}
return (0);
@HQarroum
HQarroum / pointer-arithmetics-challenge-structure.c
Last active August 3, 2021 00:30
pointer-arithmetics-challenge-structure
typedef struct {
float f;
int member;
char c;
} t_struct;
@HQarroum
HQarroum / pointer-arithmetics-challenge-prototype.c
Created August 3, 2021 00:31
pointer-arithmetics-challenge-prototype
t_struct* get_struct_ptr(void* member);
@HQarroum
HQarroum / offsetof-definition.h
Created August 3, 2021 00:34
offsetof-definition
#define offsetof(st, m) ((size_t)(&((st*)0)->m))
@HQarroum
HQarroum / pointer-arithmetics-challenge-offset-calculation.c
Created August 3, 2021 17:41
pointer-arithmetics-challenge-offset-calculation
size_t offset = offsetof(t_struct, member);
@HQarroum
HQarroum / pointer-arithmetics-challenge-using-offsetof.c
Last active July 3, 2024 21:27
pointer-arithmetics-challenge-using-offsetof
#include <stdio.h>
#include <stddef.h>
/**
* An example structure that holds members of different
* types and sizes that we will be using in our example.
*/
typedef struct {
float f;
int member;