Skip to content

Instantly share code, notes, and snippets.

View hassaananjum's full-sized avatar

Hassaan Anjum hassaananjum

  • Digital Energy
  • Dubai, UAE
View GitHub Profile
#include <string.h>
#include <bitset>
#include <iostream>
std::string hex_to_binary(std::string hexstring){
static char base16encoding_table[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
std::string binstring;
for( int i = 0; i < hexstring.length(); i++){
binstring += std::bitset<4>((int)(strchr(base16encoding_table,hexstring[i]) - base16encoding_table)).to_string();
}
@hassaananjum
hassaananjum / rf_arduino.c
Created February 13, 2017 13:04
RF Control Code Arduino
#include <RCSwitch.h>
#include <stdlib.h>
#include <stdio.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Setup");
pinMode(4, OUTPUT);
# Simple script to start/stop Amazon EC2 instances
import boto3
import sys
region = 'us-east-1'
instances = ['X-XXXXXXXX']
aws_id = "XXXXXXXXXXXXXXXXXXXX"
aws_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
def start_instance():
#simple script to upload image to s3 with a generic name
import boto3
import uuid
def uploadImage( img_name ):
file_name = str(uuid.uuid4())+'.png'
url = 'https://<bucket-name>.s3.amazonaws.com/'+file_name
s3 = boto3.client(
's3',
//basic usage bcrypt hashing
var bcrypt = require('bcrypt');
function createHash(password){
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash(password, salt, function (err, hash) {
if (err) {
console.log(err);
return err;
// bing static map generator
var http = require('http');
var fs = require('fs');
var Jimp = require('jimp');
var uuid = require('uuid');
var url = require('url');
http.createServer(function(req, res){
console.log(req.url);