Skip to content

Instantly share code, notes, and snippets.

View abdul-rehman-2050's full-sized avatar
🎯
Focusing

Abdul Rehman abdul-rehman-2050

🎯
Focusing
View GitHub Profile
@abdul-rehman-2050
abdul-rehman-2050 / QuoteDBHelper.kt
Created August 13, 2018 16:07
SQLite anko example
package com.quote.my.mark.mmq.database
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import org.jetbrains.anko.db.*
class QuoteDBHelper(ctx: Context) : ManagedSQLiteOpenHelper(ctx, "MMQDatabase", null, 1) {
companion object {
private var instance: QuoteDBHelper? = null
@abdul-rehman-2050
abdul-rehman-2050 / eeprom_int_readWrite.c
Created May 1, 2018 09:36
16 bit integer read and write to eeprom
//===========================================================================================
//This function will write a 2 byte integer to the eeprom at the specified address and address + 1
void EEPROMWriteInt(int p_address, int p_value)
{
byte lowByte = ((p_value >> 0) & 0xFF);
byte highByte = ((p_value >> 8) & 0xFF);
EEPROM.write(p_address, lowByte);
EEPROM.write(p_address + 1, highByte);
}
@abdul-rehman-2050
abdul-rehman-2050 / Arduino_SevenSement_3digit_Counter.ino
Last active April 30, 2018 12:48
This is small Arduino code to drive non blocking TDM for Seven Segment multipexing
//==========================================================================================
#define NUM_OF_DIGITS 3
#define NUM_OF_SEGMENTS 7
//--------------------------
long preMicros=0,preMillis=0;
unsigned char digitBuffer[NUM_OF_DIGITS]={0};
import speech_recognition as sr
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
# recognize speech using Sphinx
try:
@abdul-rehman-2050
abdul-rehman-2050 / UART_8051.hex
Created March 14, 2018 14:47
Controlling LEDs or devices via UART in 8051 architecture using Assembly Language
:10000000758920758DFD759852D28EC2A2C2A0C28C
:10001000A17448114674451146744C1146744C1134
:100020004674301146740D1146740A1146114E1172
:1000300046B45204B2A080F5B45904B2A180EEB423
:1000400047EBB2A280E73099FDC299F5992230982A
:06005000FDC298E59922B3
:00000001FF
@abdul-rehman-2050
abdul-rehman-2050 / LiveFaceDetector.py
Created March 7, 2018 22:04
Face detector using Opencv Python version 2.4 and frontal face cascade features
import cv2
import sys
video_capture = cv2.VideoCapture(0)
#video_capture.set(3,320)
#video_capture.set(4,240)
face_cascade = cv2.CascadeClassifier('haar_frontalface_alt2.xml')
import RPi.GPIO as GPIO
import time
#=========== GPIO ALIASES [BCM MODE] ====================
LED1 = 19 #BCM MODE
LED2 = 26
import RPi.GPIO as GPIO
import time
#global veriables
LED_Pin = 16
delay = 0.5
#setup your pins and GPIO mode
GPIO.setmode(GPIO.BOARD)
binary = reshape(dec2bin(s, 8).'-'0',1,[])
str = char(bin2dec(reshape(char(binary+'0'), 8,[]).'))
@abdul-rehman-2050
abdul-rehman-2050 / Raspberry Pi Ultrasonic HC-SR04
Created January 12, 2018 16:56 — forked from shahrulnizam/Raspberry Pi Ultrasonic HC-SR04
Raspberry Pi Lesson: Ultrasonic HC-SR04
import RPi.GPIO as GPIO
import time
TRIG = 24
ECHO = 23
GPIO.setmode(GPIO.BCM)
GPIO.setup(TRIG,GPIO.OUT)
GPIO.setup(ECHO,GPIO.IN)