Skip to content

Instantly share code, notes, and snippets.

import pygame
from typing import Callable, Optional
class Terminal:
_lines: list[str]
_commands: dict[str, Callable[[str], Optional[str]]]
def __init__(self, width: int, height: int) -> None:
self._row = 0
@sudesh955
sudesh955 / connect_android
Created February 22, 2024 16:12
connect_android
#!/usr/bin/env zx
async function main() {
const output = await $`avahi-browse -trpk _adb-tls-connect._tcp`;
const lines = output.toString().split('\n').map(item => item.trim()).filter(Boolean);
for (const line of lines) {
const parts = line.split(';');
const ip = parts[7];
const port = parts[8];
if (!ip || !port) {

Assignment

Create an single page application like MS paint.

features

  • Users can not access any page without login.
  • Users can login with username and password.
  • There is no need to create sign-up, we will add users in database.
@sudesh955
sudesh955 / tree.js
Last active June 13, 2019 12:44
AVL
/**
* @flow
*/
type Node<V> = {|
left: ?Node<V>,
right: ?Node<V>,
parent: ?Node<V>,
height: number,
value: V,
@sudesh955
sudesh955 / websocket.js
Last active April 19, 2025 22:25
Server side WebSocket
'use strict';
const crypto = require('crypto')
, EventEmitter = require('events')
const badRequest = 'HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-Length: 0'
, goodResponse = 'HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade' +
'\r\nSec-WebSocket-Accept: '
, magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
, two32 = Math.pow(2, 32)
#!/usr/bin/python
""" Downloads Background Images of 'bing.com' """
import urllib
import cjson as json
import os
url = 'http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=8&mkt=en-IN'
def get_name(s):
s = os.path.basename(s)