Skip to content

Instantly share code, notes, and snippets.

View schedutron's full-sized avatar
🎯
Focusing

Saurabh Chaturvedi schedutron

🎯
Focusing
View GitHub Profile
@schedutron
schedutron / command_sender.py
Last active October 25, 2020 11:34
Flask server to receive commands via /switch endpoint and send them via USB to CircuitPlayground Express
import serial
from flask import Flask, Response
# /dev/ttyACM0 is the USB interface to CPX on my Pi. It might be different for you,
# there are many resources on the web to help you find the correct interface.
SERIAL_PATH = '/dev/ttyACM0'
BAUDRATE = 115200
TIMEOUT = 0.01
SER = serial.Serial(SERIAL_PATH, baudrate=BAUDRATE, timeout=TIMEOUT)
@schedutron
schedutron / code.py
Created October 25, 2020 11:21
CircuitPlayground Express Code for Sending Power-on Signal to a class of Fujitsu General ACs
import array
import supervisor
import sys
import time
import pulseio
import board
from adafruit_circuitplayground import cp
# -*- coding: utf-8 -*-
"""WhatsApp.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1jyDKgWPj7_nwyhRKyvjpeGojLRU0VqqF
"""
!pip install wordcloud
@schedutron
schedutron / DisjointSetMazeGenerator.md
Last active May 3, 2021 10:14
Python3 Maze Generator with Disjoint Set

Generate Mazes with Disjoint Sets!

This script generates mazes that satisfy the following properties:

  • There are no cycles in the maze
  • Maze is always solvable
  • Every cell is reachable from every other cell

The script also animates the maze-building process on the command-line (this was actually trickier than the maze generating algorithm itself)!

Usage

@schedutron
schedutron / gsoc_2018_schedutron_work_product.md
Last active November 9, 2018 03:39
GSoC 2018 Work Product | Saurabh Chaturvedi | Open Event Server, Frontend | FOSSASIA

GSoC 2018

Saurabh Chaturvedi | FOSSASIA

Overview:

Throughout the course of this summer, I worked on FOSSASIA's Open Event project for GSoC.

Open Event Server

Majority of my work was done on the server side, i.e, on Open Event Server. The Open Event API Server enables organizers to manage events ranging from concerts to conferences, meet-ups, lecture series and much more. It offers features for events with several tracks and venues. Features also include subtle options like access and discount codes, session tracks, microlocations and so on.

@schedutron
schedutron / chat_clnt.py
Created November 22, 2017 17:55
GUI client script for my chat app
#!/usr/bin/env python3
"""Script for Tkinter GUI chat client."""
from socket import AF_INET, socket, SOCK_STREAM
from threading import Thread
import tkinter
def receive():
"""Handles receiving of messages."""
while True:
@schedutron
schedutron / chat_serv.py
Created November 22, 2017 13:35
Chat Server Script
#!/usr/bin/env python3
"""Server for multithreaded (asynchronous) chat application."""
from socket import AF_INET, socket, SOCK_STREAM
from threading import Thread
def accept_incoming_connections():
"""Sets up handling for incoming clients."""
while True:
client, client_address = SERVER.accept()
@schedutron
schedutron / barrier_tut.py
Last active August 13, 2017 03:12
A demo script for threading.Barrier synchronization primitive
from random import randrange
from threading import Barrier, Thread
from time import ctime, sleep
num = 4
b = Barrier(num) # 4 threads will need to pass this barrier to get released.
names = [“Harsh”, “Lokesh”, “George”, “Iqbal”]
def player():
name = names.pop()
@schedutron
schedutron / condition_tut.py
Last active August 13, 2017 03:13
A demo script for threading.Condition synchromization primitive.
import random, time
from threading import Condition, Thread
# This will be used to represent the availability of a produced item.
condition = Condition()
box = []
def producer(box, nitems):
for i in range(nitems):
time.sleep(random.randrange(2, 5)) # Sleeps for some time.
@schedutron
schedutron / event_tut.py
Last active August 13, 2017 03:13
A demo script for threading.Event synchronization primitive
import random, time
from threading import Event, Thread
event = Event()
def waiter(event, nloops):
for i in range(nloops):
print(“%s. Waiting for the flag to be set.” % (i+1))
event.wait() # Blocks until the flag becomes true.
print(“Wait complete at:”, time.ctime())