Skip to content

Instantly share code, notes, and snippets.

View anandology's full-sized avatar

Anand Chitipothu anandology

View GitHub Profile
@anandology
anandology / music.ipynb
Created July 11, 2023 14:01
Joy of Music
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anandology
anandology / query.py
Created March 6, 2023 04:13
Utility to query database in python
"""The database interface.
Please see schema.sql for the schema of the tables.
"""
from pathlib import Path
import sqlite3
import sys
from . import config
def query(q, parameters=[]):
@anandology
anandology / main.aum
Created February 1, 2023 06:56
Austral Modules example.
import Square (square);
module body Main is
function main(): ExitCode is
let n: Int32 := 5;
let n2:Int32 := square(n);
printLn(n2);
return ExitSuccess();
@anandology
anandology / bootstrap.py
Created January 5, 2023 06:50
bootstrap.py
from kutty import Page, Table, Code, html
from _demo import Demo
page = Page("Bootstrap")
page << html.p("""
bootstrap experiments.
""")
@anandology
anandology / reduction-game.py
Created November 1, 2022 17:01
The reduction game of @dabeaz
from functools import reduce
LEN = lambda items: reduce(lambda n, _: n + 1, items, 0)
REVERSE = lambda items: reduce(lambda rev, item: [item, *rev], items, [])
MAP = lambda func, items: reduce(lambda result, item: [*result, func(item)], items, [])
FILTER = lambda func, items: reduce(lambda result, item: [*result, item] if func(item) else result, items, [])
APPEND = lambda items, value: reduce(lambda result, item: [*result, item], [value], items)
@anandology
anandology / schema.sql
Created September 15, 2022 12:01
Database schema for Rajdhani Challenge
create table station (
code text primary key,
name text,
zone text,
state text,
address text,
latitude real,
longitude real
);
@anandology
anandology / origami.md
Created June 30, 2022 17:51
Origami: the programming language of paper

The resource for this talk will be updated here soon.

@anandology
anandology / email-count.py
Created April 10, 2015 17:44
Script to find the number of emails in the given gmail account
"""Script to count the emails received in a gmail account and posts it to a web hook.
"""
import imaplib
import optparse
import json
import urllib2
def count_emails(username, password, folder="INBOX"):
"""Returns the number of emails in specified folder.
"""
@anandology
anandology / api-v1.md
Last active June 9, 2021 10:30
API optioons for Joy

API - V1

Basic Types

Create a circle:

circle()
circle(r=50)
circle(cx=100, cy=100, r=50)
@anandology
anandology / test_email_queue.py
Created May 24, 2021 03:42
email test using py.test
def test_sendmail(monkeypatch):
emails = []
def mock_sendmail(self, from_addr, to_addrs, msg, mail_options=(), rcpt_options=()):
emails.append(dict(from_addr=from_addr, to_addrs=to_addrs, msg=msg))
monkeypatch.setattr(smtplib.SMTP, "sendmail", mock_sendmail)
frappe.sendmail(