Skip to content

Instantly share code, notes, and snippets.

View randhawp's full-sized avatar

randhawp

  • Toronto, Canada
View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@randhawp
randhawp / cognito-developer-authenticated-client-example.py
Created September 8, 2017 01:59 — forked from dkarchmer/cognito-developer-authenticated-client-example.py
django-boto3-cognito: AWS' Cognito Developer Authenticated Identities Authflow using Django/Python/Boto3 (For building stand-alone clients)
__author__ = 'dkarchmer'
'''
This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but
requires your Django server to have an API for your user to access Cognito based credentials
Because of Cognito, the client (this script) will only get temporary AWS credentials associated
to your user and only your user, and based on whatever you configure your AIM Policy to be.
Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate
how to create a stand-alone Python script but operating similarly to these apps.
@randhawp
randhawp / gstreamer.md
Created August 16, 2019 20:28 — forked from nebgnahz/gstreamer.md
Collections of GStreamer usages

Most GStreamer examples found online are either for Linux or for gstreamer 0.10.

This particular release note seems to have covered important changes, such as:

  • ffmpegcolorspace => videoconvert
  • ffmpeg => libav

Applying -v will print out useful information. And most importantly the negotiation results.

// async example
#include <iostream> // std::cout
#include <future> // std::async, std::future
// a non-optimized way of checking for prime numbers:
class X{
public:
X(){};
~X(){};
@randhawp
randhawp / CompressYUYV2JPEG.cpp
Created November 27, 2019 19:44 — forked from royshil/CompressYUYV2JPEG.cpp
Example of converting a YUYV buffer to JPEG using libJPEG
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdint>
#include <memory>
#include <jpeglib.h>
using namespace std;
@randhawp
randhawp / i2c.c
Created December 12, 2019 19:21 — forked from JamesDunne/i2c.c
C library for reading/writing I2C slave device registers from Raspberry Pi 1 Model B
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
// Terrible portability hack between arm-linux-gnueabihf-gcc on Mac OS X and native gcc on raspbian.
#ifndef I2C_M_RD
#include <linux/i2c.h>
#endif
cat /proc/meminfo | grep MemFree | tr -s ' ' | cut -d' ' -f2
or
free -m | head -2 | tail -1 | tr -s ' ' | cut -d' ' -f4
------------------------------------------------------------------------
#include <iostream>
int check_free_ram(){
FILE *fp;
int status;
char result[24];
@randhawp
randhawp / all-angular-material-components-imports.txt
Created September 30, 2021 20:38 — forked from pimatco/all-angular-material-components-imports.txt
All Angular Material Components Imports from app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
//Angular Material Components
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MatCheckboxModule} from '@angular/material';
import {MatButtonModule} from '@angular/material';