Skip to content

Instantly share code, notes, and snippets.

Avatar

Inderpreet Singh inderpreet

View GitHub Profile
View setup1.sh
#!/bin/bash
# @Brief Script to install mysql and python with apache2 and sample codes
# @author Inderpreet Singh(inderpreet.v1@gmail.com)
chek_sudo(){
if [ "$EUID" -ne 0 ]; then
echo "Please run with sudo"
exit
fi
@inderpreet
inderpreet / Drawer-menu.js
Created May 3, 2021 — forked from alexanmtz/Drawer-menu.js
A tab menu example using Material-UI for react
View Drawer-menu.js
// styles
const styles = theme => ({
iconContainer: {
display: 'none',
[theme.breakpoints.down('sm')]: {
display: 'block'
}
}
})
@inderpreet
inderpreet / mqtt.py
Created Mar 16, 2021 — forked from stylpen/mqtt.py
python MQTT wrapper
View mqtt.py
import thread, mosquitto, random, time
# mosquitto reference and download can be found here: http://mosquitto.org/documentation/python/
class mqtt():
def __init__(self, broker = "127.0.0.1", port = 1883, clientID = None):
self.__broker = broker
self.__port = port
self._client = None
self.__subscriptionsList = []
self.__pendingSubscriptionsList = []
View student_database_with_python.py
#!/usr/bin/python3
# Import statements for libraries
import time
import MySQLdb
# Variable placeholders
Done = False
@inderpreet
inderpreet / keysight_psu_01.py
Created Apr 28, 2019
A script to display text on the Keysight PSU
View keysight_psu_01.py
#!/usr/bin/env python
import visa
rm = visa.ResourceManager()
rm.list_resources()
inst = rm.open_resource('TCPIP0::192.168.5.185::5025::SOCKET')
# print(inst.query("*IDN?"))
View bbc_microbit_remote.py
"""
@file bbc_tx
@brief BBC microbit Receiver By Inderpreet Singh
"""
import radio
import random
from microbit import * #import display, Image, button_a, sleep, button_b,
music = False
lights = False
@inderpreet
inderpreet / bbc_microbit.py
Created Apr 28, 2019
Contains Code to allow BLE control over GPIOs
View bbc_microbit.py
"""
@file bbc_recieve
@brief BBC microbit Receiver By Inderpreet Singh
"""
import radio
import random
from microbit import display, Image, button_a, sleep
radio.on()
View index.js
var noble = require('noble');
var scanningTimeout = 2000; // one second
var scanningRepeat = scanningTimeout + 8000; // Repeat scanning after 10 seconds for new peripherals.
noble.on('stateChange', function(state) {
if (state === 'poweredOn') {
//
// Once the BLE radio has been powered on, it is possible
// to begin scanning for services. Pass an empty array to
// scan for all services (uses more time and power).
View test.js
var noble = require('noble');
var ble_UUID =['171a3182907143bfb53a1689b132a533', '9d0bfe96c7bb46c59b35d9abc398c587']; // add your UUIDs to this list...
var ble_serices = 'ffb0';
var red_char = 'ffb1';
var green_char = 'ffb2';
var blue_char = 'ffb3';
var white_char = 'ffb4';
var R=0;
@inderpreet
inderpreet / statemachine.c
Created Mar 13, 2017 — forked from nmandery/statemachine.c
State machines are very simple in C if you use function pointers.
View statemachine.c
/*
http://stackoverflow.com/questions/1371460/state-machines-tutorials/1371654#1371654
State machines are very simple in C if you use function pointers.
Basically you need 2 arrays - one for state function pointers and one for state
transition rules. Every state function returns the code, you lookup state
transition table by state and return code to find the next state and then
just execute it.
*/