├── .github └── workflows │ └── blank.yml ├── .gitignore ├── Herbrand Semantics.pdf ├── README.md ├── SPIM_Manual.pdf ├── abstract-algebra ├── 0.tex ├── abstract-algebra.tex ├── examples.tex └── makefile ├── analysis1 ├── 2.md ├── 3.md ├── 4.md ├── 5.md ├── 6.md └── 7.md ├── apl.md ├── apue ├── 1 ├── 3 ├── 4 ├── 5 ├── 6 ├── 7 ├── 8 ├── 9 ├── 10 └── 11 ├── asm └── asm.md ├── bavsi.md ├── bin └── cf448d.png ├── blackhill.md ├── category-theory └── milewski │ ├── 1 │ └── 1.tex │ ├── 2 │ └── 2.tex │ └── 3 │ ├── 3.md │ └── 3.tex ├── clean-code.md ├── computability-and-logic └── 1.md ├── coq ├── 1.md ├── 2.md ├── 3.md ├── 4.md ├── 5.md ├── 6.md └── misc.md ├── cp.tex ├── create_ap.md ├── dataIntensive.md ├── dbms.md ├── dbms ├── 1.md └── 2.md ├── design-of-everyday-things └── 1.md ├── distributed-computing.md ├── django.md ├── docker.md ├── dom.md ├── dragonBook ├── 3.md └── 4.md ├── dv ├── 1.md └── 2.md ├── eit ├── 2.md └── 3.md ├── electro-dynamics └── ad.tex ├── emacs.pdf ├── emacs ├── 1.md ├── 7.md ├── 8.md ├── README.md └── tutorial.md ├── erlang ├── README.md ├── ch1.beam ├── ch1.erl ├── ch2.erl ├── counter.beam ├── counter.erl ├── echo.beam ├── echo.erl ├── erl_crash.dump ├── factorial.beam ├── lists2.beam ├── lists2.erl ├── number_analyser.erl └── timer.erl ├── essentials-of-compilation.md ├── fundamentals-of-ethics.md ├── gabbay-thesis.md ├── game-theory.md ├── gawk ├── 1.md ├── 3.md └── 4.md ├── gdbref.ps ├── git ├── chapter-1.md ├── chapter-2.md ├── chapter-3.md ├── chapter-4.md ├── chapter-5.md └── chapter-7.md ├── haskell ├── 10.md ├── 12.md ├── 13.md ├── 14.md ├── 15.md ├── 16.md ├── 17.md ├── 18.md ├── 19.md ├── 20.md ├── 22.md ├── 23.md ├── 24.md ├── 25.md ├── 26.md ├── 27.md ├── 29.md ├── 35.md ├── 36.md ├── 37.md ├── 4.md ├── 5.md ├── 6.md ├── 7.md ├── 8.md ├── 9.md ├── README.md ├── monad.hs └── typeclassopedia.md ├── highschool-math.tex ├── how-to-solve-it └── checklist.md ├── http └── http.md ├── hussaini-alam-house.md ├── hyderabad-course ├── classical-urdu-literature.md ├── lecture-notes.md └── verse-translations.md ├── iiit-data-systems.md ├── iiit-ethics.md ├── iiit-fpga.md ├── iiit-ire.md ├── iiit-math-for-bio.md ├── iiit-ril.md ├── iiit-soci.md ├── imc ├── 1.md ├── 2.md ├── 3.md ├── 4.md ├── 5.md └── 8.md ├── intro-language.md ├── intro-nlp └── lectures.md ├── ire-book.md ├── java-concurrency.md ├── jenkins.md ├── joel-test.md ├── jurafsky-nlp.md ├── k8s.md ├── kafka.md ├── kavsi ├── 1.md ├── 2.md ├── 3.md ├── 4.md ├── 5.md ├── 6.md ├── 7.md └── 8.md ├── knrc ├── chapter-1.md ├── chapter-2.md ├── chapter-3.md ├── chapter-4.md ├── chapter-5.md ├── chapter-6.md └── chapter-7.md ├── latex ├── 2 └── 3 ├── lean └── 1.md ├── lil-typer ├── 1.md ├── 2.md └── 3.md ├── little-learner.md ├── living-ethics.md ├── logic-programming-foundations.md ├── ltavsi.md ├── lua ├── chapter-1.md ├── chapter-2.md ├── chapter-3.md ├── chapter-4.md ├── chapter-5.md └── chapter-6.md ├── macros.md ├── make ├── 2.md └── 3.md ├── microservices.md ├── mlir-toy.md ├── music-mind-tech ├── lectures │ ├── 1.md │ ├── 10.md │ ├── 11.md │ ├── 12.md │ ├── 13.md │ ├── 14.md │ ├── 15.md │ ├── 16.md │ ├── 17.md │ ├── 18.md │ ├── 19.md │ ├── 2.md │ ├── 25.md │ ├── 3.md │ ├── 4.md │ ├── 5.md │ ├── 6.md │ ├── 7.md │ ├── 8.md │ └── 9.md └── social-applied-psych-music.md ├── mysql ├── intro.txt └── master.txt ├── networking-course.md ├── oauth.md ├── ocaml ├── 1 │ ├── 1.ml │ ├── README.md │ └── tour.ml ├── 2 │ └── varfunc.ml ├── 3 │ ├── dune │ └── listpattern.ml ├── 4 │ ├── dune │ ├── ext_opt.ml │ ├── ext_opt.mli │ ├── hidden_core.ml │ ├── hidden_core.mli │ ├── included.ml │ ├── linecounter.ml │ └── nested.ml ├── 5 │ └── 5.ml ├── 6 │ └── 6.ml ├── modules.md └── old-mds │ ├── files-modules-programs.md │ ├── lists-and-patterns.md │ ├── overview.md │ ├── records.md │ └── variables-and-functions.md ├── ocw-finance-theory.md ├── os.md ├── papers ├── la-tour-d-hanoi.md ├── logic-prog-survey.md ├── partial-computation-of-programs.md ├── partial-evaluation-of-computation-process.md ├── predicate-logic-as-pl.md ├── reflection-and-semantics-in-lisp.md └── teaching-gc-without.md ├── pfpl └── pfpl.tex ├── prolog ├── ch1.pl └── old-mds │ ├── 1.md │ └── 2.md ├── rap ├── README.md ├── code │ ├── 2.ml │ ├── power_rts.ml │ └── square.ml ├── square.cmi └── square.cmo ├── react └── README.md ├── rebel-sultans.md ├── reflection-thesis-notes.md ├── republic └── 1.md ├── rubik.md ├── russell-happy.md ├── savsi.md ├── scala ├── 2.md └── 3.md ├── sdff ├── 2.rkt └── sdff.md ├── sed ├── 1.md └── 3.md ├── setl └── 2.md ├── sml └── sml.txt ├── spj-paper.md ├── stanford-intro-logic.md ├── sysadmin └── tcp-ip-networking.md ├── talks ├── idescent.tex └── sylow.tex ├── tfgon └── 1.md ├── thoreau-civil-disobeience.md ├── top-student.md ├── topology.tex ├── topology └── munkres │ └── 2.tex ├── trat ├── 1.tex └── 2.tex ├── typescript ├── basic-types.md ├── classes.md ├── functions.md ├── generics.md ├── interfaces.md └── variables.md ├── univAlgebra └── makefile ├── vim ├── 11.md └── 19.md ├── web └── 2.md └── x64_cheatsheet.pdf /.github/workflows/blank.yml: -------------------------------------------------------------------------------- 1 | name: Build LaTeX document 2 | on: [push] 3 | jobs: 4 | build_latex: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Set up Git repository 8 | uses: actions/checkout@v1 9 | - name: Compile LaTeX document 10 | uses: xu-cheng/latex-action@master 11 | with: 12 | root_file: abstract-algebra/0.tex 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pdf 2 | *.aux 3 | *.log 4 | *.toc 5 | *.idx 6 | *.out 7 | -------------------------------------------------------------------------------- /Herbrand Semantics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/Herbrand Semantics.pdf -------------------------------------------------------------------------------- /SPIM_Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/SPIM_Manual.pdf -------------------------------------------------------------------------------- /abstract-algebra/examples.tex: -------------------------------------------------------------------------------- 1 | \documentclass[titlepage, 12pt]{article} 2 | \usepackage[parfill]{parskip} 3 | \usepackage{amsmath} 4 | \usepackage{xcolor} 5 | \usepackage{amsfonts} 6 | \usepackage{amssymb} 7 | \usepackage{setspace} 8 | \usepackage{hyperref} 9 | \usepackage{tcolorbox} 10 | \tcbuselibrary{theorems} 11 | 12 | \hypersetup{ 13 | colorlinks=true, 14 | linkcolor=blue, 15 | filecolor=magenta, 16 | urlcolor=blue, 17 | } 18 | 19 | \newtcbtheorem[]{technique}{Technique}% 20 | {colback=magenta!5,colframe=teal!100!black,fonttitle=\bfseries}{th} 21 | 22 | \newtcbtheorem[]{tip}{Tip}% 23 | {colback=magenta!5,colframe=violet!100!black,fonttitle=\bfseries}{th} 24 | 25 | \newcommand*{\logo}{\fbox{$\mathfrak{BRJ}$}} 26 | 27 | \begin{document} 28 | 29 | \begin{titlepage} 30 | 31 | \raggedleft 32 | 33 | \vspace*{\baselineskip} 34 | 35 | {Bharathi Ramana Joshi\\\url{https://github.com/iambrj/notes}} 36 | 37 | \vspace*{0.167\textheight} 38 | 39 | \textbf{\LARGE Notes on}\\[\baselineskip] 40 | 41 | \textbf{\textcolor{teal}{\huge Abstract Algebra}}\\[\baselineskip] 42 | 43 | {\Large \textit{Collection of examples}} 44 | 45 | \vfill 46 | 47 | {\large \logo} 48 | 49 | \vspace*{3\baselineskip} 50 | 51 | \end{titlepage} 52 | 53 | \newpage 54 | \begin{enumerate} 55 | \item Cyclic group $Z_n$ 56 | \item A normal subgroup that is not abelian $A_5\trianglelefteq S_5$ 57 | \item Smallest simple non abelian group $A_5$ 58 | \item Division ring that is not commutative - Real Hamiltonian 59 | Quaternions $\{a+bi+cj+dk|a,b,c,d\in\mathbb{R}\}$ 60 | \item rng - set of even integers, no multiplicative identity 61 | \end{enumerate} 62 | 63 | \end{document} 64 | 65 | -------------------------------------------------------------------------------- /abstract-algebra/makefile: -------------------------------------------------------------------------------- 1 | pdfs: 2 | for i in *.tex; do latexmk -pdf "$i";done 3 | mkdir pdfs 4 | mv *.pdf pdfs 5 | rm -f *.aux *.toc *.log *.fdb_latexmk *.fls *.out 6 | clean: 7 | rm -r ./pdfs/* 8 | rmdir pdfs 9 | rm -f *.aux *.toc *.log *.fdb_latexmk *.fls *.out 10 | rmlogs: 11 | rm -f *.aux *.toc *.log *.fdb_latexmk *.fls *.out 12 | rmpdfs: 13 | rm *.pdf 14 | -------------------------------------------------------------------------------- /analysis1/2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Chapter-2 : The natural numbers' 3 | author: Bharathi Ramana Joshi 4 | --- 5 | 6 | # Peano axioms 7 | 8 | 1. 0 is a natural number 9 | 2. If $n$ is a natural number, $n++$ is a natural number 10 | 3. 0 is not the successor of any natural number; i.e. $n++\neq 0, \forall n$ 11 | 4. Different natural numbers have different successors; i.e. if $n, m$ are 12 | natural numbers such that $n\neq m$ then $n++\neq m++$ 13 | 5. Let $P(n)$ be any property pertaining to a natural number $n$. Suppose that 14 | $P(0)$ is true, and whenever $P(n)$ is true, $P(n++)$ is also true. Then 15 | $P(n)$ is true for all natural numbers. 16 | 17 | - **Addition**: If $m$ is a natural number, then $0 + m := m$ and $(n++)+ m := (n + m)++$ 18 | - **Positive**: A natural number $n$ is said to be positive iff it is not equal to 19 | 0 20 | - **Ordering**: If $n$ and $m$ are natural numbers, we say $n$ is *greater than* 21 | or *equal to* $m$ and write $n\ge m$ or $m\le n$ iff we have $n = m + a$ for 22 | some natural number $a$. We say that $n$ is *strictly grater than m* and 23 | write $n > m$ or $m < n$ 24 | -------------------------------------------------------------------------------- /analysis1/4.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Chapter-4 : Integers and rationals' 3 | author: Bharathi Ramana Joshi 4 | header-includes: \usepackage{amssymb} 5 | --- 6 | 7 | - Definition - Integers: An integers is an expression of the form $a \Xi b$ where 8 | $a$ and $b$ are natural numbers. Two integers are considered to be equal, 9 | $a\Xi b = c\Xi d$ iff $a+d=c+b$ 10 | - Definition - Integer sum: The sum of two integers $a\Xi b$ and $c\Xi d$ is 11 | defined as $(a+c)\Xi (b+d)$. 12 | - Definition - Negation: If $a\Xi b$ is an integer then the negation, $-(a\Xi 13 | b)$ is defined as the integer $b\Xi a$ 14 | -------------------------------------------------------------------------------- /analysis1/5.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Chapter-4 : Integers and rationals' 3 | author: Bharathi Ramana Joshi 4 | --- 5 | 6 | - Definition - sequence: a sequence is a mapping from the integers to the 7 | rationals, for example $(n^2)_{n=0}^\infty$ 8 | - Definiton - $\epsilon$ steadiness: a sequence $a_0,a_1,\dots$ is $\epsilon$ 9 | steady iff $\forall j, k,\;d(a_j, a_k)\leq\epsilon$ 10 | - Definition - eventual $\epsilon$ steadiness: a sequence $(a_n)_{n=0}^\infty$ 11 | is eventually $\epsilon$ steady iff the sequence $a_N, a_{N+1},\dots$ is 12 | $\epsilon$ steady for some natural number $N\geq 0$ 13 | - Definition - Cauchy sequences: a sequence $(a_n)_{n=0}^\infty$ of rational 14 | numbers is said to be a Cauchy sequence iff for every rational $\epsilon > 15 | 0$, the sequence $(a_n)_{n=0}^\infty$is eventually $\epsilon$ steady 16 | Intuition - you can make the difference between elements arbitrarily close 17 | to zero if you go sufficiently farther into the sequence 18 | - Definition - Bounded sequence: a finite sequence $(a_i)_{i=1}^n$ is bounded by 19 | $M$ iff $|a_i|\leq M$ for all $1\leq i\leq n$. An infinite sequence 20 | $(a_n)_{n = 1}^\infty$ is bounded by $M$ iff $|a_i|\leq M$ for all $i\geq 1$ 21 | - Definition - $\epsilon$ close sequences: two sequences $(a_n)_{n = 1}^\infty$ 22 | and $(b_n)_{n = 1}^\infty$ are $\epsilon$ close iff $a_n$ is $\epsilon$ 23 | close to $b_n$ for each $n\in N$ 24 | - Definition - Equivalent sequences: two sequences $(a_n)_{n = 1}^\infty$ and 25 | $(b_n)_{n = 1}^\infty$ are equivalent iff for each rational $\epsilon > 0$, 26 | they are eventually $\epsilon$ close 27 | - Definition - Real numbers: A real number is defined as an object of the form 28 | $lim_{n\rightarrow\infty}a_n$ where $(a_n)_{n=1}^\infty$ is a Cauchy 29 | sequence of real numbers. Two real numbers are equal if their Cauchy 30 | sequences are equivalent. 31 | - Proposition: equality is well defined. 32 | - Definition: A sequence $(a_n)_{n = 1}^\infty$ of rational numbers is said to 33 | be bounded away from zero iff there exists a rational number $c>0$ such that 34 | $|a_n|\geq c$ for all $n\geq 1$ 35 | - Lemma: If $x$ is a non zero real number, then it is the limit of some Cauchy 36 | sequence bounded away from zero. 37 | - Definition - sequences bounded away from zero: A sequence $(a_n)_{n=1}^\infty$ 38 | of rational numbers is said to be *bounded away from zero* iff $\exists$ 39 | rational number $c>0$ such that $|a_n|\geq c, \forall n\geq 1$ 40 | -------------------------------------------------------------------------------- /analysis1/6.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Chapter-6 : Limits of sequences' 3 | author: Bharathi Ramana Joshi 4 | --- 5 | 6 | - Definition - Convergence of sequences: $\epsilon > 0$ and $L$ are real 7 | numbers, then a sequence $(a_n)_{n=N}^\infty$ of real numbers is said to 8 | converge to $L$ iff $\exists N$ such that $\forall n\geq N, |a_n - 9 | L|\leq\epsilon$ 10 | - Limits are unique 11 | - Definition - Limit points: If $(a_n)_{n=m}^\infty$ is a sequence of real 12 | numbers and $x$ is a real number then $x$ is said to be a *limit point* of 13 | $(a_n)_{n=m}^\infty$ iff $\forall\epsilon > 0, \exists N$ such that 14 | $\exists a_i\;\epsilon$ close to $x, \forall i \geq N$. Intuitively, one can 15 | always find elements arbitrarily close to $x$ by going sufficiently deeper 16 | into the sequence. 17 | - Remark: The difference between convergence and limit points is that 18 | the former requires *every* element to be $\epsilon$ close after sufficient 19 | depth, but the latter only requires *at least* one element to be $\epsilon$ 20 | close after sufficient depth. In other words, it is universal vs existential 21 | qualification 22 | - Proposition : Limits are limit points 23 | - Definition - Limit superior 24 | \begin{gather*} 25 | limsup_{n\rightarrow\infty} a_n := inf(a_N^+)_{N=m}^\infty 26 | \end{gather*} 27 | where 28 | \begin{gather*} 29 | a_N^+ := sup(a_n)_{n=N}^\infty 30 | \end{gather*} 31 | - Definition - Limit inferior 32 | \begin{gather*} 33 | liminf_{n\rightarrow\infty} a_n := sup(a_N^-)_{N=m}^\infty 34 | \end{gather*} 35 | where 36 | \begin{gather*} 37 | a_N^- := inf(a_n)_{n=N}^\infty 38 | \end{gather*} 39 | Intuitively, these are smallest upper bound and greatest lower bound *at 40 | infinity* 41 | - Lemma - Continuity of exponentiation: If $x > 0$, $\alpha$ is a real 42 | number, $(q_n)_{n=1}^\infty$ is a sequence of rational numbers converging to 43 | $\alpha$ then $(x^{q_n})_{n=1}^\infty$ is also a convergent sequence 44 | -------------------------------------------------------------------------------- /apl.md: -------------------------------------------------------------------------------- 1 | ``` 2 | author: Bharathi Ramana Joshi 3 | title: Notes on APL 4 | ``` 5 | 6 | - Depth (`≡`): layers of nesting, or length of largest layer (prepended with - 7 | if uneven array). 8 | - Shape (`⍴`): exact lengths of each dimension. 9 | - Rank: number of dimensions, i.e. shape of shape! 10 | - Important identity: `X ≡ ⍴ (X ⍴ A)`, i.e. the shape of an array is always the 11 | same after reshaping. 12 | - Empty shape: ` ⍬`(numbers)/`''`(character). 13 | - Light bulb `⍝` for comments (since the illuminate us). 14 | - Scalar functions: functions that penetrate the arrays, all the way down to 15 | simple scalars before application. 16 | - Scalar functions applied dyadically throw errors if argument shapes don't 17 | match up. 18 | - Scalar extension 19 | - Mixed function: works with larger structures of its arguments. 20 | - Dynamic functions (`dfns`): expressions enclosed in `{}`, left argument `⍺` and 21 | right argument `⍵`. 22 | - Use "self" `∇` for recursive definitions, can rename functions without having 23 | to change the body. 24 | - Tacit function: APL statement that does not have data on the right 25 | - Two-train/atop: 26 | ``` 27 | (f g) X ←→ f (g X) 28 | ``` 29 | - Dyadic trains: 30 | ``` 31 | X (f g) Y ←→ f (X g Y) 32 | ``` 33 | and, 34 | ``` 35 | X (f g h) Y ←→ (X f Y) g (X h Y) 36 | ``` 37 | - Tree-trains/forks: 38 | ``` 39 | (f g h) X ←→ (f X) g (h X) 40 | ``` 41 | and, 42 | ``` 43 | (A g h) X ←→ A g (h X) 44 | ``` 45 | -------------------------------------------------------------------------------- /apue/1: -------------------------------------------------------------------------------- 1 | #include 2 | char *strerror(int errorno); //returns error string corresponding to errorno 3 | 4 | #include 5 | void perror(const char *msg); //print msg onto std error 6 | 7 | Unix systems maintain three values for a process 8 | 1. Clock time 9 | 2. User CPU time 10 | 3. System CPU time 11 | -------------------------------------------------------------------------------- /apue/11: -------------------------------------------------------------------------------- 1 | #include 2 | int pthread_equal(pthread_t tid1, pthread_t tid2); /* test if both are equal */ 3 | /* nonzero if equal, 0 otherwise */ 4 | 5 | #include 6 | pthread_t pthread_self(void); 7 | /* returns thread id of calling thread */ 8 | 9 | #include 10 | int pthread_create(pthread_t *restrict tidp, const pthread_attr_t *restrict attr, void *(*start_rtn)(void *), void *restrict arg); 11 | /* returns 0 if OK, error code on failure */ 12 | 13 | #include 14 | void pthread_exit(void *rval_ptr); /* exit current thread with rval_ptr return value */ 15 | 16 | int pthread_join(pthread_t tid, void **rval_ptr); /* block current thread until tid finishes */ 17 | /* returns 0 if OK, error number otherwise */ 18 | 19 | #include 20 | int pthread_cancel(pthread_t tid); /* request to cancel thread tid with rval_ptr = PTHREAD_CANCELLED*/ 21 | /* returns 0 if OK, error no otherwise */ 22 | 23 | #include 24 | void pthread_cleanup_push(void (*rtn)(void *), void *arg); 25 | void pthread_cleanup_pop(int execute); /* set 0 to not call rtn */ 26 | 27 | #include 28 | int pthread_detach(pthread_t tid); 29 | /* return 0 if OK, error number on failure */ 30 | 31 | 32 | -------------------------------------------------------------------------------- /apue/7: -------------------------------------------------------------------------------- 1 | #include 2 | void exit(int status); /* cleans up before terminating */ 3 | void _Exit(int status); 4 | 5 | #include 6 | void _exit(int status); 7 | 8 | #include 9 | int atexit(void (*func)(void)); /* maintained in stack */ 10 | /*Returns 0 if OK, nonzero otherwise*/ 11 | 12 | argv[argc] == NULL 13 | 14 | #include 15 | void *malloc(size_t size); /* Initial value inderminate*/ 16 | void *calloc(size_t nobj, size_t size); /* All bits set to zero*/ 17 | void *realloc(void *ptr, size_t newsize); 18 | /* Return non-null pointer if OK, NULL on error*/ 19 | 20 | void free(void *ptr); 21 | 22 | #include 23 | char *getenv(const char *name); 24 | /* Returns pointer to value associated with name, NULL if not found*/ 25 | 26 | #include 27 | int putenv(char *str); 28 | /*Returns 0 if OK, nonzero on error*/ 29 | int setenv(const char *name, const char *value, int rewrite = 0 / 1); 30 | int unsetenv(const char *name); 31 | /*Return 0 if OK, -1 on error*/ 32 | 33 | #include 34 | int setjmp(jmp_buf env); 35 | /* Returns 0 if called directly, nonzero if returning from a call to longjmp*/ 36 | void longjmp(jmp_buf env, int val); 37 | 38 | #include 39 | int getrlimit(int resource, struct rlimit *rlptr); 40 | int setrlimit(int resource, const struct rlimit *rlptr); 41 | resource = RLIMIT_AS/CORE/CPE/DATA/FSIZE/MEMLOCK/MSGQUEUE/NICE/NOFILE/NPROC/NPROC/NPTSRSS/SBSIZE/SIGPENDING/STACK/SWAP/VMEM 42 | struct rlimit 43 | { 44 | rlim_t rlim_cur; /* soft limit: current limit*/ 45 | rlim_t rlim_max; /* hard limit: ma value for rlim_cur */ 46 | }; 47 | Use limit = RLIM_INFINITY for infinite limit 48 | -------------------------------------------------------------------------------- /apue/9: -------------------------------------------------------------------------------- 1 | #include 2 | pid_t getpgrp(void); 3 | /* Returns process group ID of calling process */ 4 | 5 | #include 6 | pid_t getpgid(pid_t pid); 7 | /* Returns process group ID if OK, -1 on error */ 8 | pid == 0 then same as getpgrp() 9 | 10 | #include 11 | int setpgid(pid_t pid, pid_t pgid); 12 | 13 | #include 14 | pid_t setsid(void); 15 | /* Returns process group ID if OK, -1 on error*/ 16 | 17 | #include 18 | pid_t getsid(pid_t pid); 19 | /* Returns session leader's process group ID if OK, -1 on error */ 20 | 21 | #include 22 | pid_t tcgetpgrp(int fd); 23 | /* Returns process group ID of foreground process group if OK, -1 on error */ 24 | int tcsetpgrp(int fd, pid_t pgrpid); 25 | /* Returns 0 if OK, -1 otherwise */ 26 | 27 | #include 28 | pid_t tcgetsid(int fd); 29 | /* Returns session leader's process group ID if OK, -1 on error */ 30 | 31 | 32 | -------------------------------------------------------------------------------- /bin/cf448d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/bin/cf448d.png -------------------------------------------------------------------------------- /category-theory/milewski/2/2.tex: -------------------------------------------------------------------------------- 1 | \documentclass[titlepage, 12pt]{article} 2 | \usepackage[parfill]{parskip} 3 | \usepackage{listings} 4 | 5 | \begin{document} 6 | 7 | \title{Category Theory Unit 2} 8 | 9 | \author{Bharathi Ramana Joshi} 10 | 11 | \date{\today} 12 | 13 | \maketitle 14 | 15 | \newpage 16 | 17 | \section{Book} 18 | \begin{enumerate} 19 | \item Monkeys banging at the keyboard: 20 | \begin{itemize} 21 | \item Machine language $\Rightarrow$ any combination produced should be run 22 | \item High level language $\Rightarrow$ lexical and grammatical errors detected 23 | \item Type checking further removes errors 24 | \item Question: Make monkeys happy or produce correct programs? 25 | \end{itemize} 26 | \item Intuitively, types are (finite or infinite) sets of values. 27 | \item A category of sets, \textbf{Set} has objects as sets and morphisms 28 | (arrows) as functions 29 | \item To overcome infinite recursion, a new type $\perp$ (bottom) is introduced 30 | \item \textbf{Operational semantics} describes the mechanics of program execution in 31 | terms of a formalized idealized interpreter 32 | \item \textbf{Denotational semantics} gives every programming construct its 33 | mathematical interpretation - proving a property of a program is same as 34 | proving a mathematical theorem 35 | \item Functions that always produce the same result given the same input and 36 | have no side effects are called \textbf{pure functions} 37 | \item The type corresponding to an empty set is \lstinline{Void} - it's a 38 | type that's not inhabited by any values 39 | \item The type corresponding to a singleton set is \lstinline{()} 40 | \item Functions from unit to any type $A$ are in one-to-one correspondence 41 | with the elements of that set $A$ 42 | \item The type corresponding to a two element set is \lstinline{Bool} 43 | \end{enumerate} 44 | 45 | \section{Lecture 2.1} 46 | 47 | A function is pure if it can be memoised 48 | 49 | Isomorphism - a function that is invertible ($f\circ g = id$, for some $g$) 50 | 51 | \end{document} 52 | 53 | -------------------------------------------------------------------------------- /category-theory/milewski/3/3.md: -------------------------------------------------------------------------------- 1 | ``` 2 | mappend = (++) 3 | ``` 4 | is different from 5 | ``` 6 | mappend s1 s2 = (++) s1 s2 7 | ``` 8 | -------------------------------------------------------------------------------- /computability-and-logic/1.md: -------------------------------------------------------------------------------- 1 | * An **enumerable**/**countable** set is one whose members can be enumerated: 2 | arranged in a single list with a first entry, a second entry, and so on, so 3 | that every member of the set appears sooner or later on the list. 4 | * The empty set is regarded as enumerable by convention 5 | * An infinite set that is enumerable is said to be enumerably infinite or 6 | denumerable 7 | * In an acceptable list, each item must appear sooner or later as the *n*th 8 | entry, for some *finite* n. Therefore lists of the kind 1, 3, 5,..., 2, 4, 9 | 6,... are not acceptable 10 | * An infinite list determines a *function* that takes integers are *arguments* and 11 | returns members of the set as *values*. 12 | * In enumerating a set by listing its members, it is perfectly all right if a 13 | member of the set shows up more than once - the requirement is that each 14 | member show up *at least* once. 15 | * 16 | -------------------------------------------------------------------------------- /coq/2.md: -------------------------------------------------------------------------------- 1 | # Proof by induction 2 | * For the Require Export to work, Coq needs to be able to find a compiled version 3 | of Basics.v, called Basics.vo, in a directory associated with the prefix LF. 4 | This file is analogous to the .class files compiled from .java source files and 5 | the .o files compiled from .c files. 6 | ``` 7 | From LF Require Export Basics. 8 | ``` 9 | * A `_CoqProject` file should have project name as follows 10 | ``` 11 | -Q . LF 12 | ``` 13 | * Use 14 | ``` 15 | coq_makefile -f _CoqProject *.v -o Makefile 16 | ``` 17 | to generate a makefile. Then you can compile `Basics.v` by running make with the 18 | corresponding `.vo` file as a target: 19 | ``` 20 | make Basics.vo 21 | ``` 22 | * Under the hood, make uses the Coq compiler, coqc. You can also run coqc directly: 23 | ``` 24 | coqc -Q . LF Basics.v 25 | ``` 26 | # `induction` tactic 27 | ``` 28 | Theorem plus_n_O : forall n:nat, n = n + 0. 29 | Proof. 30 | intros n. induction n as [| n' IHn']. 31 | - (* n = 0 *) reflexivity. 32 | - (* n = S n' *) simpl. rewrite <- IHn'. reflexivity. Qed. 33 | ``` 34 | # Assert 35 | * It is convenient to be able to simply state and prove the needed "sub-theorem" 36 | right at the point where it is used. The assert tactic allows us to do this. 37 | ``` 38 | Theorem mult_0_plus' : ∀n m : nat, 39 | (0 + n) * m = n * m. 40 | Proof. 41 | intros n m. 42 | assert (H: 0 + n = n). { reflexivity. } 43 | rewrite → H. 44 | reflexivity. Qed. 45 | ``` 46 | -------------------------------------------------------------------------------- /coq/3.md: -------------------------------------------------------------------------------- 1 | # Lists 2 | ## Induction on lists 3 | * Each Inductive declaration defines a set of data values that can be built up 4 | using the declared constructors: a boolean can be either true or false; a number 5 | can be either O or S applied to another number; a list can be either nil or cons 6 | applied to a number and a list. 7 | # Search 8 | * Entering and evaluating `Search foo` will display list of all proved theorems 9 | with `foo`. 10 | -------------------------------------------------------------------------------- /coq/4.md: -------------------------------------------------------------------------------- 1 | * The Arguments directive specifies the name of the function (or constructor) and 2 | then lists its argument names, with curly braces around any arguments to be 3 | treated as implicit. (If some arguments of a definition don't have a name, as is 4 | often the case for constructors, they can be marked with a wildcard pattern `_`.) 5 | ``` 6 | Arguments nil {X}. 7 | Arguments cons {X} _ _. 8 | Arguments repeat {X} x count. 9 | ``` 10 | * Alternatively, we can declare an argument to be implicit when defining the 11 | function itself, by surrounding it in curly braces instead of parens. For 12 | example: 13 | ``` 14 | Fixpoint repeat''' {X : Type} (x : X) (count : nat) : list X := 15 | match count with 16 | | 0 ⇒ nil 17 | | S count' ⇒ cons x (repeat''' x count') 18 | end. 19 | ``` 20 | -------------------------------------------------------------------------------- /coq/5.md: -------------------------------------------------------------------------------- 1 | # Swapping LHS RHS 2 | Use `symmetry` to swap LHS and RHS in the goal. 3 | # Apply 4 | ``` 5 | apply eq2. 6 | Qed. 7 | ``` 8 | is same as 9 | ``` 10 | rewrite -> eq2. 11 | reflexivity. 12 | Qed. 13 | ``` 14 | * To use the apply tactic, the (conclusion of the) fact being applied must match 15 | the goal exactly 16 | # Injection and discriminate 17 | * The same principles apply to all inductively defined types: all constructors 18 | are injective, and the values built from distinct constructors are never equal 19 | # `apply with` 20 | ``` 21 | Theorem trans_eq : forall(X : Type) (n m o : X), 22 | n = m -> m = o -> n = o. 23 | Proof. 24 | intros X n m o eq1 eq2. 25 | rewrite -> eq1. 26 | rewrite -> eq2. 27 | reflexivity. 28 | Qed. 29 | 30 | Example trans_eq_example : forall(a b c d e f : nat), 31 | [a;b] = [c;d] -> 32 | [c;d] = [e;f] -> 33 | [a;b] = [e;f]. 34 | Proof. 35 | intros a b c d e f eq1 eq2. 36 | apply trans_eq with (m := [c;d]). 37 | apply eq1. 38 | apply eq2. 39 | Qed. 40 | ``` 41 | # `injection` 42 | ``` 43 | Inductive nat : Type := 44 | | O : nat 45 | | S : nat → nat. 46 | ``` 47 | * The constructor `S` is injective. That is, if `S n = S m,` it must be the case 48 | that `n = m`. 49 | * The constructors `O` and `S` are disjoint. That is, `O` is not equal to `S n` for any 50 | `n`. 51 | * Coq provides a tactic called `injection` that allows us to exploit the 52 | injectivity of any constructor 53 | ``` 54 | ``` 55 | * By writing injection `H` at this point, we are asking Coq to generate all 56 | equations that it can infer from `H` using the injectivity of constructors 57 | # `discriminate` 58 | * This is an instance of a logical principle known as the principle of 59 | explosion, which asserts that a contradictory hypothesis entails anything, 60 | even false things! 61 | # Use tactic `in` hypothesis 62 | # `generalize dependent` 63 | Selectively take variables out of context and put them back at the beginning of 64 | the goal. 65 | # `unfold` 66 | Use a `Definition` in a proof when `simpl`, `apply` or `rewrite` don't work. 67 | -------------------------------------------------------------------------------- /coq/6.md: -------------------------------------------------------------------------------- 1 | In Coq, `Prop`s are first class entities - we can write functions that 2 | take/return `Prop`s etc 3 | 4 | # `split` 5 | Tactic used to prove a logical and 6 | 7 | # `destruct` 8 | Tactic used to replace a conjunctive hypothesis with two individual hyptheses 9 | 10 | # `Axiom` 11 | * Create new axiom 12 | ``` 13 | Axiom functional_extensionality : ∀{X Y: Type} 14 | {f g : X → Y}, 15 | (∀(x:X), f x = g x) → f = g. 16 | ``` 17 | # `Print Assumptions` 18 | * Check whether a particular proof relies on any additional axioms. 19 | -------------------------------------------------------------------------------- /coq/misc.md: -------------------------------------------------------------------------------- 1 | * `Require` loads a library whereas `Import` brings its definitions into scope 2 | - If a library is only loaded, you'll need to refer to names fully qualified 3 | -------------------------------------------------------------------------------- /create_ap.md: -------------------------------------------------------------------------------- 1 | * To create a WiFi, use `sudo create_ap wlp2s0 enp3s0 lappy nowifi4u` 2 | * To delete redundant virtual interfaces, use `sudo iw dev ap0 del` 3 | * To up an interface, use `sudo ip link set wlp2s0 up` 4 | * To deal with `RTNETLINK answers: Operation not possible due to RF-kill`, use `sudo rfkill unblock wlan` 5 | -------------------------------------------------------------------------------- /dbms/1.md: -------------------------------------------------------------------------------- 1 | # FS vs DBMS 2 | * FSs have limited memory 3 | * Even with virtual memory, more than 2^32 (~4GB) addressing not possible 4 | * Queries slower - as data large 5 | * Need for consistency adds complexity 6 | * Crash recovery 7 | * Security 8 | # Advantages of DBMS (IIESAAC) 9 | * Data **I**ndependence 10 | * Data **I**ntegrity 11 | * **E**fficient access 12 | * **S**ecurity 13 | * Data **A**dministration 14 | * Reduced **A**pplication development time 15 | * **C**oncurrent access 16 | * **C**rash recovery 17 | # Levels of abstraction 18 | * **Data Definition Language (DDL)**: used to define the external and conceptual 19 | schemas 20 | ## Conceptual Schema 21 | * **Conceptual/Logical Schema**: describes the stored data in terms of the data 22 | model of the dbms 23 | * **Conceptual Database Design**: process of arriving at a good conceptual 24 | schema 25 | ## Physical Schema 26 | * **Physical Schema**: used to specify additional storage details - summarizes 27 | how the relations described in the conceptual schema are actually stored on 28 | secondary storage devices 29 | ## External Schema 30 | * **External Schema**: allow data access to be customized at the level of 31 | individual users or groups of users 32 | # Data Independence 33 | * Application programs should be insulated from the way data is structured and 34 | stored 35 | ## Logical Data Independence 36 | * Users being shielded from changes in the logical structure of the data, or 37 | change in the choice of relations to be stored 38 | ## Physical Data Independence 39 | * Users being insulated from the changes in the physical storage details 40 | # Glossary 41 | * **Data model**: collection of high level data description constructs that hide 42 | many low-level storage details 43 | * **Semantic data model**: more abstract, high level data model that makes it 44 | easier for a user to come up with a good initial description of the data in 45 | an enterprise 46 | * **Relation**: set of records 47 | * **Schema**: a description of data in terms of a data model 48 | * **Field**: attribute or column 49 | * **Integrity constraints**: conditions that the records in a relation must 50 | satisfy 51 | * **Transaction**: any one execution of a user program in DBMS 52 | -------------------------------------------------------------------------------- /dbms/2.md: -------------------------------------------------------------------------------- 1 | # Database design 2 | 1. **Requirements analysis**: understand what data is to be stored in the 3 | database, what applications must be built on top of it, and what operations 4 | are most frequent and subject to performance requirements i.e., what do the 5 | users want? 6 | 2. **Conceptual Database Design**: develop high-level description of data to be 7 | stored in database using info from step 1. Generate ER schema. 8 | 3. **Logical Database Design**: convert ER schema to relational database schema 9 | ## Beyond ER 10 | 4. **Schema Refinement**: normalization, identify potential problems and resolve 11 | 5. **Physical Database Design**: consider typical expected workload and further 12 | refine. Indexing and clustering 13 | 6. **Application and Security Design**: beyond database 14 | # Glossary 15 | * **Entity**: an object in the real world that is distinguishable from other objects 16 | * **Entity Set**: collection of similar entities 17 | * **Attributes**: elements used to describe entities. All entities in a given 18 | entity set have *similar* attributes 19 | * **Key**: minimal set of attributes whose values uniquely identify an entity in 20 | a given set 21 | * **Primary key**: a designated key from available keys 22 | * **Candidate keys**: all other keys 23 | * **Relationship**: an association among two or more entities 24 | * **Relationship set**: a set of similar relationships; can be thought of as a 25 | set of n-tuples `{(e1, ..., en) | e1 ∈ E1, ..., en ∈ En}` 26 | * **Descriptive attributes**: used to record information about the relationship, 27 | rather than about nay one of the participating entities 28 | -------------------------------------------------------------------------------- /django.md: -------------------------------------------------------------------------------- 1 | # Tutorial 1 2 | * `django-admin startproject polls` - create a new django project named `polls` 3 | * `python manage.py startserver` - start web app on localhost 4 | # Creating a new view 5 | 1. `pollsapp/views.py` - define `index(request)` 6 | 2. `pollsapp/urls.py` - add url for view here 7 | ``` 8 | urlpatterns = [ 9 | path('', views.index, name='index'), 10 | ] 11 | ``` 12 | 3. `pollsproject/urls.py` - add rootURL conf herer 13 | ``` 14 | urlpatterns = [ 15 | path('pollsapp/', include('pollsapp.urls')), # new url 16 | path('admin/', admin.site.urls), 17 | ] 18 | ``` 19 | The `path` function here takes four arguments 20 | - `route`: string containing URL pattern 21 | - `view`: function to be called when pattern is matched 22 | - `name`: unique identifier for URL 23 | # Tutorial 2 24 | * `INSTALLED_APPS` in `settings.py` holds list of all django applications that 25 | are activated 26 | * `python manage.py createsuperuser` - create new admin 27 | * `pollsapp/admin.py` - contains models we want to be displayed in our admin 28 | interface 29 | ``` 30 | from django.contrib import admin 31 | 32 | from .models import Question 33 | 34 | admin.site.register(Question) 35 | ``` 36 | ## Making model changes 37 | * Change your models (in models.py). 38 | * Run python manage.py makemigrations to create migrations for those changes 39 | * Run python manage.py migrate to apply those changes to the database. 40 | -------------------------------------------------------------------------------- /dv/2.md: -------------------------------------------------------------------------------- 1 | ![what-can-be-viz](https://user-images.githubusercontent.com/29101670/77601611-3581c880-6f31-11ea-928a-29b18e655ebe.png) 2 | -------------------------------------------------------------------------------- /eit/3.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on Elements of Information Theory, Chapter 3 4 | --- 5 | - Law of Large Numbers: For large number of iid trails, the actual mean 6 | converges to expected mean 7 | \begin{gather*} 8 | \frac{1}{n}\sum_{i=1}{n}X_i\rightarrow E[X] 9 | \end{gather*} 10 | - Asymptotic Equipartition Property 11 | \begin{gather*} 12 | \frac{1}{n}log\frac{1}{p(X_1,\dots,X_n)}\rightarrow H(X) 13 | \end{gather*} 14 | Equivalently 15 | \begin{gather*} 16 | p(X_1,\dots,X_n)\rightarrow 2^{-nH} 17 | \end{gather*} 18 | - Convergence of Random Variables: A sequence of random variables 19 | $(X_1,\dots)$ is said to converge to a random variable $X$ 20 | \begin{enumerate} 21 | \item \textbf{In probability}:$\forall\epsilon > 0, Pr\{|X_n - X| > 22 | \epsilon\}\rightarrow 0$ 23 | \item \textbf{In mean square}: $E(X_n-X)^2\rightarrow 0$ 24 | \item \textbf{With probability 1}: $Pr\{\lim_{n\rightarrow\infty}X_n = 25 | X\} = 1$ 26 | \end{enumerate} 27 | - The typical set $A_\epsilon^{(n)}$ with respect to $p(x)$ is the set of 28 | sequences $(x_1,\dots,x_n)\in\chi^n$ such that 29 | \begin{gather*} 30 | 2^{-n(H(X)+\epsilon)}\leq p(x_1,\dots,x_n)\leq 2^{-n(H(n)-\epsilon)} 31 | \end{gather*} 32 | - Theorem 33 | \begin{enumerate} 34 | \item $(x_1,\dots,x_n)\in A_\epsilon^{(n)}\implies 35 | H(X)-\epsilon\leq\frac{1}{n}logp(x_1,\dots,x_n)\leq H(X)+\epsilon$ 36 | \item $Pr\{A_\epsilon^{(n)}\} > 1-\epsilon$, for sufficiently large $n$ 37 | \item $|A_\epsilon^{(n)}|\leq 2^{n(H(X)+\epsilon)}$ 38 | \item $|A_\epsilon^{(n)}|\geq (1-\epsilon)2^{n(H(X)-\epsilon)}$ 39 | \end{enumerate} 40 | -------------------------------------------------------------------------------- /electro-dynamics/ad.tex: -------------------------------------------------------------------------------- 1 | \documentclass[titlepage, 12pt]{article} 2 | \usepackage[parfill]{parskip} 3 | 4 | \begin{document} 5 | 6 | \title{Advertisement notes} 7 | 8 | \author{Bharathi Ramana Joshi} 9 | 10 | \maketitle 11 | 12 | \newpage 13 | 14 | \begin{itemize} 15 | \item Charge comes in two varieties 16 | \item Charge is conserved\\ 17 | - \textbf{Global conservation}: total charge of universe is fixed for 18 | all time\\ 19 | - \textbf{Local conservation}: disappear at one place and reappear at 20 | another, \textbf{continuity equation}\\ 21 | \item Charge is quantized - it comes only in discrete integer multiples of 22 | the basic unit of charge $e$ 23 | \end{itemize} 24 | 25 | \end{document} 26 | 27 | -------------------------------------------------------------------------------- /emacs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/emacs.pdf -------------------------------------------------------------------------------- /emacs/1.md: -------------------------------------------------------------------------------- 1 | * **frame** - a graphical window or terminal screen occupied by Emacs 2 | * **window** - below the tool bar and above the echo area 3 | * **mode line** - last line of the window; displays various information about 4 | what is going on in the buffer 5 | * **selected window** - active window 6 | * **current buffer** - buffer displayed in the selected window 7 | # Point 8 | * **point** - location shown by the cursor in the selected window where most of 9 | the editing commands take effect 10 | * If the cursor is over `b` in `frob`, then point is between `o` and `b` 11 | * Each buffer has its own value of point 12 | # Echo area 13 | * The line at the very bottom of the frame 14 | * Single-character commands are not echoed and multi-character commands are 15 | echoed if paused for more than one second in the middle of a command 16 | * Informative echo area messages are saved in a special buffer named `*Messages*` 17 | * Commands that take a long time often display messages ending in `...` while 18 | they are working 19 | * Echo area is also used to display the "minibuffer", a special window where you 20 | can input arguments to commands 21 | 22 | # Mode Line 23 | * The line at the bottom which describes what is going on in the current buffer 24 | * Format 25 | ``` 26 | CS:CH-FR BUF POS LINE (MAJOR MINOR) 27 | ``` 28 | * `CS` - character set 29 | * `CH` 30 | - `--` - buffer displayed in window has same contents as on disk file 31 | - `**` - buffer modified 32 | - `%*` - modified read-only buffer 33 | - `%%` - otherwise 34 | * `-` (after `CH`) 35 | - `-` - Default directory for current buffer is local machine 36 | - `@` - Default directory for current buffer is remote machine 37 | * `FR` - gives selected frame name (text terminal only) 38 | * `BUF` - name of the buffer displayed in the buffer 39 | * `POS` - position of point in buffer 40 | * `LINE` - line number of point 41 | * `MAJOR` - name of major mode used in the buffer 42 | * `MINOR` - list of enabled minor modes 43 | # Menu bar 44 | * First menu bar item can be invoked by pressing `` and then usual 45 | navigation keys can be used. -------------------------------------------------------------------------------- /emacs/7.md: -------------------------------------------------------------------------------- 1 | # Changing location of point 2 | * `M-r` - move cursor to screen center line 3 | * `M-g c` - move cursor to char N 4 | * `M-g M-g`, `M-g g` - move cursor to beginning of line N 5 | * `M-g ` - move cursor to current column of line N 6 | * `C-x C-n` - set current column to semi-permanent goal column 7 | * `C-u C-x C-n` - cancel goal column 8 | # Erasing text 9 | * `C-d` - delete char after point 10 | * `C-k` - kill to end of line 11 | * `M-d` - kill forward to end of next word 12 | * `M-`, `M-` - kill backward till beginning of previous word 13 | # Undoing changes 14 | * `C-/`, `C-x u`, `C-_` to undo changes 15 | # Files 16 | * `C-x C-f ` - open a file 17 | * `C-x C-s` - save buffer 18 | * `C-h k` - describe key 19 | * `C-o` - open line 20 | * `C-x C-o` - delete all but one of many consecutive bank lines 21 | # Continuation lines 22 | * `C-n` and `C-p` work on screen lines, not logical lines 23 | * Lines can be turncated (one logical line == one screen line) 24 | * Visual Line Mode - enables word wrapping instaed of window edge wrapping 25 | # Cursor position information 26 | * `M-x what-line` - display line number of point 27 | * `M-x line-number-mode`, `M-x column-number-mode` - toggle automatic display 28 | * `M-=` - display no of lines, words and chars in region 29 | * `M-x count-words` - display no of lines, words and chars in buffer 30 | * `C-x =` - display char code, pos and col of point 31 | * `M-x hl-line-mode` - toggle highlighting current line 32 | * `M-x size-indication-mode` - toggle automatic display of buffer size 33 | * `M-x what-line` - display current line number in echo area 34 | # Numeric arguments 35 | * `M-` - specify a numeric argument to following command 36 | * `M- ` - multi digit argument (to insert repeated copies of a 37 | second digit instead, use `C-u` after `M-`) 38 | * `C-u` - repeat following command four times 39 | * Some commands behave differently when repeat count is used (`C-k` for e.g.) 40 | # Repeating a command 41 | * `C-x z`If the command being invoked repeats prompts for input or uses a 42 | numeric argument in another way -------------------------------------------------------------------------------- /emacs/README.md: -------------------------------------------------------------------------------- 1 | # emacs cheatsheet 2 | 3 | * `M-x cua-mode` - enable cut/copy/paste for `C-x`/`C-c`/`C-v` 4 | -------------------------------------------------------------------------------- /emacs/tutorial.md: -------------------------------------------------------------------------------- 1 | * `C-p` to go to **p**revious line 2 | * `C-n` to go to **n**ext line 3 | * `C-f` to go **f**orward one character 4 | * `C-b` to **b**ackward one character 5 | * `C-x C-c` to quit 6 | * `C-g` to quit a partially entered command 7 | * `C-v` to view next screen 8 | * `M-v` to view previous screen 9 | * `C-l` to clear screen and redisplay all text 10 | * `M-f`to move **f**orward by a word 11 | * `M-b` to move **b**ackward by one word 12 | * `C-a` to move beginning of a line (a is the beginning of the alphabet?) 13 | * `C-e` to move to the **e**nd of a line 14 | * Usually, `C` applies to smallest unit, `M` applies to next larger unit and 15 | `C-M` applies to largest unit 16 | * The location of the cursor in the text is called the "point" 17 | * `M-<` to go to beginning of text 18 | * `M->` to go to end of text 19 | * `C-u ` to repeat a command 20 | * `C-k` kill to end of line 21 | * `M-k` kill to end of sentence 22 | * `C-` to enter visual mode 23 | * `C-` to make a selection and `C-w` to kill selection 24 | * `C-k` to kill form current position to end of line 25 | * `C-y` to yank last killed line 26 | * `M-y` to go back to older yanksA 27 | * `C-/` to undo 28 | * `C-x C-f` to find a file 29 | * `C-x C-s` to save changes to a file 30 | * `C-x C-b` to list all buffers 31 | * `C-x b ` to switch buffers 32 | * `C-x s` to save some files 33 | * `C-x 1` kill all but one windows 34 | * `hello.c` is auto saved to `#hello.c#` 35 | * `C-x f ` to change margin size 36 | * `C-s` for forward search 37 | * `C-r` for reverse search 38 | * `C-x ` to split into `` windows 39 | * `C-x o` to switch between windows 40 | * `C-h` for help 41 | * `C-h r` for entire manual 42 | -------------------------------------------------------------------------------- /erlang/ch1.beam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/erlang/ch1.beam -------------------------------------------------------------------------------- /erlang/ch1.erl: -------------------------------------------------------------------------------- 1 | -module(ch1). 2 | % only exported functions are available outside module 3 | -export([factorial/1]). 4 | -export([area/1]). 5 | 6 | % Use pattern matching for choice 7 | factorial(0) -> 1; % note ; use for peicewise functions 8 | factorial(N) -> N * factorial(N - 1). 9 | 10 | % Use pattern matching for choice 11 | area({circle, Radius}) -> % Variables should start with uppercase letter 12 | 3.14 * Radius * Radius; 13 | area({square, Side}) -> % Tokens starting with lowercase letters are atoms 14 | Side * Side; 15 | area({rectangle, Length, Breadth}) -> 16 | Length * Breadth; 17 | area({triangle, A, B ,C}) -> 18 | S = (A + B + C) / 2, % use comma to perform sequencing 19 | math:sqrt(S * (S - A) * (S - B) * (S - C)). 20 | -------------------------------------------------------------------------------- /erlang/ch2.erl: -------------------------------------------------------------------------------- 1 | -module(ch2). 2 | -export() 3 | -------------------------------------------------------------------------------- /erlang/counter.beam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/erlang/counter.beam -------------------------------------------------------------------------------- /erlang/counter.erl: -------------------------------------------------------------------------------- 1 | -module(counter). 2 | -export([start/0, loop/1, increment/1, value/1, stop/1]). 3 | 4 | start() -> 5 | spawn(counter, loop, [0]). 6 | 7 | increment(Counter) -> 8 | Counter ! increment. 9 | 10 | value(Counter) -> 11 | Counter ! {self(), value}, 12 | receive 13 | {Counter, Value} -> 14 | Value 15 | end. 16 | 17 | stop(Counter) -> 18 | Counter ! stop. 19 | 20 | loop(Val) -> 21 | receive 22 | increment -> 23 | loop(Val + 1); 24 | {From, value} -> 25 | From ! {self(), Val}, 26 | loop(Val); 27 | stop -> 28 | true; 29 | _ -> 30 | loop(Val) 31 | end. 32 | -------------------------------------------------------------------------------- /erlang/echo.beam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/erlang/echo.beam -------------------------------------------------------------------------------- /erlang/echo.erl: -------------------------------------------------------------------------------- 1 | -module(echo). 2 | -export([start/0, loop/0]). % note [] usage for lists 3 | 4 | start() -> 5 | spawn(echo, loop, []). 6 | 7 | loop() -> 8 | receive 9 | {From, Message} -> 10 | From ! Message, 11 | loop() 12 | end. 13 | -------------------------------------------------------------------------------- /erlang/factorial.beam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/erlang/factorial.beam -------------------------------------------------------------------------------- /erlang/lists2.beam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/erlang/lists2.beam -------------------------------------------------------------------------------- /erlang/lists2.erl: -------------------------------------------------------------------------------- 1 | -module(lists2). 2 | -export([flat_length/1, flatten/1]). 3 | 4 | flat_length(List) -> 5 | flat_length(List, 0). 6 | 7 | % Unlike, say C, same name can be used for functions with different number 8 | % arguments 9 | flat_length([H | T], Acc) when is_list(H) -> % guards may NOT have new vars 10 | flat_length(H, flat_length(T, Acc)); 11 | flat_length([_ | T], Acc) -> 12 | flat_length(T, Acc + 1); 13 | flat_length([], Acc) -> Acc. 14 | 15 | flatten([H | T]) when is_list(H) -> 16 | flatten(H) ++ flatten(T); 17 | flatten([H | T]) -> 18 | [H] ++ flatten(T); 19 | flatten([]) -> []. 20 | 21 | 22 | -------------------------------------------------------------------------------- /erlang/number_analyser.erl: -------------------------------------------------------------------------------- 1 | -module(number_analyser). 2 | -export([start/0, server/1,add_number/2, analyse/1]). 3 | 4 | start() -> 5 | register(number_analyser, spawn(number_analyser, server, [nil])). 6 | 7 | add_number(Seq, Dest) -> 8 | request({add_number, Seq, Dest}). 9 | 10 | analyse(Seq) -> 11 | request({add_number, Seq}). 12 | 13 | request(Req) -> 14 | number_analyser ! {self(), Req}, 15 | receive 16 | {number_analyser, Reply} -> 17 | Reply 18 | end. 19 | 20 | server(AnalTable) -> 21 | receive 22 | {From, {analyse, Seq}} -> 23 | Result = lookup(Seq, AnalTable), 24 | From ! {number_analyser, ack}, 25 | server(AnalTable); 26 | {From, {add_number, Seq, Dest}} -> 27 | From ! {number_analyser, ack}, 28 | server(insert(Seq, Dest, AnalTable)) 29 | end. 30 | -------------------------------------------------------------------------------- /erlang/timer.erl: -------------------------------------------------------------------------------- 1 | -module(timer). 2 | -export([timeout/2, cancel/1, timer/3]). 3 | 4 | timeout(Time, Alarm) -> 5 | spawn(timer, timer, [self(), Time, Alarm]). 6 | 7 | timer(Pid, Time, Alarm) -> 8 | receive 9 | {Pid, cancel} -> 10 | true 11 | after Time -> 12 | Pid ! Alarm 13 | end. 14 | 15 | cancel(Timer) -> 16 | Timer ! {self(), cancel}. 17 | -------------------------------------------------------------------------------- /essentials-of-compilation.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on Essentials of Compilation 4 | --- 5 | 6 | # Registers and Calling Conventions 7 | 8 | - Spilling : pushing register values onto stack 9 | - Caller-saved registers : registers that caller saves before call to function, 10 | allowing the function to reuse these registers 11 | - Callee-saved registers : registers that callee restores before returning, 12 | allowing the caller to reuse these registers 13 | - For variables not in use during a function call, try in order 14 | 1. Put it in caller saved register 15 | 2. Put it in callee saved register 16 | 3. Spill it onto the stack 17 | - Graph coloring for register allocation 18 | 1. Vertices are variables 19 | 2. Edges indicate when to variables interfere (i.e. are needed at the same 20 | time) 21 | -------------------------------------------------------------------------------- /gabbay-thesis.md: -------------------------------------------------------------------------------- 1 | - This thesis is about inductive structures with alpha conversion 2 | - Inductive structure = 3 | + (Co)inductively defined sets 4 | + Data types 5 | + (Co)inductive "reasoning" over them 6 | - Inductive structure examples: CFGs, datatypes, circuits, natural numbers, 7 | operational semantics, typing judgements 8 | - Novel solution to the problem of abstract syntax with variable binding 9 | - ?? R4.3 10 | - Syntax = what we write it as, semantics = object in formal framework, 11 | denotation = entity in nature 12 | - 13 | -------------------------------------------------------------------------------- /gawk/1.md: -------------------------------------------------------------------------------- 1 | `awk` programs look like 2 | ``` 3 | pattern {action} 4 | pattern {action} 5 | ... 6 | ``` 7 | 8 | * Use `BEGIN` to execute statements without reading input 9 | * Use `END` to execute statements after all input has been read 10 | -------------------------------------------------------------------------------- /gawk/4.md: -------------------------------------------------------------------------------- 1 | * If input files are specified, awk reads them in order, processing all the data 2 | from one before going on to the next. 3 | * input -> record -> field 4 | * The predefined variable `FNR` keeps track of the number of records that have 5 | been read so far in current file 6 | * The predefined variable `NR` keeps track of the total number of input records 7 | read so far from all files 8 | * Records are separated by a character called the *record separator* (by default 9 | newline) 10 | * To use a different character for the record separator, assign that character 11 | to the predefined variable `RS`. The new record separator should be enclosed 12 | in quotation marks, indicating a string constant 13 | * The built-in variable `NF` is the number of fields in the current record 14 | * The empty string `""` means records that are separated by one or more blank 15 | lines and nothing else 16 | * `RS` can be any regular expression when using `gawk` 17 | * The general rule for record splitting is: each record ends at the beginning of 18 | the next matching string and the following record starts just after the end of 19 | this string. 20 | * `RT` contains the text that matched the regular expression. If the input file 21 | ends without any text matching `RS`, `gawk` sets RT to the null string 22 | -------------------------------------------------------------------------------- /git/chapter-1.md: -------------------------------------------------------------------------------- 1 | # Basics 2 | For every commit, Git takes a picture of all files at that moment and stores a 3 | reference to that snapshot. Git thinks (not really) about its data more like a 4 | stream of snapshots. 5 | 6 | Everything in Git is check-summed before it is stored and is then referred to by 7 | that checksum. Git uses SHA-1 for checksumming. 8 | 9 | Git has three main states that a file can reside in: committed, modified, and 10 | staged. Committed means that the data is safely stored in the local database. 11 | Modified means that the file has been changed but not committed to the local 12 | database yet. Staged means that a modified file has been marked in its current 13 | version to go into the next commit snapshot. 14 | 15 | The Git directory is where metadata and object database for the project are 16 | stored. The working directory is a single checkout of one version of the 17 | project. The staging area is a file that stores information about what will go 18 | into the next commit. 19 | -------------------------------------------------------------------------------- /git/chapter-5.md: -------------------------------------------------------------------------------- 1 | # Workflows 2 | * Centralized Workflow: One central hub, everyone synchronizes their work to it 3 | * Integration-Manager Workflow: "fork, change and merge" - GitHub 4 | * Dictator and Lieutenants: Heirarchial - Linux kernel 5 | 6 | # Small private team 7 | Each developer clones repo, makes changes, merges with master for any other 8 | changes occurred simultaneously and then pushes local changes 9 | ``` 10 | git clone https://github.com/iambrj/notes 11 | vim notes/git/chapter-6.md 12 | git commit -am "updated notes/git/chapter-6.md" 13 | git fetch origin 14 | git merge origin/master 15 | git push origin master 16 | ``` 17 | 18 | # Private managed team 19 | Each developer creates and works on branches and maintainers merge branches onto 20 | master 21 | ``` 22 | git clone https://github.com/iambrj 23 | git checkout -b chapter-6 24 | vim notes/git/chapter-6.md 25 | git commit -am "added chapter-6" 26 | git push -u origin chapter-6:chapter-six # push local's chapter-6 to server's chapter-six 27 | 28 | ``` 29 | 30 | # Forked public project 31 | Clone, makes changes on topic branch, fork, push changes to fork and pull 32 | request. 33 | 34 | Use `git request-pull` to create a summary of changes. 35 | 36 | # Public project over Email 37 | Use `git format-patch` to generate mbox-formatted files to email developer 38 | mailing lists requesting merges. Subject is the first line of the commit message 39 | 40 | # Maintainence 41 | 42 | Use `git apply filename.patch` to apply patches. 43 | 44 | To see if a patch applies cleanly before actually applying it, use `git apply 45 | --check filename.patch` 46 | 47 | To apply mbox patches, use `git am` 48 | ``` 49 | git am filename.patch 50 | ``` 51 | # Adding changes from a remote branch 52 | ``` 53 | git remote add (shortname) (url) 54 | git fetch (shortname) 55 | git checkout -b (local-branch) (shortname)/(remote-branch) 56 | ``` 57 | -------------------------------------------------------------------------------- /haskell/10.md: -------------------------------------------------------------------------------- 1 | * Use `do` operator to execute a sequence of actions in a particular order 2 | * Use `read` to convert from `String` to `Num` 3 | * Use `show` to convert from `Num` to `String` 4 | * Use `putStrLn` to print to output 5 | * Use `getLine` to get next line 6 | * Use left arrow `<-` operator to assign a name to a returned value. `<-` 7 | cannot be used in the last action. 8 | * A complete program is a big IO action. In a compiled program, this action is 9 | called `main` and has type `IO ()` - `IO` says that it does something with 10 | IO and `()` says that it has unit type, i.e., tuple with no elements 11 | ``` 12 | main = do 13 | putStrLn "The base?" 14 | x <- getLine 15 | putStrLn "The height?" 16 | y <- getLine 17 | let base = read x :: Double 18 | let height = read y :: Double 19 | putStrLn("The area of that triangle is " ++ show (0.5 * base * height)) 20 | ``` 21 | # Look out for... 22 | * `IO String` is different from `String` - `IO String` represents an action that 23 | will *give* a `String` when it's run. However, it *must* actually be run 24 | using the left arrow `<-` operator to get the `String` from `IO String` 25 | * Converse too - using non-actions where actions are expected. Use `return` to 26 | cast `t` to `IO t` 27 | -------------------------------------------------------------------------------- /haskell/12.md: -------------------------------------------------------------------------------- 1 | # Numeric recursion 2 | * Function application binds more tightly than anything else 3 | * Always list multiple function definitions starting with the most specific and 4 | proceeding to the most general 5 | # List recursion 6 | * Tip: base case usually involves an empty list, and the recursive case involves 7 | passing the tail of the list to the function again 8 | -------------------------------------------------------------------------------- /haskell/13.md: -------------------------------------------------------------------------------- 1 | * Defining functions with no argument variables is called *point-free* style 2 | ``` 3 | multiplyList Integer -> [Integer] -> [Integer] 4 | -- multiplyList definition -- 5 | 6 | doubleList [Integer] -> [Integer] 7 | doubleList = multiplyList 2 8 | ``` 9 | * Right arrow operator (`->`) is right associative, i.e. 10 | ``` 11 | a -> b -> c = a -> (b -> c) (and not (a -> b) -> c) 12 | ``` 13 | * *Currying* - creating intermediate functions when feeding arguments into a 14 | complex function 15 | # `map` function 16 | * Prelude has `map` which takes two arguments - a unary function and a list; it 17 | applies the function to every element of the list 18 | # Dot Dot Notation 19 | * Syntax: `[, .. ]` 20 | ``` 21 | [1..10] == [1,2,3,4,5,6,7,8,9,10] 22 | [2,4..10] == [2,4,6,8,10] 23 | [5,4..1] == [5,4,3,2,1] 24 | [1,3..10] = [1,3,5,7,9] 25 | ``` 26 | # Infinite Lists 27 | ``` 28 | [1..] 29 | evens = map ((*) 2) [1..] 30 | ``` 31 | # On head and tail 32 | * `:` is preferable over `head` and `tail` while splitting `List`s (as `head` 33 | and `tail` fail on empty lists) 34 | * `null :: [a] -> Bool` can be used to check if a given `List` is empty 35 | * `last` and `init` return the last element and a `List` with its last element 36 | removed (complements of `head` and `tail`). However, they also blow up with 37 | empty `List`s. 38 | -------------------------------------------------------------------------------- /haskell/15.md: -------------------------------------------------------------------------------- 1 | Haskell has three ways to declare a new type 2 | * `data` declaration, used to define new data types 3 | * `type` declaration, used to create type synonym 4 | * `newtype` declaration, used to define new data types equivalent to existing 5 | ones 6 | # `data` and constructor functions 7 | ``` 8 | data Anniversary = Birthday String Int Int Int -- name, year, month, day 9 | | Wedding String String Int Int Int -- spouse name 1, spouse name 2, year, month, day 10 | ``` 11 | * Types defined by `data` declarations are referred to as *algebraic data types* 12 | * Type names and constructor functions must start with capital letters 13 | * Constructors are called using their names 14 | ``` 15 | johnSmith :: Anniversary 16 | johnSmith = Birthday "John Smith" 1968 7 3 17 | 18 | smithWedding :: Anniversary 19 | smithWedding = Wedding "John Smith" "Jane Smith" 1987 3 4 20 | 21 | anniversariesOfJohnSmith :: [Anniversary] 22 | anniversariesOfJohnSmith = [johnSmith, smithWedding] 23 | ``` 24 | * General syntax 25 | ``` 26 | data [context =>] typename tv1 ... tvi = con1 c1t1 c1t2... c1tn | 27 | ... | conm cmt1 ... cmtq 28 | [deriving] 29 | ``` 30 | # Deconstructing types 31 | ``` 32 | showDate :: Int -> Int -> Int -> String 33 | showDate y m d = show y ++ "-" ++ show m ++ "-" ++ show d 34 | 35 | showAnniversary :: Aniversary -> String 36 | 37 | showAnniversary (Birthday name year month day) = 38 | name ++ "born "" showDate year month day 39 | 40 | showAnniversary (Wedding name1 name2 year month day) = 41 | name1 ++ " married " ++ name2 ++ " on " ++ showDate year month day 42 | ``` 43 | # `type` for making type synonyms 44 | ``` 45 | type Name = String 46 | ``` 47 | -------------------------------------------------------------------------------- /haskell/16.md: -------------------------------------------------------------------------------- 1 | * In pattern matching, we attempt to match values against patterns and, if so 2 | desired, bind variables to successful matches 3 | * Pattern matching gives us a way to 4 | - Recognize values (base case of recursion `[]`) 5 | - Bind variables (recursive case `(x:xs)`) 6 | - Break down values into parts (recursive case `(x:xs)`) 7 | * Only functions allowed in pattern matching are *constructors* - functions used 8 | to build algebraic data types 9 | # As-patterns 10 | * As-patterns are a form of `var@pattern` and bind the name `var` to the whole 11 | value being matched by `pattern` 12 | ``` 13 | contrivedMap :: ([a] -> a -> b) -> [a] -> [b] 14 | contrivedMap f [] = [] 15 | contrivedMap f list@(x:xs) = f list x : contrivedMap f xs 16 | ``` 17 | # Records 18 | * For constructors with many elements, *records* provide a way of naming values 19 | in a datatype using the following syntax 20 | ``` 21 | data Foo2 = Bar2 | Baz2 {bazNumber :: Int, bazName :: String} 22 | h :: Foo2 -> Int 23 | h Baz2 {bazName=name} = length name 24 | h Bar2 {} = 0 25 | x = Baz2 1 "Haskell" 26 | y = Baz2 {bazName = "Curry", bazNumber = 2} 27 | h x -- 7 28 | h y -- 5 29 | ``` 30 | # Pattern matching applications 31 | * Gist - *wherever you can bind variables* 32 | * Equations 33 | * Lambdas 34 | * List comprehensions 35 | * `do` blocks 36 | -------------------------------------------------------------------------------- /haskell/17.md: -------------------------------------------------------------------------------- 1 | * In Haskell, `if` is an expression (which is converted to a value) and not a 2 | statement (which is executed) as in many imperative languages. 3 | * Multiline `if` expressions are indented by aligning `else`s with `then`s, 4 | rather than with `if`s 5 | ``` 6 | describeLetter :: Char -> String 7 | describeLetter c = 8 | if c >= 'a' && c <= 'z' 9 | then "Lower case" 10 | else if c >= 'A' && c <= 'Z' 11 | then "Upper case" 12 | else "Not ASCII letter" 13 | ``` 14 | * `case` expressions are to piece-wise function definitions what `if` 15 | expressions are to guards 16 | ``` 17 | f 0 = 18 18 | f 1 = 15 19 | f 2 = 12 20 | f x = 12 - x 21 | ``` 22 | This is equivalent to (and in fact syntactic sugar for) 23 | ``` 24 | f x = 25 | case x of 26 | 0 -> 18 27 | 1 -> 15 28 | 2 -> 12 29 | _ -> 12 - x 30 | ``` 31 | * Left hand side of any case branch is just a pattern, it can also be used for 32 | binding 33 | ``` 34 | describeString :: String -> String 35 | describeString str = 36 | case str of 37 | (x:xs) -> "First char = " ++ [x] 38 | [] -> "Empty string" 39 | ``` 40 | * `case` expressions can be embedded anywhere another expression would fit 41 | * Sections can be used to convert operators to functions 42 | ``` 43 | (2+) 4 44 | (+4) 1 45 | ``` 46 | -------------------------------------------------------------------------------- /haskell/18.md: -------------------------------------------------------------------------------- 1 | * `let ... in` construct is an expression, but `where` clauses are guards 2 | * `where` clauses *can* incorporated into `case` expressions, even though they 3 | are not full expressions 4 | ``` 5 | describeColour c = 6 | "This colour " 7 | ++ case c of 8 | Black -> "is black" 9 | White -> "is white" 10 | RGB red green blue -> " has an average of the components of " ++ show 11 | av 12 | where av = (red + green + blue) `div` 3 -- note indent scopes to RGB 13 | ++ ", yeah?" 14 | ``` 15 | * New operators can be defined in the usual way as other functions - just don't 16 | use any alphanumeric characters in their names 17 | ``` 18 | {- New operator to find the set difference -} 19 | (\\) :: (Eq a) => [a] -> [a] -> [a] 20 | xs \\ ys = foldl (\ zs y -> delete y zs) xs ys 21 | ``` 22 | * To use functions in infix form, surround their names with backticks 23 | ``` 24 | elem 1 [1..4] 25 | 1 `elem` [1..4] 26 | ``` 27 | -------------------------------------------------------------------------------- /haskell/19.md: -------------------------------------------------------------------------------- 1 | * Quicksort 2 | ``` 3 | quickSort :: (Ord a) => [a] -> [a] 4 | 5 | quickSort [] = [] 6 | 7 | quickSort (x : xs) = (quickSort less) ++ (x : equal) ++ (quickSort more) 8 | where 9 | less = filter (< x) xs 10 | equal = filter (== x) xs 11 | more = filter (> x) xs 12 | ``` 13 | * Quicksort using custom comparison function 14 | ``` 15 | quickSort' :: (Ord a) => (a -> a -> Ordering) -> [a] -> [a] 16 | 17 | quickSort' _ [] = [] 18 | 19 | quickSort' c (x:xs) = (quickSort' c less) ++ (x : equal) ++ (quickSort' c more) 20 | where 21 | less = filter (\ y -> y `c` x == LT) xs 22 | equal = filter (\ y -> y `c` x == EQ) xs 23 | more = filter (\ y -> y `c` x == GT) xs 24 | ``` 25 | * `flip` - takes a function of two arguments and returns a version of the same 26 | function with arguments swapped 27 | * `$` - takes a function and applies it to its second argument 28 | * `uncurry` - takes a function of two arguments and returns a function that 29 | takes a pair as its only argument 30 | * `curry` - takes a function that takes a pair as an argument and returns a 31 | curried function 32 | * `id` - identity function, returns its argument unchanged 33 | * `const` - takes two arguments, discards the second and returns the first 34 | -------------------------------------------------------------------------------- /haskell/20.md: -------------------------------------------------------------------------------- 1 | * `:` commands 2 | - `:h`/`:help` - prints a list of all available commands 3 | - `:l`/`:load` - loads a file int GHCi 4 | - `:r`/`:reload` - reloads whatever file has been loaded most recently 5 | - `:t`/`:type` - prints the type of a given expression 6 | - `:m`/`:module` - loads a given module 7 | - `:browse` - gives the type signatures for all functions available from a 8 | given module 9 | * `:set +s` - get the runtime of a function 10 | * Delimit multi-line code with `:{` and `:}` or `:set +m`(empty line ends the 11 | block) or use `;` to separate line breaks 12 | -------------------------------------------------------------------------------- /haskell/22.md: -------------------------------------------------------------------------------- 1 | # Modules 2 | * Modules are used to group a set of related functionalities into a single 3 | package and manage different functions that may have the same names 4 | ``` 5 | module ModuleName where 6 | ``` 7 | 1. Name of the module begins with a capital letter 8 | 2. Each file contains only one module 9 | 3. The name of the file is the name of the module plus the `.hs` file extension 10 | 4. Any dots `.` in the module name are changed for directories 11 | # Importing 12 | ``` 13 | import Data.Char (toUpper, toLower) -- import only the functions toLower and toUpper from Data.Char 14 | import Data.List -- import everything form Data.List 15 | ``` 16 | * Use `qualified` to prefix all imported names with module name 17 | * Use `hide` to hide certain names from an import 18 | ``` 19 | import MyModule 20 | import MyOtherModule -- both have remove_e 21 | 22 | import qualified MyModule 23 | import qualified MyOtherModule 24 | MyModule.remove_e != MyOtherModule.remove_e 25 | 26 | import MyModule hiding (remove_e, remove_f) 27 | import MyOtherModule 28 | ``` 29 | * Use `as` to create synonyms 30 | ``` 31 | import qualified MyModuleWithLongModuleName as Shorty 32 | ``` 33 | # Exporting 34 | ``` 35 | module MyModule (remove_e, add_two) where 36 | 37 | add_one blah = blah + 1 38 | 39 | remove_e text = filter (/= 'e') text 40 | 41 | add_two blah = add_one . add_one $ blah 42 | ``` 43 | * Only `add_two` and `remove_e` are exported, `add_one` is internal to the 44 | module 45 | -------------------------------------------------------------------------------- /haskell/23.md: -------------------------------------------------------------------------------- 1 | # Golden rule 2 | * **Code which is part of some expression should be indented further in than the 3 | beginning of that expression** 4 | * All *grouped* expressions must be exactly aligned 5 | * Use bracket and semi-colon instead of indents 6 | ``` 7 | foo :: Double -> Double 8 | foo x = 9 | let s = sin x 10 | c = cos x 11 | in 2 * s * c 12 | 13 | foo :: Double -> Double 14 | foo x = let { 15 | s = sin x; 16 | c = cos x; 17 | } in 2 * s * c 18 | ``` 19 | -------------------------------------------------------------------------------- /haskell/24.md: -------------------------------------------------------------------------------- 1 | * An *enumeration* is where none of the constructor functions have any arguments 2 | ``` 3 | data Month = January 4 | | February 5 | | March 6 | | April 7 | | May 8 | | June 9 | | July 10 | | August 11 | | September 12 | | October 13 | | Novemeber 14 | | December 15 | ``` 16 | # Records 17 | ``` 18 | data Configuration = Configuration 19 | { 20 | username :: String, 21 | localHost :: String, 22 | remoteHost :: String, 23 | isGuest :: Bool, 24 | isSuperuser :: Bool, 25 | curDir :: String, 26 | homeDir :: String, 27 | timeConnected :: Integer 28 | } 29 | ``` 30 | This will automatically generate accessor functions 31 | ``` 32 | username :: Configuration -> String 33 | localHost :: Configuration -> String 34 | -- etc 35 | ``` 36 | * To update field `x` in a value `y` to `z` and field `a` to `b`, `y {x = z, a 37 | = b}` 38 | # Parameterized types 39 | * A parameterized type can be thought of as a function at the type level - it 40 | takes types as parameters and returns a type. 41 | * A parameterized type takes one or more type parameters 42 | ``` 43 | data Maybe a = Nothing | Just a 44 | ``` 45 | * Multi type parameter example 46 | ``` 47 | data Either a b = Left a | Right b 48 | 49 | pairOff :: Int -> Either String Int 50 | pairOff people 51 | | people < 0 = Left "Can't pair off negative number of people" 52 | | people > 0 = Left "Too many people for this activity" 53 | | even people = Right (people `div` 2) 54 | | otherwise = Left "Can't pair off an odd number of people" 55 | ``` 56 | -------------------------------------------------------------------------------- /haskell/25.md: -------------------------------------------------------------------------------- 1 | * Pattern matching happens on constructor functions 2 | # `map` for trees 3 | ``` 4 | data Tree a = Leaf a | Branch (Tree a) (Tree a) deriving (Show) 5 | 6 | treeMap :: (a -> b) -> Tree a -> Tree b 7 | treeMap f (Leaf x) = Leaf (f x) 8 | treeMap f (Branch left right) = Branch (treeMap f left) (treeMap f right) 9 | 10 | {- elegance -} 11 | treeMap :: (a -> b) -> Tree a -> Tree b 12 | treeMap f = g where 13 | g (Leaf x) = Leaf (f x) 14 | g (Branch left right) = Branch (g left) (g right) 15 | ``` 16 | # `fold` for trees 17 | ``` 18 | treeFold :: (b -> b -> b) -> (a -> b) -> Tree a -> b 19 | ``` 20 | * First argument - what to do with subtrees 21 | * Second argument - what to do with leaves 22 | * Third argument - actual tree 23 | ``` 24 | treeFold :: (b -> b -> b) -> (a -> b) -> Tree a -> b 25 | treeFold fbranch fleaf = g where 26 | g (Leaf x) = fleaf x 27 | g (Branch left right) = fbranch (g left) (g right) 28 | ``` 29 | # Catamorphism 30 | -------------------------------------------------------------------------------- /haskell/27.md: -------------------------------------------------------------------------------- 1 | * `Functor` is Prelude class for types which can be mapped over. It has a single 2 | method called `fmap` 3 | ``` 4 | class Functor f where 5 | fmap :: (a -> b) -> f a -> f b 6 | 7 | instance Functor Maybe where 8 | fmap f Nothing = Nothing 9 | fmap f (Just x) = Just (f x) 10 | ``` 11 | # Intuition 12 | * Functor is a container (list, tree, set etc) of elements of type `a` 13 | * `fmap` takes a function that maps elements of type `a` to elements of type `b` 14 | and applies this function to every element of a functor of elements of type 15 | `a`, thus returning a functor of elements of type `b` 16 | * `fmap` is a generalization of `map` for any parametrized data type 17 | # Laws 18 | 1. Identity 19 | ``` 20 | fmap id = id 21 | ``` 22 | 2. Function distribution 23 | ``` 24 | fmap (f . g) = (fmap f) . (fmap g) 25 | ``` 26 | -------------------------------------------------------------------------------- /haskell/35.md: -------------------------------------------------------------------------------- 1 | # Notes on state monad 2 | 3 | * Intuition: Perform stateful computation and return value with new state 4 | * Definition: 5 | 6 | ``` 7 | -- s is type of state and a is type of result 8 | newtype State s a = State { runState :: s -> (a,s) } 9 | instance Monad (State s) where 10 | return x = state (\s -> (x,s)) 11 | p >>= q = state (\s -> let (val, newState) = runState p s 12 | b = q val 13 | in runState b newState) 14 | 15 | ``` 16 | 17 | * Example: 18 | 19 | ``` 20 | import Control.Monad.State 21 | 22 | pop :: State Stack Int 23 | pop = state $ \(x:xs) -> (x,xs) 24 | 25 | push :: Int -> State Stack () 26 | push a = state $ \xs -> ((),a:xs) 27 | ``` 28 | 29 | * Related functions 30 | 31 | ``` 32 | runState :: State s a -> s -> (a, s) 33 | state :: MonadStaet s m => (s -> (a, s)) -> m a 34 | put :: MonadState s m => s -> m () 35 | get :: MonadState s m => m s 36 | evalState :: State s a -> s -> a 37 | execState :: State s a -> s -> s 38 | ``` 39 | -------------------------------------------------------------------------------- /haskell/36.md: -------------------------------------------------------------------------------- 1 | # Alternative 2 | 3 | * Intuition: Ability to combine multiple computations 4 | * Definition: 5 | ``` 6 | class Applicative f => Alternative f where 7 | empty :: f a 8 | (<|>) :: f a -> f a -> f a 9 | ``` 10 | * Examples: 11 | ``` 12 | instance Alternative Maybe where 13 | empty = Nothing 14 | Nothing <|> Nothing = Nothing 15 | Nothing <|> Just x = Just x 16 | Just x <|> Nothing = Just x 17 | Just x <|> Just y = Just x 18 | 19 | instance Alternative List where 20 | empty = [] 21 | (<|>) = (++) 22 | 23 | digit :: Int -> [String] -> Maybe Int 24 | digit _ [] = Nothing 25 | digit n (h : _) 26 | | (n < 0 || n > 9) = Nothing 27 | | otherwise = do 28 | if [h] == show n then Just n else Nothing 29 | 30 | -- Use Alternative to run parsers in parallel and read binary strings 31 | binChar :: String -> Maybe Int 32 | binChar s = digit 0 s <|> digit 1 s 33 | ``` 34 | 35 | * Laws 36 | 37 | Alternative 38 | ``` 39 | empty <|> u = u 40 | u <|> empty = u 41 | u <|> (v <|> w) = (u <|> v) <|> w 42 | ``` 43 | 44 | MonadPlus 45 | ``` 46 | mzero `mplus` m = m 47 | m `mplus` mzero = m 48 | m `mplus` (n `mplus` o) = (m `mplus` n) `mplus` o 49 | mzero >>= f = mzero -- left zero 50 | m >> mzero = mzero -- right zero 51 | ``` 52 | 53 | 54 | * Related functions 55 | ``` 56 | asum :: (Alternative f, Foldable t) => t (f a) -> f a 57 | asum = foldr (<|>) empty 58 | 59 | guard :: Alternative m => Bool -> m () 60 | guard True = pure () 61 | guard False = empty 62 | ``` 63 | -------------------------------------------------------------------------------- /haskell/37.md: -------------------------------------------------------------------------------- 1 | # Monad transformers 2 | * Key idea - combine functionalities provided by different monads into a single 3 | monad 4 | * Example 5 | ``` 6 | newtype MaybeTransformer m a = MaybeTransformer { runMaybeTrans :: m (Maybe a) } 7 | 8 | instance Monad m => Monad (MaybeTransformer m) where 9 | return = MaybeTransformer . return . Just 10 | 11 | x >>= f = MaybeTransformer $ do maybe_val <- runMaybeTrans x 12 | case maybe_val of 13 | Nothing -> return Nothing 14 | Just value -> runMaybeTrans $ f value 15 | 16 | getPassword :: MaybeTransformer IO String 17 | getPassword = do s <- lift getLine 18 | guard (isValid s) 19 | return s 20 | 21 | askPassword :: MaybeTransformer IO () 22 | askPassword = do lift $ putStrLn "Enter new password: " 23 | value <- msum $ repeat getPassword 24 | lift $ putStrLn "Saving in db" 25 | ``` 26 | 27 | # Lifting 28 | * Key idea - lift/bring/promote base monad computation into combined monad 29 | computation 30 | -------------------------------------------------------------------------------- /haskell/4.md: -------------------------------------------------------------------------------- 1 | # Infix notation 2 | ``` 3 | > 4 + 3 == 7 4 | True 5 | ``` 6 | and 7 | ``` 8 | > (==) (4 + 3) 7 9 | ``` 10 | are equivalent 11 | 12 | # Guards 13 | Guards are a way of testing whether some property of a value (or several of 14 | them) are true or false 15 | ``` 16 | mod x 17 | | x < 0 = 0 - x 18 | | otherwise = x -- Syntactic sugar for true 19 | ``` 20 | ## Syntax 21 | ``` 22 | function parameters 23 | | condition1 = expression1 24 | | condition2 = expression2 25 | ... 26 | | conditionn = expressionn 27 | | otherwise = default 28 | ``` 29 | # Mixing pattern matching with guards 30 | ``` 31 | accumulate_list' :: (Eq a, Num a) => [a] -> ( a -> a -> a ) -> a 32 | accumulate_list' l f 33 | | [] <- l = 0 --pattern for the empty list case 34 | | 10 < 5 = 10 --arbitrary regular guard just because 35 | | (x:xs) <- l = undefined --pattern for the non-empty case 36 | ``` 37 | 38 | # `where` clause 39 | ``` 40 | numOfRealSolutions a b c 41 | | disc > 0 = 2 42 | | disc == 0 = 1 43 | | disc < 0 = 0 44 | where 45 | disc = b ^ 2 - 4 * a * c 46 | ``` 47 | -------------------------------------------------------------------------------- /haskell/5.md: -------------------------------------------------------------------------------- 1 | * All type names begin with an uppercase letter 2 | * Use `:type ` to find out the type of the expression while running in the 3 | interactive mode. 4 | * Type synonyms are alternative names to refer to the same types, ex `String` & 5 | `[Char]` 6 | * Function signatures are specified using `::`, for example `xor :: Bool -> Bool -> Bool` 7 | -------------------------------------------------------------------------------- /haskell/6.md: -------------------------------------------------------------------------------- 1 | # Lists 2 | * Square brackets delimit the list, and individual elements are separated by 3 | commas. All elements of a list must be of the same type. 4 | ``` 5 | let numbers = [1,2,3,4] 6 | ``` 7 | ## Consing 8 | * Lists can be built up piece by piece using the `:` operator (cons, from LISP). 9 | Syntax:`something:someList`. It evaluates from right to left. Haskell builds 10 | all lists this way, `[]` is syntactic sugar. Lists cannot be consed onto an 11 | element. 12 | ``` 13 | let numbers = [1,2,3,4] 14 | 0:numbers 15 | >> [0,1,2,3,4] 16 | ``` 17 | * Strings are just `List`s of characters. `" "` notation is just syntactic sugar 18 | for multiple `:` operators. 19 | * Use the `++` operator to concatenate two `List`s 20 | ``` 21 | [1,2] ++ [3,4] 22 | >> [1,2,3,4] 23 | ``` 24 | # Tuple 25 | * Tuples are marked by `()` and delimited by `,` 26 | * Tuples cannot be consed - they are immutable 27 | ``` 28 | (1, "Bharath", True) 29 | ``` 30 | # Retrieving 31 | * Use `fst` to get first element of a pair. 32 | * Use `snd` to get second element of a pair. 33 | * Use `head` to get first element of a list. 34 | * Use `tail` to get rest of the list. 35 | * `head` and `tail` __crash__ on empty lists. 36 | * Rule of thumb: avoid functions that might fail without warning. 37 | -------------------------------------------------------------------------------- /haskell/7.md: -------------------------------------------------------------------------------- 1 | # Numeric types 2 | Most important numeric types are 3 | * `Int`: -2^64 to (2^64 - 1) on a 64 bit computer 4 | * `Integer`: arbitrarily long values - at the cost of efficiency 5 | * `Double`: double precision floating point type 6 | * Use `fromIntegral` to promote an integral type (`Int` or `Integer`) to a `Num` 7 | type 8 | -------------------------------------------------------------------------------- /haskell/8.md: -------------------------------------------------------------------------------- 1 | # Function composition 2 | * Function composition is applying one function to a value and then applying 3 | another function to the result. 4 | * Functions can be composed using the `.` - function composition operator 5 | ``` 6 | squareOfF x = (square . f) x 7 | fOfSquare x = (f . square) x 8 | ``` 9 | # Prelude and the libraries 10 | * Prelude is the core library loaded by default in every every Haskell program. 11 | * Use `import` keyword to import modules into current program. 12 | ## Prelude functions for `String`s 13 | * `words` - breaks down a string in whitespace delimited words, returning a list 14 | of `String`s 15 | * `reverse` - reverses a list 16 | * `unwords` - does opposite of words 17 | -------------------------------------------------------------------------------- /haskell/9.md: -------------------------------------------------------------------------------- 1 | # `if ... then ... else` 2 | * Both `then` and `else` clauses are required, furthermore both of them should 3 | evaluate to the same type 4 | ``` 5 | mySignum x = 6 | if x < 0 7 | then -1 8 | else if x > 0 9 | then 1 10 | else 0 11 | ``` 12 | # Pattern matching 13 | ## Piece-wise definition 14 | ``` 15 | pts :: Int -> Int 16 | pts 1 = 10 17 | pts 2 = 6 18 | pts 3 = 4 19 | pts 4 = 3 20 | pts 5 = 2 21 | pts 6 = 1 22 | pts _ = 0 -- Note use of _ wildcard -- 23 | ``` 24 | ## Things to watch out for 25 | * Shadowing - patterns for specific matches should come before general ones 26 | * Have patterns to cover all cases - like `otherwise` with gaurds 27 | * Use pattern matching to extract elements from tuples 28 | ``` 29 | fst' :: (a, b) -> a 30 | fst' (x, _) = x 31 | snd' :: (a, b) -> b 32 | snd`(_, x) = x 33 | ``` 34 | and lists 35 | ``` 36 | head' :: [a] -> a 37 | head' (x:_) = x 38 | head' [] = error "Prelude.head: empty list" 39 | tail' :: [a] -> [a] 40 | tail' (_:x) = x 41 | tail[] = error "Prelude.tail: empty list" 42 | ``` 43 | # `let` binding 44 | * Syntax: `let = in ` 45 | -------------------------------------------------------------------------------- /haskell/README.md: -------------------------------------------------------------------------------- 1 | 1 Getting set up 2 | 3 | 2 Variables and functions 4 | 5 | 3 Truth values 6 | 7 | 4 Type basics 8 | 9 | 5 Lists and tuples 10 | 11 | 6 Type basics II 12 | 13 | 7 Next steps 14 | 15 | 8 Building vocabulary 16 | 17 | 10 Simple input and output 18 | 19 | 12 Recursion 20 | 21 | 13 Lists II (map) 22 | 23 | 14 Lists III (folds, comprehensions) 24 | 25 | 15 Type declarations 26 | 27 | 16 Pattern matching 28 | 29 | 17 Control structures 30 | 31 | 18 More on functions 32 | 33 | 19 Higher-order functions 34 | 35 | 20 Using GHCi effectively 36 | 37 | 22 Modules 38 | 39 | 23 Indentation 40 | 41 | 24 More on datatypes 42 | 43 | 25 Other data structures 44 | 45 | 26 Classes and types 46 | 47 | 27 The Functor class 48 | 49 | 29 Prologue: IO, an applicative functor 50 | 51 | 30 Understanding monads 52 | -------------------------------------------------------------------------------- /haskell/monad.hs: -------------------------------------------------------------------------------- 1 | data TrivialMonad a = TrivialWrapper a deriving Show 2 | 3 | {- Wrap a value -} 4 | return :: a -> TrivialMonad a 5 | return x = TrivialWrapper x 6 | 7 | {- Apply a function to a wrapped value -} 8 | fmap :: (a -> b) -> TrivialMonad a -> TrivialMonad b 9 | fmap f (TrivialWrapper x) = TrivialWrapper (f x) 10 | 11 | {- Apply a function after unwrapping a wrapped value -} 12 | bind :: TrivialMonad a -> (a -> TrivialMonad b) -> TrivialMonad b 13 | bind (TrivialWrapper x) f = f x 14 | 15 | {- Exercise 1 -} 16 | {- g x (TrivialWrapper y) = TrivialWrapper (x + y) -} 17 | g :: Int -> TrivialMonad Int -> TrivialMonad Int 18 | {-g x y = Main.fmap (+ x) y-} 19 | g x y = bind y (Main.return . (+ x)) 20 | 21 | 22 | {- Exercise 2 -} 23 | {- h (TrivialMonad x) (TrivialMonad y) = TrivialMonad (x + y)-} 24 | {- h :: TrivialMonad Int -> TrivialMonad Int -> TrivialMonad Int -} 25 | h x y = bind x (\x -> g x y) 26 | -------------------------------------------------------------------------------- /haskell/typeclassopedia.md: -------------------------------------------------------------------------------- 1 | # Functor 2 | ## Definition 3 | ``` 4 | class Functor f where 5 | fmap :: (a -> b) -> f a -> f b 6 | 7 | (<$) :: a -> f b -> f a 8 | (<$) = fmap . const 9 | ``` 10 | ## Laws 11 | ``` 12 | fmap id = id 13 | fmap (g . h) = (fmap g) . (fmap h) 14 | ``` 15 | # Applicative 16 | ## Definition 17 | ``` 18 | class Functor f => Applicative f where 19 | pure :: a -> f a 20 | infixl 4 <*>, *>, <* 21 | (<*>) :: f (a -> b) -> f a -> f b 22 | 23 | (*>) :: f a -> f b -> f b 24 | a1 *> a2 = (id <$ a1) <*> a2 25 | 26 | (<*) :: f a -> f b -> f a 27 | (<*) = liftA2 const 28 | ``` 29 | ## Laws 30 | ``` 31 | pure id <*> v = v -- identity 32 | pure f <*> pure x = pure (f x) -- homomorphism 33 | u <*> pure y = pure ($ y) <*> u -- interchange 34 | u <*> (v <*> w) = pure (.) <*> u <*> v <*> w -- composition 35 | ``` 36 | # Monad 37 | ## evalParser 38 | evalParser 39 | class Applicative m => Monad m where 40 | return :: a -> m a 41 | (>>=) :: m a -> (a -> m b) -> m b 42 | (>>) :: m a -> m b -> m b 43 | m >> n = m >>= \_ -> n 44 | 45 | fail :: String -> getNextChar getNextChar 46 | ``` 47 | ## Laws 48 | ``` 49 | return a >>= k = k a 50 | m >>= return = m 51 | m >>= (\x -> k x >>= h) = (m >>= k) >>= h [(c,cs)] 52 | ``` 53 | 54 | bind :: Parser a -> (a -> Parser b) -> (Parser b) 55 | bind p f = Parser $ \s -> concatMap (\(a, s') -> parse (f a) s') $ parse p s 56 | 57 | unit :: a -> Parser a 58 | unit a = Parser (\s -> [(a, s)] 59 | ) 60 | instance Functor Parser where 61 | fmap f (Parser cs) = Parser (\s -> [(f a, b) | (a, b) <- cs s]) 62 | 63 | insta App Parser where 64 | pure = return 65 | (Pa cs1) <*> (Pa cs2) = Pa (\s -> [(f a, s2) | (f, s1) <- cs1 s, (a, s2) 66 | <- cs2 s1]) 67 | 68 | instance Monad Pa where 69 | return = unit 70 | (>>=) = bind 71 | -------------------------------------------------------------------------------- /how-to-solve-it/checklist.md: -------------------------------------------------------------------------------- 1 | # Understanding the problem 2 | * What is the unknown? 3 | * What are the data? 4 | * What is the condition? 5 | # Devising a plan 6 | * Have you seen it before? 7 | * Do you know a related problem? 8 | * A more general problem? 9 | * A more special problem? 10 | # Carrying out the plan 11 | * Check each step - can you prove that each step is correct? 12 | # Looking back 13 | * Can you verify the result? 14 | -------------------------------------------------------------------------------- /hyderabad-course/classical-urdu-literature.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : Notes on Classical Urdu Literature 4 | --- 5 | 6 | # Guidelines to reading 7 | 8 | - Pay attention to evolution of Dakhni 9 | - Read critically 10 | 11 | - nastaliq - hanging style calligraphy 12 | - Urdu literature has close connections to Persian heritage, due to Turco-Mongolian immigrants 13 | - Poetry mostly developed in courts of rulers in Muslim India, as in Iran. Poets 14 | imitated Iran genres, including 15 | 1. Monorhymes/Qasidas : all the lines have the same end rhyme. Used to sing 16 | about course personalities, prophets, saints 17 | It came in a winter’s night, 18 | a fierce cold with quite a bite. 19 | Frosted wind with all its might 20 | sent ice and snow an invite 21 | to layer earth in pure white 22 | and glisten with morning light. 23 | 2. Mathnawi : romantic narratives about heroic adventures, amorous legends. 24 | Usually 11, rarely 10 meter couplets. No limit on couplets 25 | 3. Rubai : 4 line poem with lyrical/philosophical contents 26 | 4. Ghazals : 5-15 couplet poem, all couplets have same rhyming pattern and 27 | same meter, written for their own pleasure 28 | 5. Qitas 29 | 6. Tarih 30 | 31 | ## 12th - 14th centuries 32 | 33 | - Hindawi : Parakit derivative mixed with Afghan, Persian and Arabic 34 | - Husrau Turk-e-Hindustani, father Turk and mother Hindustani, love for 35 | Hindustan in his works. Founder of hindustani music 36 | - Urdu developed out of classical Persian poetry and Indian (Sanskrit in 37 | particular) tradition. Urdu gaps the bridge between the two. 38 | 39 | ## 15th - 17th centuries 40 | 41 | - Sultan Muhammad ibn Tugluq transfer power from Delhi to Deogir/Daulatabad, 42 | develop Urdu in South 43 | - Served as ideal breeding ground for Dakhni (Persian + Gujrati + Telugu), due 44 | to local patriotism since relatively untouched from invasions being inner land 45 | - Gisudaraz : mystic poet 46 | - Sunni vs Shia, Sufi 47 | + Sunni : Devotion to Father in law 48 | + Shia : Devotion to Son in law 49 | + Sufi : Mystics with religious tolerance 50 | - 51 | -------------------------------------------------------------------------------- /hyderabad-course/verse-translations.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : "Notes on : Verse translations on Dakhni poetry" 3 | author : Bharathi Ramana Joshi 4 | --- 5 | 6 | # General questions 7 | 8 | - Why not broken down into words? Extremely difficult to read 9 | - Why no titles? 10 | - How are these Ghazals when they break the AA, BA, CA ... rhyme scheme? 11 | - Comment on location 12 | 13 | # 34 14 | 15 | 1. Rakhiyaa kam sahanskrut ke isme bol 16 | adek bolnete rkhiya hoon amol 17 | 2. jise pharasee ka nkuch gnaan hai 18 | so dkhnee zabham usko aasaan hai 19 | 3. so ismei sahanskrut ka hai muraad 20 | keyaa iste aasaangee kaa svaad 21 | 4. keyaa iste dkhnee mei aassaan kar 22 | jo zahir desei is mei kaee kaee hunar 23 | 24 | 1. रखिया कम सहनस्कृत के इस में बोल I have restricted the use of Sanskrit words, 25 | अदिक बोलनेते रखिया हुं अमोल And made it free of unneccesary talk. 26 | 27 | 2. जिसे फ़ारसी का न कुछ ज्ञान है Those who have no knowledge of Persian; 28 | सो दखनी ज़बाँ उस को आसान है For them Dakhni is a readily understoond language. 29 | 30 | 3. सो इस में सहनस्कृत का है मुराद My writings contain the essence of Sanskrit, 31 | किया इस्ते आसानगीका स्वाद Which makes them sweet and simple. 32 | 33 | 4. किया इस्ते दखनी में आसान कर I have made it simple and rendered into Dakhni, 34 | जो ज़ाहिर दिसें इस में कई कई हुनर So that its numerous inherent flairs are apparent. 35 | 36 | ## Rhyme scheme 37 | - AA, BB, CC, DD 38 | - Mixing of languages characteristic of Deccan 39 | - Appeal to both Muslim rulers and local patriotism 40 | - Philology 41 | 42 | # 40 43 | 44 | 1. वोकि कुश्किल अछे 45 | 46 | - Romantic undertones, which is characteristic of Wajhi 47 | - Colloquial 48 | - Rich symbolism 49 | 50 | # 44 51 | 52 | - Praising his native land, patriotism 53 | - Borrows 54 | 55 | 1. दखनसा नहीं ठार संसार में 56 | पुन जफ़ा ज़िलाँ का है इस सठार में 57 | 58 | 2. दखन है नगीना उंगठी है जान 59 | 60 | # 45 61 | 62 | - Epic poetry 63 | 64 | # 62 65 | # 75 -------------------------------------------------------------------------------- /iiit-ethics.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: 'Lectures notes for the Basics of Ethics course, IIIT Hyderbad Monsoon 2021' 4 | --- 5 | 6 | # Lecture 1, 17/08/2021 7 | - Grading 8 | * 10% class participation 9 | * 75% assignments x 4 10 | * 15% essay/final-assignment 11 | - Don't assume anything. 12 | - 13 | -------------------------------------------------------------------------------- /iiit-ire.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: 'Lectures notes for the Information Retrieval and Extraction course, IIIT Hyderbad Monsoon 2021' 4 | --- 5 | 6 | # Lecture 1, 17/08/2021 7 | # Lecture 2, 20/08/2021 8 | # Lecture 3, 24/08/2021 9 | -------------------------------------------------------------------------------- /iiit-math-for-bio.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: 'Lectures notes for the Mathematical Models in Biology course, IIIT Hyderbad Monsoon 2021' 4 | --- 5 | 6 | # Lecture 1 : 17/08/2021 7 | 8 | - Model exploits math to represent, analyze or make predictions about real world 9 | phenomenon. 10 | - Models as "replica" of real-life systems. 11 | - Mathematical models as differential equations. 12 | - Why need modelling? 13 | 1. Infeasible experiments. 14 | 2. Complicated results that are difficult to comprehend. 15 | - Uses of models 16 | * Gives physical explanation of a phenomenon. 17 | * Helps make predictions. 18 | * Helps build hypothesis. 19 | - Biological processes are not static. 20 | - Dynamical systems: systems changing with times. Examples: 21 | 1. COVID modelling. 22 | 2. Number of predators and preys in ecosystem. 23 | 3. Infections disease modelling. 24 | 4. Gene expansion (transcription, translation). 25 | 5. Signal transduction. 26 | 6. Growth of bacteria in a fermenter. 27 | 7. Sleep cycle. 28 | 29 | ## Differential equations 30 | - Order of a differential equation = order of highest derivative. 31 | - Degree of a differential equation = power of highest derivative. 32 | - Linear differential equation: 33 | $$ 34 | a_0(x)y^{(n)} + a_1(x)y^{(n - 1)} + \dots + a_n(x)y = F(x) 35 | $$ 36 | 37 | where $a_i(x)$ and $F(x)$ are single variable functions of $x$. 38 | 39 | ## Population models 40 | - Malthusian model: the rate of growth of population is directly proportional to 41 | the population at that moment. 42 | - Modify Malthusian model to incorporate more complex features. 43 | - Carrying capacity: limit of a population as time tends to infinity. 44 | -------------------------------------------------------------------------------- /iiit-ril.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: 'Lectures notes for Reaadings in Indian Literature course, IIIT Hyderbad Spring 2022' 4 | --- 5 | 6 | # Lecture 1, 03/01/2022 7 | - Logistics 8 | 9 | # Lecture 2, 06/01/2022 10 | - Story: the bare bones skeleton of a text 11 | - Narrative: a particular telling of a story 12 | - Plot: events transpired in a story 13 | -------------------------------------------------------------------------------- /iiit-soci.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: 'Lectures notes for State of Colonial India course, IIIT Hyderbad Spring 2022' 4 | --- 5 | 6 | # Lecture 1, 04/01/2022 7 | - Course outline 8 | 1. Ideas of State 9 | 2. Geographies of the Colonial State 10 | 3. Economies of the Colonial State 11 | 4. Technologies of the Colonial State 12 | 5. Idologies of the State 13 | - Submissions 14 | + Assignments x3 15 | + Exam x1 16 | + Project/Term paper x1 17 | -------------------------------------------------------------------------------- /imc/2.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on Introduction to Modern Cryptography, chapter 2 4 | --- 5 | - **Perfectly secret scheme**: a cryptographic scheme that is provably secure 6 | against attackers with unbounded computational power. Formally 7 | - Definition: An encryption scheme `(Gen, Enc, Dec)` with message space 8 | $\mathcal{M}$ is *perfectly secret* if $\forall$ probability distributions 9 | over $\mathcal{M}$, $\forall m\in\mathcal{M}$ and $\forall c\in\mathcal{C}$ 10 | such that $P[C = c] > 0$, 11 | \begin{gather*} 12 | P[M = m | C = c] = P [M = m] 13 | \end{gather*} 14 | - Alternate equivalent definitions 15 | \begin{enumerate} 16 | \item Ciphertext independent of message 17 | \begin{gather*} 18 | P[Enc_K(m) = c] = P[Enc_K(m') = c] 19 | \end{gather*} 20 | \item Perfect indistinuishability 21 | \begin{gather*} 22 | P[PrivK_{\mathcal{A},\Pi}^{eav} = 1] = \frac{1}{2} 23 | \end{gather*} 24 | \end{enumerate} 25 | - Theorem - Limitations of perfectly secret encryption schemes: If 26 | `(Gen, Enc, Dec)` is a perfectly secret encryption scheme with message space 27 | $\mathcal{M}$ and key space $\mathcal{K}$ then $|K|\geq |M|$ 28 | - Shannon's Theorem: An encryption scheme `(Gen, Enc, Dec)` with message 29 | space $\mathcal{M}$ such that $|\mathcal{M}| = |\mathcal{K}| = 30 | |\mathcal{C}|$ is perfectly secret iff 31 | \begin{enumerate} 32 | \item Every $k\in\mathcal{K}$ is chosen with probability $1/\mathcal{K}$ 33 | by `Gen` 34 | \item $\forall m\in\mathcal{M}$ and $\forall c\in\mathcal{C}$, $\exists 35 | k\in\mathcal{K}$ such that `Enc`$_k(m)$ outputs $c$. 36 | \end{enumerate} 37 | -------------------------------------------------------------------------------- /imc/4.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on Introduction to Modern Cryptography, chapter 4 4 | --- 5 | - **Definition**: A message authentication code (MAC) is a three tuple of PPTs 6 | `(Gen, Mac, Vrfy)` 7 | 1. `Gen` - takes as input the security parameter $1^n$ and outputs key $k 8 | (|k|\geq n)$ 9 | 2. `Mac` - $key, message\rightarrow tag$ 10 | 3. `Vrfy` - $key, message, tag\rightarrow \{0, 1\}$ (invalid/valid) 11 | - **Experiment**: Adversary has oracle access to tag generator `Mac`, it 12 | shouldn't be able to trick `Vrfy` for a message whose tag wasn't generated 13 | - **Fixed length MAC construction**: If $F$ is a pseudorandom function, 14 | \begin{enumerate} 15 | \item `Mac`: $t := F_k(m)$ 16 | \item `Vrfy`: 1 iff $t == F_k(m)$ 17 | \end{enumerate} 18 | - **Arbitrary length MAC construction**: If $\pi'$ is MAC for fixed-length $n$ 19 | \begin{enumerate} 20 | \item `Mac`: For key $k\in\{0,1\}^n$ and message $m\in\{0,1\}^*$ of length 21 | $l$ parse message into $d$ blocks each of length $l/4$ and choose uniform 22 | random identifier $r\in\{0,1\}^{l/4}$. For $i$ in [i, d] compute 23 | $t_i\leftarrow$ `Mac` $_k(r||l||i||m_i)$ and output the tag $t = \langle 24 | r,t_1,\dots,t_d\rangle$ 25 | \item `Vrfy`: Output 1, if each $d$ block is verified to 1 26 | \end{enumerate} 27 | - **Cipher Block Chaining MAC**: Like Arbitrary case, but each $t_i = 28 | F_k(t_{i-1}\oplus m_i)$ ($F$ is a pseudorandom generator) and give last 29 | $t_i$ as tag. Output 1 iff $t == Mac_k(m)$ 30 | TODO: Authenticated Encryption 31 | -------------------------------------------------------------------------------- /imc/5.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on Introduction to Modern Cryptography, chapter 5 4 | --- 5 | - Collision resistance: hard for PPT adversary to find collision in $H$ 6 | \begin{gather*} 7 | Pr[Hash-coll_{A, \pi} = 1]\leq negl(n) 8 | \end{gather*} 9 | - Merkle-Damagard transform : compression by a single bit is as easy/hard as 10 | compressing by an arbitrary amount 11 | \begin{enumerate} 12 | (Gen, h : 2n\rightarrow n) 13 | \item Parse string of length $L$ into $B$ blocks 14 | \item set $z_0 = 0^n$ 15 | \item For $i\in [1, B+1]$, set $z_i = h(z_{i-1}||x_i)$ 16 | \item Output $z_{B+1}$ 17 | \end{enumerate} 18 | - Hash MAC 19 | -------------------------------------------------------------------------------- /imc/8.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on Introduction to Modern Cryptography, chapter 8 4 | --- 5 | - For naturals $a$ and $b$, the smallest value $aX+bY$ can take is their gcd 6 | - $b$ is invertible modulo $N$ iff they are coprime 7 | - If $N = \Pi_i p_i^{e_i}$, then $\phi(N) = \Pi_i p_i^{e_i-1}(p_i-1)$ 8 | - Factoring problem: Given a composite number $N$, find numbers $p$ and $q$ such 9 | that $p\times q = N$. No polynomial time algorithms known. Exponential 10 | $\mathcal{O}(\sqrt{N}.||N||^c)$. 11 | - If $H$ is a nontrivial subgroup of $G$, then $|H|\leq |G|/2$ 12 | - If there exists a witness that $N$ is composite, then at least half the 13 | elements of $\mathbb{Z}_N^*$ are witnesses that $N$ is composite. 14 | - $a$ is a strong witness for $N$'s compositness, if 15 | 1. $a^u\neq\pm 1 mod N$ 16 | 1. $a^{2^i}u\neq-1 mod N$ 17 | - If $N$ is an odd number that is not a prime power, then at least half the 18 | elements of $\mathbb{Z}_N$ are strong witnesses that $N$ is composite. 19 | -------------------------------------------------------------------------------- /jenkins.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/jenkins.md -------------------------------------------------------------------------------- /joel-test.md: -------------------------------------------------------------------------------- 1 | 1. Do you use source control? 2 | 2. Can you make a build in one step? 3 | 3. Do you make daily builds? 4 | 4. Do you have a bug database? 5 | 5. Do you fix bugs before writing new code? 6 | 6. Do you have an up-to-date schedule? 7 | 7. Do you have a spec? 8 | 8. Do programmers have quiet working conditions? 9 | 9. Do you use the best tools money can buy? 10 | 10. Do you have testers? 11 | 11. Do new candidates write code during their interview? 12 | 12. Do you do hallway usability testing? 13 | -------------------------------------------------------------------------------- /kavsi/1.md: -------------------------------------------------------------------------------- 1 | # Questions 2 | 3 | - Knowing vs thinking something to be true 4 | - Difference between knowledge and (universal) opinion/belief? Is there even a 5 | difference? 6 | - Justification needed for knowing a claim? 7 | - Do non-human entities (animals, god etc) have knowledge? Or is it inherently 8 | human-centric 9 | 10 | # Knowledge and the knower 11 | 12 | - Economy of knowledge: knowledge is a free flowing resource, stored in 13 | databases and libraries. 14 | - Knowledge is dependent on someone to know (unlike, say a mountain) 15 | - Knowledge != facts. Say a friend tosses a coin, then the outcome is either 16 | heads or tails - a fact. However, you *lack* the knowledge of the outcome 17 | (i.e. what it has actually landed on). It is knowledge's nature to be required 18 | to access: libraries, databases etc are not knowledge but merely paper with 19 | ink marks, electronic traces unless someone accesses them 20 | - Many people can have same knowledge, but all knowledge *must* be known by 21 | someone 22 | - Knowledge can be combined in productive ways by groups of people, Take the 23 | Linux kernel for example - no single individual knows every LOC, yet all the 24 | developers combined together, i.e. the *group* of developers, know how it 25 | works. 26 | - Knowledge as a link : Person <-> Fact 27 | 28 | # Spotting the difference 29 | 30 | - Cynical Theory: knowledge as an attitude of the elite. Some knowledge is more 31 | valid than others, simply because of who possess it irrespective of its 32 | relation to reality? 33 | - More power => more means to gain knowledge, more knowledge => more power 34 | - Falls short at 35 | + Ability to question the powerful - history proves great scholars have also 36 | been wrong 37 | + Everyday knowledge 38 | 39 | # Knowing vs thinking 40 | 41 | - Factivity: knowing something to be true (I think I have green hair vs I know I 42 | have black hair). Link between truthfulness of a proposition and person 43 | - Just because it is hard to spot the difference, doesn't mean there is no 44 | difference: 45 | - *Knowledge* links only with facts. *Belief* can link with falsities. 46 | - Confidence is also essential to knowledge 47 | - Just truthfulness and confidence aren't enough: father-daughter dilemma 48 | - Thus, knowledge = truthfulness + confidence + _ 49 | - Assumption: objectivity of truth, otherwise lead into self-destructive 50 | theories like Protagoras' 51 | -------------------------------------------------------------------------------- /kavsi/2.md: -------------------------------------------------------------------------------- 1 | # Scepticism 2 | 3 | ## Can you be sure? 4 | 5 | - Nothing? Do you even know this? 6 | 7 | ## The historical roots of scepticism 8 | 9 | - Academic sceptics: argue for impossibility of knowledge, argues against stoic 10 | epistemology 11 | - Pyrrhonian sceptics: argue for nothing 12 | - Stoic epistemology: impressions (experience) vs judgements (acceptance/rejectance) 13 | - Academic Sceptics argument: Impressions are always fallible, thus knowledge 14 | cannot be attained 15 | - Core problem: criterion for accepting/rejecting knowledge? How to select this 16 | criteria itself? 17 | - Pyrrhonian's strategy: whenever a decision must be made, provide supporting 18 | arguments to each possible decision, without ever reaching a conclusion. In 19 | other words, simply avoid taking any decisions at all and be at inner peace. 20 | 21 | ## Old challenges, fresh replies 22 | 23 | - Moore's argument: "Here is one hand, and here is another". Shift the burden of 24 | proof to the sceptic. 25 | - Russell's argument: All other things being equal, a simple explanation is 26 | favoured over a complex one rationally (Occam's razor?). Counter - knowledge 27 | calls for a higher standard than rational belief (Butcher-Maid-Murder example) 28 | - Semantic Externalism: words get their meaning not from what individual 29 | speakers think of them, but from casual chains that connect us with the 30 | world around us. For example, people from the medieval ages thought of water 31 | as an element, but today's scientists describe it as H20. However, both a 32 | modern scientist and a medieval man both refer to the same liquid when the say 33 | water i.e. both have the same casual link. 34 | - These casual links may be across multiple people. For instance Socrates is 35 | dead, yet whenever people talk about him everyone refers to the same 36 | Socrates 37 | - Semantic Externalism allows people to communicate despite of conflict. For 38 | instance the Socratic problem can be avoided. 39 | - Putnam's argument against the Matrix: our knowledge of the computer is from 40 | the simulation, you've never interacted with a computer outside the 41 | simulation, thus there cannot be an outside reality 42 | - Scepticism is a good thing - second checking individual beliefs - taken too 43 | far 44 | -------------------------------------------------------------------------------- /kavsi/3.md: -------------------------------------------------------------------------------- 1 | # Rationalism and Empiricism 2 | 3 | ## The Rationalism of Rene Descartes 4 | 5 | 1. Demolish all previous opinions 6 | 2. Know for certainty that I, a thinking being, exist, irrespective of everything else 7 | 3. A clear and distinct perception of what I was asserting 8 | 4. All mistakes arise from our freedom 9 | 10 | ## The Empiricism of John Locke 11 | 12 | - Outer experiences + inner thought 13 | - Knowledge: the perception of the connection and agreement, or disagreement and 14 | repugnancy, of any of our ideas 15 | - Demonstrative knowledge: knowledge that a mind sees through a chain of 16 | connecting ideas 17 | - Sensitive knowledge: connected to existence of things being experienced: 18 | clothes worn. Different from recollection 19 | - Judgement allows us to hold that something is probably true, and probably is 20 | good enough 21 | - 22 | -------------------------------------------------------------------------------- /kavsi/4.md: -------------------------------------------------------------------------------- 1 | # The Analysis of Knowledge 2 | 3 | ## Gettier's challenge 4 | 5 | - Classical analysis of knowledge: justified true belief 6 | $S$ knows that $p$ is true iff 7 | 1. $p$ is true 8 | 2. $S$ believes that $p$ 9 | 3. $S$ is justified in believing that $p$ 10 | - Consider a detective X that comes to the conclusion that Z is guilty of a crime 11 | based on the testimonies of A, B and C. However, C is a lies in their 12 | testimony. But A and B are truthful and X is indeed guilty. The justified true 13 | belief model of knowledge fails here as X does have knowledge that Z is 14 | guilty, but does not know that C lied. X does not *essentially rely* on a 15 | false belief 16 | 17 | ## The causal theory of knowledge 18 | 19 | - Gap between source of justification and truthfulness: say a student S cheats 20 | on n math test. However the evaluator E evaluating S's answers (source of 21 | justification) is unaware of this fact and thinks that S has indeed learnt 22 | math (truthfulness). Does E have the knowledge that S has learnt math? 23 | - Goldman's casual theory of knowledge: experience based knowledge requires the 24 | knower to be casually connected to the fact. Continuing the previous example, 25 | if the evaluator invigilated for the test, he would be casually connected to 26 | the fact. 27 | - Most educated adults know that Julius Caesar was assassinated, yet cannot 28 | justify. Does this mean they do not have that knowledge? 29 | - $S$ knows that $p$ iff the fact $p$ is casually connected in an appropriate 30 | way with $S$'s believing $p$. 31 | - Reliabilism: knowledge is true belief produced by a reliable (likely to be 32 | true) belief-producing mechanism. Criticism: how reliable is reliable enough? 33 | 34 | ## No way out? 35 | 36 | - Recipe for counter examples: come up with a scenario where someone has a 37 | justified false belief, then add a twist to make the proposition is true 38 | 39 | ## Can knowing be analysed at all? 40 | 41 | - Knowledge is not a well behaved concept 42 | - Timothy Williamson's argument: knowledge is more fundamental than beliefs 43 | -------------------------------------------------------------------------------- /kavsi/5.md: -------------------------------------------------------------------------------- 1 | # Internalism and externalism 2 | 3 | ## The first-person point of view 4 | 5 | - Internalist: You can't know something unless you can see for yourself why you believe it 6 | - Externalist: Knowledge is a relationship between the knower and the fact. 7 | Internalism leads to scepticism. 8 | 9 | ## Nozick's tracking theory 10 | 11 | - Having the tendency to believing something when it is true, and not believing 12 | when it is not is knowing 13 | $S$ knows that $p$ iff 14 | 1. $p$ is true 15 | 2. $S$ believes that $p$ 16 | 3. If $p$ were not true, $S$ would not believe that $p$ 17 | 4. If $p$ were true, $S$ would believe that $p$ 18 | 19 | In other words, the belief formation mechanism should be such that it should 20 | actually track the truthfulness of beliefs. 21 | 22 | ## The Generality Problem 23 | 24 | - Which belief forming process is relevant for justification determining 25 | purposes? 26 | 27 | ## Questionable methods 28 | -------------------------------------------------------------------------------- /kavsi/6.md: -------------------------------------------------------------------------------- 1 | # Testimony 2 | 3 | ## They told you so 4 | 5 | - Testimony allows us to "know" things which we otherwise could not have 6 | 7 | ## No way to know 8 | 9 | - Testimony: someone telling something which plays a key role in what you get 10 | out of the exchange 11 | - One believing something based on a testimony is to understand what is being 12 | told and taking it for granted 13 | - Locke's argument: at best, it is highly probable that a testimony is true. Key 14 | problem lies here is people's reliance on their past experiences 15 | - Locke's formula for confidence of a testimony (along with one's experiences) 16 | 1. The number of witnesses 17 | 2. Their integrity 18 | 3. Their skill 19 | 4. The purpose they have in supplying their report 20 | 5. The internal consistency of what is conveyed, and the circumstances of 21 | your hearing it 22 | 6. Whether there is any contrary testimony 23 | - This allows for future questioning of current knowledge 24 | - Locke does **not** show: difference between knowledge providing powers of 25 | perception and testimony 26 | 27 | ## The middle ground: reductionism 28 | 29 | - Use ordinary powers of inference to make judgements about testimonies 30 | - Global reductionism: rely on experiences to make judgements 31 | - Local reductionism: look for specific positive reasons in any given situation 32 | 33 | ## Testimony as a distinctive source of knowledge 34 | 35 | - Craig's argument: knowledge as a consequence of testimony 36 | - Knowers: good informants. Counter: knowers can be deceptive 37 | - Failures: Gettier case victims 38 | -------------------------------------------------------------------------------- /kavsi/7.md: -------------------------------------------------------------------------------- 1 | # Shifting standards? 2 | 3 | ## Counting on context 4 | 5 | - As words themselves have wildly different meanings (I, here, small/big, 6 | tomorrow), what about "to know"? 7 | - Contextualism: knowing itself is context sensitive 8 | 9 | ## The emergence of contextualism 10 | 11 | - Relevant Alternatives: shift the burden of proof & knowing goes hand in hand 12 | with grasping a contrast 13 | - Closure: anything that is logically deducible from what is already known is 14 | also known 15 | - Relevant Alternatives denies closure: zebra & painted donkey example 16 | - Contextualism uses Relevant Alternatives with closure as follows 17 | 1. Standards for knowledge varies with setting (think street, school, court) 18 | 2. Employ one, and only one, set of standards for knowledge in any given 19 | setting 20 | - Contextualism is just skepticism in disguise? No, both (skeptic argument and 21 | non-skeptic argument) true according to contextualism. It's like asking which 22 | weekday is ultimately 'tomorrow' 23 | - Active question: why is context sensitive nature of language obscured when 24 | talking about knowledge? 25 | 26 | ## Interest-relative invariantism 27 | 28 | - Interest-relative invariantism: practical interest play a role 29 | - IRI is beyond Contextualism - it is a theory of how knowledge itself works, 30 | not just semantics 31 | - More evidence is needed for knowledge as the stakes rise 32 | 33 | ## Old-fashioned invariantism, again? 34 | 35 | - IRI cannot handle shifting intuitions patterns 36 | - IRI cannot handle counterfactual possibilities 37 | - Moderate Strict Invariantism: there is a single fixed standard that must be 38 | met for knowledge, and humans frequently meet it (unlike skepticism) 39 | -------------------------------------------------------------------------------- /kavsi/8.md: -------------------------------------------------------------------------------- 1 | # Knowing about knowing 2 | 3 | ## Epistemology's raw materials 4 | 5 | ## Reading minds 6 | 7 | - Human beings can not only keep track of what other human beings know/not know, 8 | but also know _where_ other human beings are mistaken (latter not observed in 9 | any other species). They are able to calculate other people's false beliefs 10 | - Above notions go well with knowledge first approach 11 | - Natural limits on mindreading 12 | * Limit on recursion 13 | * Tendency to be self centered - egocentrism (children crayon candybox). 14 | It's tough to suppress our own private knowledge when calculating how 15 | well someone else might perform 16 | 17 | ## Challenges to the case method 18 | 19 | - Experimental philosophy advocated abandonment of reliance on intuitions for 20 | knowledge 21 | - Theory starts clouding experiments when thinking too hard 22 | 23 | ## Impressions of knowledge, and knowledge itself 24 | - Cummins' conclusion: philosophers should not rely on their intuitions for 25 | theorizing knowledge 26 | - We do not yet understand the full nature of knowledge 27 | -------------------------------------------------------------------------------- /knrc/chapter-1.md: -------------------------------------------------------------------------------- 1 | A function contains statements that specify the computing operations to be done, 2 | and variables store values used during the computations. 3 | 4 | A variable must be declared in each function that wants to access it - the 5 | declaration may be an explicit extern statement or may be implicit from the 6 | context. 7 | -------------------------------------------------------------------------------- /knrc/chapter-2.md: -------------------------------------------------------------------------------- 1 | Identifiers are made up of letters and digits; the first character must be a 2 | letter. Underscore counts as a letter. 3 | 4 | Strings may be concatenated at compile time 5 | ``` 6 | "hello," " world" 7 | ``` 8 | is equivalent to 9 | ``` 10 | "hello, world" 11 | ``` 12 | 13 | ## Sizes and ranges for various types 14 | | Type | Size | Range | 15 | | ---- | ---- | ----- | 16 | | char | 1 byte | -128 to 127 | 17 | | short | 2 bytes | -32768 to 32767 | 18 | | int | 2/4 bytes | -32768 to 32767 / -2M to +2M | 19 | | long | 4 bytes | -2M to +2M | 20 | | float | 4 bytes | -3.4E+38 to +3.4E+38 (6 decimal places) | 21 | | double | 8 bytes | -1.7E+308 to +1.7E+308 (15 decimal places) | 22 | | long double | 10 bytes | -3.4E+4932 to +3.4E+4932 (19 decimal places) | 23 | 24 | Conversion rules:- 25 | * If either operand is long double, convert the other to long double 26 | * Otherwise, if either operand is double, convert the other to double 27 | * Otherwise, if either operand is float, convert the other to float 28 | * Otherwise, conver char and short to int 29 | * Then, if either oerand is long, conver the other to long 30 | 31 | Increment and decrement operators can only be applied to variables; an 32 | expression like `(i + j)++` is illegal. 33 | 34 | ## Precedence and Associativity of operators 35 | | Operators | Associativity | 36 | | --------- | ------------- | 37 | | () [] -> . | left to right | 38 | | ! ~ ++ -- + _ * & (type) sizeof | right to left | 39 | | * / % | left to right | 40 | | + - | left to right | 41 | | << >> | left to right | 42 | | < <= > >= | left to right | 43 | | == != | left to right | 44 | | & | left to right | 45 | | ^ | left to right | 46 | | \| | left to right | 47 | | && | left to right | 48 | | \|\| | left to right | 49 | | ?: | right to left | 50 | | = += -= *= /= %= &= ^= |= <<= >>= | right to left | 51 | | , | left to right | 52 | -------------------------------------------------------------------------------- /knrc/chapter-3.md: -------------------------------------------------------------------------------- 1 | A pair of expressions separated by a comma is evaluated left to right, and the 2 | type and value of the result are the type and value of the right operand. Note 3 | that commas that separate function arguments, variables in declarations, etc., 4 | are not comma operators, and do not guarantee left to right evaluation. 5 | -------------------------------------------------------------------------------- /knrc/chapter-4.md: -------------------------------------------------------------------------------- 1 | If return type of a function is ommited, int is assumed. 2 | 3 | A function is implicitly declared by its first appearance in an expression. 4 | 5 | If a name that has not been previously decflared occurs in an expression and is 6 | followed by a left parenthesis, it is declared by context to be a function name, 7 | the function is assumed to return an int, and nothing is assumed about its 8 | arguments. 9 | 10 | By default, external variables and functions have the propertry that all 11 | references to them by the same name, even from functions compiled separately, 12 | are references to the same thing. 13 | 14 | Any function may access an external variable by referring to it by name, if the 15 | name has been declared somehow. 16 | 17 | The scope of a name is the part of the program within which the name can be 18 | used. 19 | 20 | A declaration announces the properties of a variable; a definition also causes 21 | storage to be set aside. 22 | 23 | There must be only one definition of an external variable among all files that 24 | make up the source program; other files may contain `extern` declarations to 25 | access it. 26 | 27 | The static declaration, applied to an external variable or function, limits the 28 | scope of that object to the rest of the source file being compiled. 29 | 30 | `register` variables are to be placed in machine registers, which may result in 31 | smaller and faster programs. 32 | 33 | The `register` declaration can only be applied to automatic variables and to the 34 | formal parameters of a function. 35 | 36 | Excess `register` declarations are harmless since the word `register` is ignored 37 | for excess or disallowed declarations. 38 | 39 | Automatic variables, including formal parameters, also hide external variables 40 | and functions of the same name. 41 | 42 | In the absence of explicit initilization, external and static variables are 43 | guaranteed to be initializzed to zero; automatic and register variables have 44 | undefined (i.e. garbage) initial values. 45 | 46 | The name in a #define has the same form as a variable name; the replacement text 47 | is arbitary. Long definiions may be continued onto several lines by placing a 48 | `\` at the end of each line. Substitutions are made only for tokens, and do not 49 | take place within quoted strings. 50 | 51 | Macros avoid the run-time overhead of a function call. 52 | 53 | The preprocessor operator ## provides a way to concatenate actual arguments 54 | during macro expansion. 55 | -------------------------------------------------------------------------------- /knrc/chapter-5.md: -------------------------------------------------------------------------------- 1 | A pointer is constrained to point to a particular kind of object: every pointer 2 | points to a specific datatype (except for the void pointer, which is used to 3 | hold any type of pointer but cannot be dereferenced itself.) 4 | 5 | Pointer arguments enable a function to access and change objects in the function 6 | that called it. 7 | 8 | An array-and-index expression is equvialent to one written as a pointer and 9 | offset. 10 | 11 | There is one difference between an array name and a pointer that must be kept in 12 | mind - a pointer is a variable, so pa = a and pa++ are legal. But an array name 13 | is not a variable; constructions like a = pa and a++ are illegal. 14 | 15 | When an array name is passed to a function, the function can at its convenience 16 | believe that it has been handed either an array or a pointer, and manipulate it 17 | accordingly. 18 | 19 | If one is sure that the elements exits, it is also possible to index backwards 20 | in an array; p[-1], p[-2] and so on are syntactically legal, and refer to 21 | elements that immediately precede p[0]. 22 | 23 | C guarantees that zero is never a valid address for data, so a return value of 24 | zero can be used to signal an abnormal event. 25 | 26 | Pointer and integers are not interchangeable, with zero being the sole 27 | exception: the constant zero may be assigned to a pointer, and a pointer may be 28 | compared with the constant zero. 29 | 30 | The valid pointer operations are assignment of pointer of the same type, adding 31 | or subtracting a pointer and an integer, subtracting or comparing two pointers 32 | to members of the same array, and assigning or comparing to zero. All other 33 | pointer arithmetic is illegal. 34 | 35 | Only the first dimension (subscript) of an array is free; all the others have to 36 | be specified. 37 | 38 | In function pointers, the `&` operand is not necessary, in the same way that it 39 | is not needed before an array name. 40 | 41 | Any pointer can be case to void\* and back again without loss of information. 42 | -------------------------------------------------------------------------------- /latex/2: -------------------------------------------------------------------------------- 1 | \command[optional argumet]{argument} 2 | \textup{Upright shape} {\upshape Upright shape} 3 | \textit{Italic shape} {\itshape Italic shape} 4 | \textsl{Slanted shape} {\slshape Slanted shape} 5 | \textsc{Small caps shape} {\scshape Small caps shape} 6 | \textmd{Medium series} {\mdseries Medium series} 7 | \textbf{Boldface series} {\bfseries Boldface series} 8 | \textrm{Roman family} {\rmfamily Roman family} 9 | \textsf{Sans serif family} {\sffamily Sans serif family} 10 | \texttt{Typewriter family} {\ttfamily Typewriter family} 11 | {\textit Effects on fonts can be delimited using brackets} 12 | \tiny 13 | \script 14 | \footnotesize 15 | \small 16 | \normalsize 17 | \large 18 | \big 19 | \Large 20 | \LARGE 21 | \huge 22 | \Huge 23 | \begin{} 24 | \end{} 25 | \newcommand{\}{} 26 | \parbox[alignment]{width}{text} 27 | \mbox{indivisible} 28 | \begin{center} \end{center} %center text 29 | \begin{quote} \end{quote} 30 | \begin{quotation} \end{quotation} %longer quotes 31 | -------------------------------------------------------------------------------- /latex/3: -------------------------------------------------------------------------------- 1 | \chapter{An interesting chapter title} 2 | \section{An interesting section title} 3 | \subsection{An interesting subsection title} 4 | 5 | \usepackage[a4paper, inner=1.5cm, outer=3cm, top=2cm, bottom=3cm, bindingoffset=1cm]{geometry} %specify margins 6 | papersize={width,height} 7 | landscape/potrait 8 | textwidth=140mm 9 | textheight=120mm 10 | includehead=true 11 | includefoot=true 12 | left=2cm right=2cm % for one side documents 13 | inner=2cm outr=2cm % for two side documents 14 | top=20mm bottom=20mm 15 | twocolumn %make two column 16 | \usepackage[singlespacing/onehalfspacing/doublespacing]{setspace} 17 | -------------------------------------------------------------------------------- /lean/1.md: -------------------------------------------------------------------------------- 1 | * *Automated theorem proving* focuses on finding proofs 2 | * *Interactive theorem proving* focuses on verification aspect 3 | -------------------------------------------------------------------------------- /lil-typer/1.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on The Little Typer, Chapter-1 4 | --- 5 | - A tick mark directly followed by one or more letters and hyphens is an `Atom`. 6 | - Two expressions are the same `Atom` if their values are tick marks followed by 7 | identical letters and hyphens 8 | - Forms of judgements 9 | 1. _ is a _ 10 | 2. _ is the same _ as _ 11 | 3. _ is a type 12 | 4. _ and _ are the same type 13 | - `Atom` is a type 14 | - Judgements are acts of knowing 15 | - For each type, every expression described by that type has a **normal form**, 16 | the most direct way of writing it. Two expression are the same iff they have 17 | identical normal forms. 18 | - It is meaningless to ask if expressions are same without specifying types, 19 | i.e. asking "is `(+ 1 2)` the same as `3`" is meaningless, asking "is 20 | `(+ 1 2)` the same `Nat` as 3" is meaningful. 21 | - When defining a name, it is necessary to first `claim` the name with a type 22 | ``` 23 | (claim one 24 | Nat) 25 | (define one 26 | (add1 zero)) 27 | ``` 28 | - An expression is normal if its top is a **constructor** and the constructor's 29 | arguments are normal 30 | - Any expression with a constructor at the top is called a **value** 31 | - `add1` and `zero` are constructors that create **data**, but `Nat` and `Pair` 32 | are type constructors 33 | -------------------------------------------------------------------------------- /lil-typer/2.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on The Little Typer, Chapter-2 4 | --- 5 | - Eliminators take apart values built by constructors 6 | - Applying a function to arguments is the eliminator for functions 7 | - Expressions that aren't values and cannot yet be evaluated due to a variable 8 | are called **neutral** 9 | - `which-Nat` discriminate between zero and other natural numbers and take 10 | appropriate action 11 | ``` 12 | (which-Nat target 13 | base 14 | step) 15 | ``` 16 | - An type expression is a type value if it has a type constructor at its top 17 | (similar to how an expression described by a type is value when it has a 18 | constructor at its top) 19 | - Every $U$ is a type. But not every type is a $U$ 20 | - Claim + definition = meaningfulness of claim 21 | - Expressions = expression's type + normal form 22 | - Type annotations 23 | ``` 24 | (the (Pair Atom Atom) 25 | (cons 'foo 'bar)) 26 | ``` 27 | - No expression can be its own type 28 | - `(Pair U U)`, `(Pair Atom U)` and `(-> U U)` are all types that do not have 29 | `U` as their type 30 | -------------------------------------------------------------------------------- /lil-typer/3.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramana Joshi 3 | title: Notes on The Little Typer, Chapter-3 4 | --- 5 | - Total function: function that always assigns a value to every possible 6 | argument 7 | - In Pie all functions are total 8 | - `iter-Nat : Nat -> X -> (Nat -> X)` 9 | - `(iter-Nat target base step)` 10 | - Semantics of `iter-Nat`: 11 | ``` 12 | (iter-Nat zero base step) = base 13 | (iter-Nat (add1 foo) base step) = step (iter-Nat foo base step) 14 | ``` 15 | - `iter-Nat`: each `add1` in the value of `target` is replaced by a `step` and 16 | the `zero` by `base` 17 | - `rec-Nat : Nat -> X -> (Nat -> X -> X)` 18 | - `(rec-Nat target base step)` 19 | - Semantics of `rec-Nat`: 20 | ``` 21 | (rec-Nat zero base step) = base 22 | (rec-Nat (add1 foo) base step) = step base (rec-Nat foo base step) 23 | ``` 24 | -------------------------------------------------------------------------------- /living-ethics.md: -------------------------------------------------------------------------------- 1 | --- 2 | author: Bharathi Ramama Joshi 3 | title: 'Notes on the book "Living Ethics"' 4 | --- 5 | 6 | # Chapter 2: Moral Reasoning 7 | - 8 | 9 | # Chapter 6: Kantian Ethics 10 | - Principle of universalizability: An act is morally acceptable if, and only if, 11 | its maxim is universalizable. 12 | 1. Maxim: the principle of action one gives oneself when one is about to do 13 | something (what are you about to do + why are you doing it). 14 | 2. Universalizability: 15 | 1. Formulate maxim clearly: what you intend to do and why you inted to 16 | do it. 17 | 2. Imagine a world in which everyone supports and acts on your maxim. 18 | 3. Ask: Can the goal of my action be achieved in such a world? 19 | If answer to 3 is yes, then maxim is moral, no then immoral. 20 | 21 | # Chapter 23: Sexual Morality 22 | - Polyamorous marriage has often been prohibited because of the prevalence of 23 | oppressive and exploitative polygamous relationships (esp towards women via 24 | polygamy). 25 | - Liberal argument: Sex is morally permissible if and only if it is engaged in 26 | by consenting adults. 27 | -------------------------------------------------------------------------------- /lua/chapter-1.md: -------------------------------------------------------------------------------- 1 | To start the interpreter, use `lua` 2 | 3 | To run commands from a file, use `lua [filename].lua` 4 | 5 | A chunk is a sequence of commands. A chunk may be a single statement, or it may 6 | be composed of a mix of statements and function definitions. 7 | 8 | Lua needs no separator between consecutive statements, but a `;` can be used. 9 | 10 | To start an interactive session after running a given chunk, use 11 | `lua -i [file].lua`. 12 | 13 | Use `dofile` to run a chunk from an interactive session. 14 | 15 | Identifiers in Lua can be any string of letters, digits and underscores, not 16 | beginning with a digit. Example 17 | ``` 18 | i 19 | jj 20 | i10 21 | _ij 22 | ``` 23 | 24 | Reserved words 25 | ``` 26 | and break do else elseif 27 | end false for function if 28 | in local nil not or 29 | repeat return then true until 30 | while 31 | ``` 32 | Identifiers are case sensitive. 33 | 34 | Comments start with `--` and run until the end of the line. 35 | 36 | Block comments start with `--[[` and run until next `]]`. A common trick is to 37 | use `--[[` and `--]]` for comments so that blocks can be uncommented by adding a 38 | single `-` at the beginning. 39 | 40 | Global variables need no declarations. Non-initialized variables are initialized 41 | to `nil`. 42 | 43 | To delete a global variable, just assign `nil` to it. Lua behaves as if the 44 | variable had never been used. A global variable is existent iff it has a non-nil 45 | value. 46 | 47 | Some common options 48 | | Option | Description | 49 | | ----- | ----------- | 50 | | `-e` | Execute script from command line | 51 | | `-l` | Load a library | 52 | | `_PROMPT` | Prompt for interacting | 53 | 54 | In interactive mode, value of any expression can be printed by writing a line 55 | that starts with an equal sign followed by the expression. 56 | ``` 57 | > = math.sin(30) --> 0.14 58 | > a = 3 59 | > = a --> 3 60 | ``` 61 | 62 | Set the `LUA_INIT` environment variable to either `@filename` to make `lua` run 63 | the contents of `filename` before beginning, or to a chunk. If there is no `@`, 64 | it simply tries to execute its contents as a command. 65 | 66 | Command line arguments can be accessed via the global variable `arg`. Preceding 67 | options go to negative indices as they appear before the script. 68 | -------------------------------------------------------------------------------- /lua/chapter-3.md: -------------------------------------------------------------------------------- 1 | Expressions include numeric constatns, string literals, variables, unary and 2 | binary operations, function calls, function definitions and table constructors. 3 | 4 | `x % 1` gives fractional part of `x`. 5 | 6 | Lua uses `~=` instead of `!=` for inequality. 7 | 8 | Lua compares tables, useradata and functions by reference, that is, two such 9 | values are consdered equal only if they point to the very same object. 10 | 11 | Lua compares strings in alphabetical order (i.e. "2" < "15" is `false`) 12 | 13 | ### Precedence table (higher to lower) 14 | ``` 15 | ^ 16 | not # - 17 | * / % 18 | + - 19 | .. 20 | < > <= >= ~= == 21 | and 22 | or 23 | ``` 24 | 25 | All binary operators are left associative, except for `^` and `..` 26 | 27 | When in doube, always use explicit parentheses. 28 | 29 | Constructor are expressions that create and initialize tables. 30 | 31 | The simplest constructor, `{}`, creates an empty table. 32 | 33 | Constructors are also used to initialize arrays/lists/sequences. Note that Lua 34 | uses 1 based indexes. 35 | 36 | ``` 37 | day = {"Sunday", "Monday", "Tuesday", ......} 38 | print(day[1]) --> Sunday 39 | ``` 40 | 41 | To remove something, set it to `nil` 42 | ``` 43 | day[1] = nil 44 | ``` 45 | 46 | Indexes can be explicitly stated 47 | ``` 48 | opnames = {["+"] = "add", ["-"] = "sub", ["*"] = "mul", ["/"] = "div"} 49 | ``` 50 | -------------------------------------------------------------------------------- /lua/chapter-4.md: -------------------------------------------------------------------------------- 1 | Lua allows multiple assignment, where a list of values is assigned to a list of 2 | varibles in one step. 3 | ``` 4 | a, b = 10, 2 * x 5 | ``` 6 | Here, `a` gets `10` and `b` gets `2 * x` 7 | 8 | In a multiple assignment, Lua first evaluates all the values and only then 9 | executes the assignments. Extra variables are assgined `nil`. 10 | 11 | Local variables are created using the `local` statement 12 | ``` 13 | local i = 1 14 | ``` 15 | 16 | Local variables are limited to the block/chunk where they are declared. 17 | 18 | `do` blcoks are useful for finer control over scope 19 | ``` 20 | do 21 | local a2 = 2 * a 22 | local d = (b ^ 2 - 4 * a * c)^(1 / 2) 23 | x1 = (-b + d)/a2 24 | end -- scope of a2 and d ends here 25 | print(x1) -- works fine, x1 is global 26 | ``` 27 | Local variables are faster to access than global variables. 28 | 29 | ## Control Structures 30 | Lua provides `if`, `while`, `repeat` and `for`. All control structures must be 31 | explicitly terminated - `if`, `for` and `while` with an `end`; and `repeat` with 32 | `until. 33 | ### if-elseif-then-end 34 | ``` 35 | if op == "+" then 36 | r = a + b 37 | elseif op == "-" then 38 | r = a - b 39 | elseif op == "*" then 40 | r = a * b 41 | elseif op == "/" then 42 | r = a / b 43 | else 44 | error("invalid operation") 45 | end -- note use of end 46 | ``` 47 | Lua has no switch statement. 48 | 49 | ### while-do-end 50 | ``` 51 | while a[i] do 52 | print(a[i]) 53 | i = i + 1 54 | end 55 | ``` 56 | ### repeat-until 57 | ``` 58 | repeat 59 | line = os.read() 60 | until line ~= "" 61 | print(line) 62 | ``` 63 | ### for 64 | `for` is of two types - numeric `for` and generic `for` 65 | #### numeric for 66 | ``` 67 | for var=exp1,exp2,exp3 do 68 | 69 | end 70 | ``` 71 | `` is executed with `var` set to `exp1`, `exp2` etc. 72 | All expressions are evaluated once, before the loop starts. The control variable 73 | is `local`. 74 | 75 | Use a `break` to end a `for` before its normal termination - changing `var` 76 | leads to unpredictable results. 77 | 78 | #### generic for 79 | The generic `for` tarverses all values returned by an iterator function: 80 | ``` 81 | for i,v in ipairs(a) do print(v) end 82 | ``` 83 | 84 | For syntactic reasons, a `break` or `return` can appear only as the last 85 | statement of a block. For inserting them in between, use explicit `do-end` 86 | blocks. 87 | -------------------------------------------------------------------------------- /lua/chapter-5.md: -------------------------------------------------------------------------------- 1 | If the function has one single argument and that argument is either a string 2 | literal or a table constructor, then the parantheses are optional 3 | 4 | When calling a function, there is no difference between functions defined in Lua 5 | and functions defined in C. 6 | 7 | ## Syntax 8 | ``` 9 | function () 10 | 11 | return 12 | end 13 | ``` 14 | 15 | Extra arguments are thrown away; extra parameters get `nil`. 16 | 17 | Functions return multiple values by listing them all after the `return` keyword. 18 | ``` 19 | function alpha(meh) 20 | 21 | return a, b, c 22 | end 23 | ``` 24 | ## Return values 25 | * Lua adjusts number of results returned - extra return values are discarded and 26 | missing values are set to `nil` 27 | 28 | * When a function is called as a statement, Lua discards all results from the 29 | function. 30 | 31 | * When a function is called as an expression, Lua keeps only the first result. 32 | 33 | * All results are returned only when the call is the last (or the only) expression 34 | in a list of expressions. 35 | 36 | To force a call to return exactly one result by enclosing it in an extra pair of 37 | parantheses. 38 | 39 | `unpack` receives an array and returns as results all elements from the array, 40 | starting from index 1 41 | ``` 42 | a, b = unpack{10,20,30} -- a=10, b=20, 30 discarded 43 | ``` 44 | 45 | To call a function `f` with variable arguments in an array a, write 46 | ``` 47 | f(unpack(a)) 48 | ``` 49 | 50 | Use three dots `...` in the parameter list indicate that the function accepts a 51 | variable number of arguments. All its arguments are collected as varargs 52 | internally. 53 | 54 | Lua uses positional arguments by defualt, to use named arguments define a 55 | structure containing all arguments to be passed and pass this structure. 56 | ``` 57 | rename{old="temp.lua", new="temp1.lua"} 58 | function os.rename(arg) 59 | return os.rename(arg.old, arg.new) 60 | end 61 | ``` 62 | -------------------------------------------------------------------------------- /lua/chapter-6.md: -------------------------------------------------------------------------------- 1 | Functions in Lua are first-class values with proper lexical scoping. 2 | * first-class = can be used just another variable 3 | * lexical scoping = functions can access variables of their enclosing functions 4 | 5 | ``` 6 | function () 7 | 8 | return 9 | end 10 | ``` 11 | is syntactic sugar for 12 | ``` 13 | = function () return end 14 | ``` 15 | i.e. the Lambda. 16 | 17 | A closure is a function plus all it needs to access non local variabels 18 | correctly. Used in callback functions. 19 | 20 | Functions can be scoped using `local` keyword. They are then visible only in the 21 | block in which they are defined. 22 | 23 | Syntactic sugar for local functions is also available 24 | ``` 25 | local function () -- note use of local keyword 26 | 27 | end 28 | ``` 29 | 30 | Note that recursive functions must use forward declarations 31 | ``` 32 | local function () -- note use of local 33 | 34 | end 35 | ``` 36 | for mutually recursive functions 37 | ``` 38 | local f, g -- forward declarations 39 | function g () 40 | f() 41 | end 42 | function f () 43 | g() 44 | end 45 | ``` 46 | A tail call happens when a function calls another as its last action. 47 | -------------------------------------------------------------------------------- /make/2.md: -------------------------------------------------------------------------------- 1 | # Template 2 | A simple makefile looks like 3 | ``` 4 | target ... : prerequisites ... 5 | recipe 6 | ... 7 | ... 8 | ``` 9 | * `target` is the name of a file that is generated by a program 10 | * `prerequisites` is a file that is used as input to create `target` 11 | * `recipe` is an action that make carries out 12 | 13 | Targets that do not refer to files but are just actions are called *phony 14 | targets*. 15 | 16 | By default `make` starts with the first target, called the *default goal*. 17 | 18 | The recompilation is made based on time stamps of the prerequisites. 19 | 20 | *Variables* allow text strings to be defined once and subsituted in multiple 21 | places later. 22 | 23 | A variable's value is subsituted by writing `$(varName)` 24 | 25 | `make` has an *implicit rule* for updating the `.o` file from a correspondingly 26 | named `.c` file using a `cc -c` command (option `-c` says not to run the linker). 27 | -------------------------------------------------------------------------------- /make/3.md: -------------------------------------------------------------------------------- 1 | # Contents of a Makfile 2 | * Explicit rule: it says when and how to remake one or more files, called the 3 | rule's *targets*. It lists files the targets depend on, called *prerequisites* 4 | * Implicit rule: it says when and how to remake a of class files based on their 5 | names. 6 | * Variable definition: specify a text string value for a variable that can be 7 | subsituted into the text later. 8 | * Directive: instruction for `make` to do something special while reading the 9 | makefile. These include 10 | * Reading another makefile 11 | * Conditional instructions 12 | * Defining multi-line variables 13 | * Comment: lines starting with `#`. Instances of `#`'s will be treated literally 14 | (i.e. they cannot be used inside variable and function definitions) 15 | Long lines can be spanned across multiple line using `\` 16 | 17 | # Naming the makfile 18 | `make` tries for `GNUmakefile`, `makefile` and `Makefile` in that order 19 | 20 | # Including other makefiles 21 | * Other makefiles can be included using the `include` directive. Syntax:- 22 | ``` 23 | include filenames ... 24 | ``` 25 | * `#` comments are not allowed at the end of a line with the `include` directory 26 | * If the filenames contain any variables or function references, they are 27 | expanded 28 | * If the `include`ed files are not found in the current directory (and any other 29 | directories mentioned using the options) make searches for them in 30 | `prefix/include`, `/usr/gnu/include`, `/usr/local/include` and `/usr/include` 31 | * `make` reports error only after it has tried to find a way to remake a 32 | makefile and failed. 33 | * To make `make` ignore makefiles, use the `-include` or `sinclude` directive. 34 | Syntax 35 | ``` 36 | -include makefile 37 | ``` 38 | # `MAKEFILES` environment variable 39 | * `make` considers `MAKEFILES` as a list of makefiles to be read before others 40 | 41 | # How `make` works 42 | * `GNU make` works in two distinct phases 43 | 1. `make` reads all makefiles, included makefiles etc, internalizes variables, 44 | implicit and explicit rules and constructs a dependency graph of all the 45 | targets and their prerequisites. 46 | 2. `make` uses all these internal structures to determine what targets will 47 | need to be rebuilt and to invoke the rules necessary to do so. 48 | * An expansion is called immediate if it happens during the first phase, 49 | deferred if in the second. Variable definitions are parsed as follows 50 | -------------------------------------------------------------------------------- /microservices.md: -------------------------------------------------------------------------------- 1 | # 101 2 | - Microservices do not share DBs 3 | -------------------------------------------------------------------------------- /mlir-toy.md: -------------------------------------------------------------------------------- 1 | # Chapter 1 2 | - Dialect: grouping functionality to extend MLIR system by adding new operators, 3 | attributes, and types. A dialect consists of: 4 | + A prefix / namespace 5 | + A list of custom types, each its C++ class 6 | + A list of operations, each its name and C++ class implementation 7 | - Verifier for operator invariants (e.g. toy.print must have a single operand) 8 | - Semantics (no-side-effects, constant-folding, CSE-allowed) 9 | + Passes: analysis, transformations, dialect conversions 10 | + Possibly custom parser and assembly printer 11 | - Operations are defined by 12 | + Name 13 | + List of SSA operand values 14 | + List of attributes (MLIR's mechanism for attaching constant metadata to 15 | operations) 16 | + List of types for result values 17 | + Source location 18 | + List of successor blocks 19 | + List of regions 20 | - Region: list of basic blocks. Approximately CFG. 21 | - Traits: mechanism to inject additional behavior (accessors, verification, etc) 22 | into operators. 23 | - MLIR allows undefined operations to be manipulated through opaque `Operaton` 24 | class. 25 | 26 | # Chapter 3: High-level transformations 27 | - `RewritePattern`s are used to represent term rewrites. 28 | - Canonicalization framework: used to reduce operations to canonical forms. 29 | 30 | # Chapter 4: Generic transformations 31 | - MLIR declares abstract classes for high level transformations which can be 32 | defined on operation specific derived classes. 33 | - DialectInlinerInterface 34 | 35 | # Chapter 5: Partial Lowering 36 | - `DialectConversion` framework is used to convert operations from one dialect 37 | to another. 38 | - To use the `DialectConversion` framework, we provide it with two things: 39 | 1. A specification of what operations are legal and illegal, used to decide 40 | what to convert and what to not. 41 | 2. A set of patterns used to convert illegal operations into a set of zero or 42 | more legal operations. 43 | - `DialectConversion` framework also uses `RewritePattern`s, it uses a derived 44 | class called `ConversionPattern`. 45 | ## TODO 46 | - Spelunk adaptor TransposeOpAdaptor 47 | - Spelunk helper lowerOpToLoops 48 | 49 | # Chapter 6: LLVM Lowering 50 | - LLVMDialect 51 | - TypeConverter 52 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/1.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 1 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | --- 5 | 6 | - Music is an art form and cultural activity whose medium is sound organized in 7 | time 8 | - science/art of ordering tones/sounds in succession, in combination, and in 9 | temporal relationships to produce a composition having unity and continuity 10 | - an organized combination of sound and silent moments 11 | 12 | # Questions on music 13 | 14 | - What ? 15 | * What is music? 16 | - Who ? 17 | * Who listens to music? 18 | * Who makes music? 19 | - When ? 20 | * When do people listen to music? 21 | - Why ? 22 | * Why do people listen to music? 23 | - Where ? 24 | * Where is music made? 25 | * Where do people listen to music? 26 | - How ? 27 | * How is music made? 28 | * How do people listen to music? 29 | 30 | - Neurological disease amusia : music sounds random and noise-like 31 | - Can you deduce information about a person based on music they listen to? 32 | 33 | # Musical Complexity 34 | 35 | - What determines complexity in music? 36 | - Why is Bach complex? 37 | - Trained musicians like more complex music? 38 | * Genre 39 | * Response 40 | * Listener (knowledge, literacy, preferences) 41 | * Situation & Context 42 | - Why music : regulating emotions, social bonding, positive mood, relax 43 | - Addiction and music? 44 | * Why do so many artists engage in substance abuse? 45 | - Individual differences in music (age, personality, learning, rehabilitation) 46 | 47 | # Music as data 48 | 49 | - Music information retrieval 50 | - Computational music analysis 51 | - Physiological collection (heart rate), neuroimaging (fMRI) 52 | - Big data 53 | 54 | - Readings for today's lecture 55 | - Original research 56 | - ismir : point survey papers? 57 | - Overlap with programming language theory? 58 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/10.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 10 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 09/02/2021 5 | --- 6 | 7 | - Genre&Mood2Personality 8 | - Limitations 9 | + 3 months too short duration 10 | - Tag2Personality 11 | - 12 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/11.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 11 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 12/02/2021 5 | --- 6 | 7 | - Music affecting state 8 | - Music and emotions 9 | - Negative emotions in music 10 | - Sad music 11 | - Extreme music 12 | - Listener's conception of sad music may differ from musical features 13 | - Why do people "enjoy" sad music/forms of entertainment? Paradox of tragedy 14 | - Music in grieving 15 | - Music as an instrument for emotional regulation 16 | - Unpleasant music and aversion 17 | - Factors and listeners 18 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/12.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 12 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 16/02/2021 5 | --- 6 | 7 | - Loudness : physical vs perceptual property 8 | - Perception as brain's processing of information 9 | - McGurk effect : visual information affecting auditory information 10 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/13.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 13 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 02/03/2021 5 | --- 6 | 7 | - Shepard tone illusion 8 | - Noise sensitivity scale 9 | - Structure of ear 10 | - Volley Theory 11 | - Critical bands 12 | - Psycho-acoustics and compression 13 | - Auditory pathway 14 | - Auditory cortex of the brain 15 | - Physical characteristics of sound 16 | + Frequency and amplitude 17 | + Loudness and pitch 18 | - Spectral vs virtual pitch (what is not present) 19 | + Virtual pitch : mobile phones, male voices 20 | - Fundamental frequency : pitch of harmonic tunes 21 | - Pitch depends on intensity 22 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/14.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : Music, Mind and Technology - Lecture 14 notes 4 | date : 05/03/2021 5 | --- 6 | 7 | - mel scale : starts at 1000 Hz 8 | - Twice as high pitch gives twice as high mel value 9 | - At higher frequencies larger and larger intervals needed to produce equal 10 | pitch increments 11 | - pitch of harmonic tones approx = fundamental frequency 12 | - pitch depends slightly on intensity 13 | - two kinds of pitch 14 | + spectral 15 | + virtual 16 | - pitch perception happens as a combination of 17 | + place coding : location of maximal oscillation along basilar membrane 18 | + rate coding : periodicity information encoded in neuron firing patterns 19 | - Hearing sensitivity depends heavily on frequency 20 | - Audio masking 21 | + Simultaneous masking : when both occur at same time and close in frequency 22 | + Temporal masking 23 | - Timbre : miscellaneous category for describing psychological attributes of 24 | sounds left over after accounting for pitch, loudness and duration 25 | + Multidimensional 26 | + Complex with no agreed upon definition 27 | + Physically correlates to 28 | * Spectral, temporal envelope 29 | - Auditory hallucinations 30 | + schizophrenia, mood disorders, AD 31 | + Transient (excess caffeine) 32 | + musical ear syndrome 33 | - abnormal activation of normal auditory, language perception and production 34 | pathways 35 | - Causes 36 | + sensory deprivation 37 | + social interaction deprivation 38 | + abuse/bullying/harassment 39 | - Tinnitus 40 | + noises in the head not related to any psychiatric condition 41 | + causes : damage in ear nerves, infections, blood pressure, age related 42 | + treatment : sound therapy, noise markers 43 | + prevention : use ear protection 44 | - Types of hearing loss 45 | + conductive hearing loss 46 | + sensory-neural hearing loss 47 | - Levels of music processing 48 | - Perceptual constancy 49 | - Auditory scene analysis : location, distance 50 | - Gestalt principles 51 | + Gestalt : shape or form 52 | + 1890s : Kurt Koffka, Max Wertheimer, Wolfgang Kohler 53 | + reaction to atomism 54 | + holistic/gestalt : who is something else than the sum of its parts 55 | - Principle of Continuity : humans have a preference for continuous colors 56 | - Principle of Closure : closed entities 57 | - Figure-Ground 58 | - Principle of Common Fate 59 | - Auditory scene analysis 60 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/15.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : Music, Mind and Technology - Lecture 15 notes 4 | date : 09/03/2021 5 | --- 6 | 7 | - Common Fate : spectral components sharing the same FM pattern are probably 8 | associated to the same source and gropued together 9 | - Old-Plus-New Heuristic 10 | - Apparent continuity through perceptual completion : if a spectrum suddenly 11 | becomes more complex or more intense, it is interpreted as the old sound 12 | continuing joined by a new one 13 | - Crossmodal/multisensory integration 14 | - Increased pleasantness of the track and the sweetness and pleasantness of 15 | taste, when the comparison is made as music vs no music. 16 | - https://www.thecut.com/2016/01/drink-your-coffee-and-listen-to-these-two-clips.html 17 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/17.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : Music, Mind and Technology - Lecture 17 notes 4 | date : 12/03/2021 5 | --- 6 | 7 | - Complexity vs interpretability 8 | - Medawar zone 9 | - Machine learning data types : acoustic to semantic 10 | - Listener responses : perceptual, corporeal, neural responses 11 | - Demographic 12 | - Five studies 13 | + Predict emotion from audio 14 | + Organize mood and genre tags 15 | + Predict musical features from brain responses 16 | + Predict musical training from brain responses 17 | + Predict genre and identity from dance kinematics 18 | - Feature selection 19 | + Feature selection \& extraction : music theoretical and statistical. 20 | Examples: 21 | * Low-level : Brightness 22 | * Mid-level : Pulse clarity 23 | * High-level : Key 24 | - Vector space modelling over tags and tracks 25 | - Brain as a distributed system 26 | - fMRI decoding : overfitting 27 | - Subject-level encoding, group-level statistical modeling, region-wise evidence 28 | estimation, region selection, linear classifier 29 | - Genre and personality interacting with dancing styles 30 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/18.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : Music, Mind and Technology - Lecture 18 notes 4 | date : 12/03/2021 5 | --- 6 | 7 | - Temporal vs frequency resolution 8 | - The necessity of windowing : Avoids sudden jumps 9 | - Uncertainty principle 10 | - Computing the STFT 11 | - Genre classification 12 | - Genre prototypical mixtures of sound sources 13 | + Timbre 14 | + Microtimbre : perceptual constancy 15 | + Timbral environments : transactional memories 16 | - Assumptions 17 | + Classes are separable 18 | - Frame based analysis 19 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/19.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : Music, Mind and Technology - Lecture 19 notes 4 | date : 30/03/2021 5 | --- 6 | 7 | - Importance of Timbre 8 | + Perceptual 9 | - Genre identification and categorization 10 | - affect identification 11 | - agree on basic emotion 12 | + Computational 13 | - Genre classification 14 | - Mood, emotion recognition 15 | - Semantics 16 | - Perceptual descriptions of timbre 17 | + Important since commercial uses 18 | + Multi-dimensional space? 19 | - Physical and perceptual correlates of timbre 20 | - Zero-crossing rate 21 | + Number of time-domain zero-crossings of the signal per time unit 22 | - Spectral energy 23 | + Information theoretic 24 | - Spectral flux 25 | + Measure of change over time in spectrum 26 | + Dissimilarity between subsequent spectral frams 27 | - Sub-band flux 28 | + Octave scaled spectrum 29 | + Spectral flux in each band 30 | - Cepstrum 31 | - How is window length important (for classification)? 32 | - Repetition in music 33 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/2.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 2 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 08/01/2021 5 | --- 6 | 7 | - How did music start in the first place? Any evolutionary use? 8 | * 42000 years 9 | * Adaptationist theories : music makes individuals sexually attractive? 10 | * Ritual efficacy, group cohesion, social bonds 11 | * Motherese baby talk 12 | * Mnemonic efficacy 13 | 8605399670 14 | - Musical aptitude : nature vs nurture? 15 | - Musical ability & appreciation : only humans? No, studies on animals 16 | - Functions of music 17 | * Social bonding 18 | * Background noise 19 | * Mnemonics 20 | * To enhance other art forms 21 | * Emotion regulation 22 | * Self reflection 23 | - Embodied Music Cognition 24 | * Sensory-motor experiences shape human consciousness 25 | * Corporeal articulation plays an important role in music cognition 26 | * The role of the human body in relation to all musical activities 27 | - Musical meter and music induced movement 28 | * Study shows toddler reacting to music 29 | - Basic definitions 30 | * Beat : basic rhythmic unit 31 | * Meter : group things into recurring patterns. Combinations of beats 32 | * Tempo : how fast or slow 33 | * Rhythm : music's systematic division in time with everchanging 34 | combinations 35 | - Auditory motor vs visuo motor 36 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/25.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : Music, Mind and Technology - Lecture 25 notes 4 | date : 09/04/2021 5 | --- 6 | 7 | - White matter is the "conductor" for signals in the brain 8 | - Gray matter contains neurons 9 | - Auditory pathways are structurally apart, but functionally connected 10 | - How to investigate the brain: space (noninvasive) vs time trade offs (invasive) 11 | + fMRI 12 | + MEG 13 | + ECoG 14 | + Optical imaging 15 | + LFP 16 | + Spikes 17 | - Exogenous process : determined by stimulus features such as frequency, 18 | intensity 19 | - Endogenous process : reflecting some task-related cognitive processing steps 20 | for which attention is required 21 | - PET : Positron Emission Tomography 22 | + Inject radioactive substance 23 | + Observe metabolism 24 | - MRI : Magnetic Resonance Imaging 25 | + Structural imaging of brain tissue 26 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/3.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 3 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 12/01/2021 5 | --- 6 | 7 | - Auditory motor vs visual motor perception 8 | * Auditory perception invokes rhythmic bodily movement, special affinity 9 | with auditory system 10 | * Evolutionary causes? Better protection from predators 11 | - What factors determine the way you move to music? 12 | * Gender 13 | * Situational context 14 | * Familiarity with music being played 15 | * Language lyrics 16 | * Age 17 | - Converse? Music influences movements? 18 | - Embodiments of metrical levels 19 | * Vertical 2hz 20 | * Limb 1hz 21 | - Gender and movement 22 | - Music Psychology - Musicology 23 | - 19th Century : era of natural sciences and technology, concerned with the 24 | physiological bases of psychological processes 25 | - 20th Century : influences from current scientific approaches including Gestalt 26 | psychology and Behaviorism 27 | - Current : Musicology as independent scientific field, several journals, books, 28 | tech development 29 | - Scientific journals, replicate study in cross cultural context 30 | - Subfields of music psychology 31 | - Music as reflection of the self 32 | - "Music and big data : a new frontier" 33 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/4.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 4 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 15/01/2021 5 | --- 6 | 7 | - Examples of Questions that music psychology asks 8 | + How does music effect us? 9 | + Why are there physiological reactions (tapping feet etc) to music? 10 | + Why is music played in elevators, taxis etc 11 | - Individual differences in music 12 | + Gender 13 | + Age 14 | + Traits 15 | + Cognitive abilities 16 | + States/arousal - excited, calming 17 | + IQ 18 | + Musical training 19 | + Neurological conditions - autism, depression, alzheimer's 20 | - Trait Theory 21 | + Personality = set of traits that remain fairly stable throughout an 22 | individual's life 23 | + Earlier versions : extroversion, neuroticism, psychoticism 24 | + Modern : 25 | * extroversion 26 | * agreeableness 27 | * conscientiousness 28 | * neuroticism - depression etc 29 | * openness to experience - non judgemental appreciation 30 | - Empathy 31 | + Cognitive empathy - rational understanding 32 | + Affective empathy - emotional connection 33 | - Preferences 34 | + Reflective & complex : classical 35 | + Intense rebellious : rap 36 | + Upbeat & conventional : folk 37 | + Energetic & rhythmic : 38 | - MUSIC model 39 | + Mellow : sad, relaxing, unaggressive, romantic 40 | + Unpretentious : simple 41 | + Sophisticated : intelligent, complex, classical 42 | + Intense : loud, aggressive 43 | + Contemporary : electric, electronica 44 | - 20 attribute theory 45 | + 1 46 | + 3 47 | + 3 48 | + 1 49 | + 5 50 | + 3 51 | + 5 52 | + 3 53 | + 5 54 | + 5 55 | + 5 56 | + 1 57 | + 5 58 | + 1 59 | + 5 60 | + 5 61 | + 5 62 | + 5 63 | + 1 64 | + 5 65 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/5.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 1 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | --- 5 | 6 | - Humans are social creatures 7 | - Rhythm as sync mechanism 8 | - Humans good at detecting point like movement 9 | - Music and memory 10 | - Motion capture systems 11 | + Infrared cameras 12 | - Motion affected by 13 | + Genre 14 | + Big 5 personality 15 | - Higher empathy => change dance to match partner 16 | - Music therapy 17 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/6.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 6 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | --- 5 | 6 | - Music & emotions 7 | + What sorts of emotions can music express? 8 | + Can music express emotions without lyrics? 9 | - 4 quadrants model 10 | - Russell's circumplex model, Thayer's model 11 | - Geneva Emotional Music Scales (GEMS) 12 | - Similarities between music and vocal expression 13 | + Human movement and gesture 14 | + Mode - major/minor 15 | + Pitch - high/low 16 | + Contextual associations - weddings, funeral 17 | + Pairing with alternative content 18 | + Personification of music 19 | - Musical features 20 | + Sadness : lower volume, low tempo, less pitch variation, narrow melodic 21 | range, low sound level 22 | + Happiness : upbeat volume, moderate tempo, moderate pitch variation, wide 23 | melodic range, moderate sound level 24 | + Anger : high volume, fast tempo, lot of pitch variation, fast tone attacks 25 | + Tenderness 26 | - Subjective bias for pleasant/unpleasant, but arousal more "objective" 27 | - How does music induce emotions? 28 | + Situation/stimulus $\rightarrow$ interpretation/cognitive appraisal 29 | $\rightarrow$ physiological reaction $\rightarrow$ experience 30 | - Mechanisms - BRECVEMA framework 31 | - Rhythmic entrainment 32 | - Emotional contagion 33 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/7.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 7 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 29/01/2021 5 | --- 6 | 7 | - Mechanisms 8 | + Brain stem reflexes 9 | + Rhythmic entrainment 10 | + Evaluate conditioning 11 | - Emotional contagion 12 | + Same face muscles activated 13 | + Mirror neurons 14 | - Visual imagery 15 | + Process of conjuring visual images 16 | + Strongly influenced by the unfolding structure of the music 17 | - Episodic memory 18 | + Treating mental disorders such as dementia by playing favorite music 19 | - Musical expectancy 20 | - Aesthetic judgement 21 | + Emotions evoked if extraordinarily good or bad 22 | - Measuring emotions 23 | + Self-report - verbal/nonverbal. Limited due to accuracy of introspection, 24 | difficulties and individual differences, demand characteristics 25 | + Physiological measurements - heart rate 26 | + Expression measurement 27 | - Application : emotional well-being, commercialization 28 | - Relevance of context : 29 | + Cross cultural findings : memories, social bonding, catharsis 30 | + Differences in individualistic vs collectivistic culture 31 | + Can music communicate emotional meaning across cultures? yes 32 | + Social experiment 33 | - Evoked emotional experience 34 | 35 | - Misogyny in Rap; glorify objectification 36 | - Misanthropic and Nazism in Black Metal 37 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/8.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 7 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 02/02/2021 5 | --- 6 | 7 | - Extramusical information 8 | - Can music be bad for health? 9 | - Musical addictivity 10 | - Yearning same sort of euphoric highs off-stage as on-stage 11 | - Strong correlation between country music and suicide 12 | - Maladaptive uses of music 13 | + Discharge vs rumination 14 | + Distraction vs avoidance/suppression 15 | - Problem music 16 | + No association between problem music and crime statistics 17 | + Unlikely to cause dysfunctional behaviour, but may create social discourse 18 | to provide platform for those with tendencies 19 | + Rap and rock abuse drugs 20 | + Significant association between poor mental health and preference for 21 | heavy metal music 22 | - Healthy-Unhealthy Music (HUM) scale 23 | - Listening to music for rewards 24 | + What sort of rewards? 25 | + Association between rewards and types of music 26 | + Extramusical and intramusical factors 27 | -------------------------------------------------------------------------------- /music-mind-tech/lectures/9.md: -------------------------------------------------------------------------------- 1 | --- 2 | title : Music, Mind and Technology - Lecture 9 notes 3 | author : Bharathi Ramana Joshi, 2019121006 4 | date : 05/02/2021 5 | --- 6 | 7 | - Music recommendation 8 | - Music information retrieval 9 | - When do you listen to music? 10 | - What order do you listen to music in? 11 | - Signal based metric for information 12 | - Tag based metric for information 13 | - Last FM 14 | - Data reliability 15 | - Tag2Risk 16 | - Gender & risk : Genres 17 | + Different gender, different risks? 18 | - Artist2Risk 19 | - Static vs Dynamic Music listening 20 | - Emotion dynamics 21 | - AudioFeatures2Risk 22 | - TagDynamics2Risk 23 | - Tag/Acousticfeatures2Risk 24 | - Genre2Personality. Where does mood fit in? 25 | -------------------------------------------------------------------------------- /mysql/intro.txt: -------------------------------------------------------------------------------- 1 | \c to cancel a command 2 | commands case insensitive but tables case sensitive 3 | CREATE DATABASE databaseName; 4 | GRANT PRIVILEGES ON databaseName.objectName TO 'username'@'hostname' IDENTIFIED BY 'passwd'; 5 | USE databaseName; 6 | CREATE TABLE tableName 7 | ( 8 | col1 type(size), //note comma 9 | col2 type(size), 10 | col3 type(size) 11 | ) 12 | ENGINE MyISAM; 13 | 14 | Data types:- 15 | (VAR)CHAR 16 | (VAR)BINARY 17 | TINYTEXT 18 | TEXT 19 | MEDIUMTEXT 20 | LONGTEXT 21 | FULLTEXT //for fast searches 22 | TINYBLOB 23 | BLOB 24 | MEDIUMBLOB 25 | LONGBLOB 26 | (UNSIGNED) TINYINT 27 | (UNSIGNED)SMALLINT 28 | (UNSIGNED)MEDIUMINT 29 | (UNSIGNED)INT 30 | (UNSIGNED)BIGINT 31 | (UNSIGNED)FLOAT 32 | (UNSIGNED)DOUBLE 33 | DATETIME 34 | DATE 35 | TIME 36 | TIMESTAMP 37 | YEAR 38 | 39 | FULLTEXT can be used for 40 | 1. MyISAM tables 41 | 2. CHAR, VARCHAR, TEXT 42 | 3. Given at CREATE TABLE or ALTER TABLE ADD 43 | 44 | ALTER TABLE original RENAME final; 45 | ALTER TABLE tableName ADD columnName INT UNSIGNED ; 46 | 47 | INSERT INTO tableName() VALUES(); 48 | INSERT INTO classics(author, title, type, year) 49 | VALUES('Jane Austen','Pride and Prejudice','Fiction','1811'); 50 | 51 | ALTER TABLE tableName MODIFY columnName newDataType; 52 | ALTER TABLE tableName DROP columnName; 53 | DROP TABLE tableName; 54 | ALTER TABLE tableName ADD PRIMARY KEY (columnName()) 55 | ALTER TABLE tableName ADD INDEX(columnName()); 56 | CREATE INDEX columnName ON tableName(columnName()); 57 | SELECT columnList FROM tableName; 58 | SELECT DISTINCT columnList FROM tableName; 59 | DELETE FROM tableName WHERE ; 60 | SELECT columnNames FROM tableName WHERE columnName LIKE 61 | ... LIMIT , ; 62 | ... MATCH() AGAINST('' ); //if bool, + = include and - = exclude 63 | UPDATE tableName SET columnName='new name' WHERE columnName='old name'; 64 | ... ORDER BY columnName ; 65 | ... GROUP BY columnName; 66 | SELECT columnNames FROM tableNames WHERE ; 67 | SELECT columnNames FROM tableName1 NATURAL JOIN tableName2; 68 | SELECT columnNames FROM tableName1 JOIN tableName2 ON ; 69 | ... tableName AS alias ... 70 | AND, OR, NOT can be used in WHERE 71 | -------------------------------------------------------------------------------- /mysql/master.txt: -------------------------------------------------------------------------------- 1 | The process of separating your data into tables and creating primary keys is called normalization. 2 | 3 | First Normal Form:- 4 | 1. There should be no repeating columns containing the same kind of data. 5 | 2. All columns should contain a single value. 6 | 3. Could any of this table's fields require a global update at any point? 7 | -------------------------------------------------------------------------------- /oauth.md: -------------------------------------------------------------------------------- 1 | - OAuth is about authorization, NOT authentication 2 | - OAuth concepts: 3 | * Resource owner 4 | * Resource server 5 | * Grant type: process used to request and grant authorization 6 | * Scope: permission that is being requested (read-write access, profile access, etc) 7 | * Auth server: where grant type and scope are sent for authorization 8 | * Token: string on successful authorization 9 | * Claims: details on authorization granted 10 | - OAuth core 11 | * authorize endpoint: used by end user (resource owner) to grant permission 12 | for application to access resource. Returns authorization code or access code 13 | * token endpoint: used by application to trade authorization code for an 14 | access token 15 | - Optional endpoints: 16 | * userinfo (OpenID core connect) 17 | * discovery: gives all URLs and capabilities of OAuth server 18 | * introspect: get token status 19 | * revoke: used to deactivate a token 20 | - Grant type decision tree: 21 | 1. For a user? No => Client Credential Grant Type 22 | 2. Browser available? No => Device Grant Type 23 | 3. Server-side only? No => Implicit grant type/Authorization code flow with PKCE 24 | Yes => Authorization code flow 25 | - OAuth scope: CRUD or more complicted; scopes are the permissions that we 26 | request not the endpoints that we use. 27 | - E.g. GitHub scopes: repo, public_repo, repo_deployment, repo:invite, etc 28 | - Some other examples: Google scope, okta 29 | - Some types of tokens : 30 | * Access (Core RFC 6749) 31 | * Refresh (Core RFC 6749) 32 | * ID (OpenID connect). JSON Web Token (JWT). 33 | - JWTs need validating. 34 | - Every JWT is made of 3 parts: 35 | * Header (algorithm used to sign) 36 | * Payload (key-value pairs called claims) 37 | * Signature (authentication) 38 | - Do not store sensitive information in JWTs 39 | - Authorization Code Flow: 40 | * 41 | -------------------------------------------------------------------------------- /ocaml/1/README.md: -------------------------------------------------------------------------------- 1 | * If no `Base` or any other external libraries are being used, executable can be 2 | built using 3 | ``` 4 | ocamlopt freq.ml -o freq 5 | ``` 6 | * With `Base` and `Stdio` 7 | ``` 8 | ocamlfind ocamlopt -linkpkg -package base -package stdio freq.ml -o freq 9 | ``` 10 | * With `dune`, have a `dune` file named 11 | ``` 12 | (executable 13 | (name freq) 14 | (libraries base stdio)) 15 | ``` 16 | and do 17 | ``` 18 | dune build freq.exe 19 | ``` 20 | -------------------------------------------------------------------------------- /ocaml/1/tour.ml: -------------------------------------------------------------------------------- 1 | open Stdio 2 | open Base 3 | 4 | let binary_search arr x = 5 | let length = Array.length arr in 6 | let l = ref 0 in 7 | let u = ref length in 8 | let mid = ref ((!l + !u) / 2) in 9 | while !l < !u && !mid < !u do 10 | (mid := ((!l + !u) / 2)) 11 | |> fun () -> 12 | if (arr.(!mid) = x) 13 | then !mid 14 | else if x < arr.(!mid) 15 | then ((u := (!mid - 1)) |> (fun () -> -1)) 16 | else ((l := (!mid + 1)) |> (fun () -> -1)) 17 | done ;; 18 | -------------------------------------------------------------------------------- /ocaml/2/varfunc.ml: -------------------------------------------------------------------------------- 1 | open Stdio 2 | open Base 3 | 4 | (* let bindings can pattern match on LHS *) 5 | let (ints, strings) = List.unzip [(1, "one"); (2, "two"); (3, "three")];; 6 | 7 | (* lambda functions *) 8 | (fun x -> x + 1) 5;; 9 | 10 | (* let binding a function *) 11 | let add1 x = x + 1 in (add1 5);; 12 | (* is just syntactic sugar for *) 13 | let add1 = (fun x -> x + 1) in (add1 5);; 14 | 15 | (* use and to define mutually recursive functions *) 16 | let rec is_even x = 17 | if x = 0 then true else is_odd (x - 1) 18 | and is_odd x = 19 | if x = 0 then false else is_even (x - 1);; 20 | 21 | (* use function to exploit built in pattern matching *) 22 | (* fun takes any number of arguments, but function takes exactly 1 argument *) 23 | let head_or_minus1 = function 24 | | x :: xs -> x 25 | | [] -> -1;; 26 | 27 | let square x = x * x;; 28 | 29 | (* prefix argument name with ~ to make it labelled *) 30 | let calc ~add ~sub ~mul ~init = init + add - sub * mul;; 31 | calc ~init:3 ~sub:5 ~mul:2 ~add:10;; 32 | 33 | (* label punning *) 34 | let init = 3 in 35 | let sub = 5 in 36 | let mul = 2 in 37 | let add = 10 in 38 | calc ~sub ~mul ~add ~init;; 39 | 40 | (* sexy usecase - do partial application without argument flipping business *) 41 | 42 | (* prefix argument name with ? to make it an option *) 43 | (* gotcha: optional args go before other args *) 44 | let optional_add ?y x = 45 | let y = match y with 46 | | None -> 0 47 | | Some z -> z 48 | in x + y;; 49 | -------------------------------------------------------------------------------- /ocaml/3/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name listpattern) 3 | (libraries base stdio)) 4 | -------------------------------------------------------------------------------- /ocaml/3/listpattern.ml: -------------------------------------------------------------------------------- 1 | open Base 2 | open Stdio 3 | 4 | let rec remove_subseq_dups l = 5 | match l with 6 | (* note renaming using as *) 7 | | [] | [_] as l' -> l' 8 | (* note when guard; compiler loses ability to reason about exhaustiveness 9 | etc *) 10 | | h :: (h' :: t) when h = h' -> h :: remove_subseq_dups t 11 | | h :: (h' :: t) when not (h = h') -> h :: remove_subseq_dups (h' :: t);; 12 | 13 | let cuber x = x * x * x;; 14 | -------------------------------------------------------------------------------- /ocaml/4/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name linecounter) 3 | (libraries base stdio)) 4 | -------------------------------------------------------------------------------- /ocaml/4/ext_opt.ml: -------------------------------------------------------------------------------- 1 | open Base 2 | 3 | let apply f_opt x = 4 | match f_opt with 5 | | None -> None 6 | | Some f -> Some (f x) 7 | 8 | include Option 9 | -------------------------------------------------------------------------------- /ocaml/4/ext_opt.mli: -------------------------------------------------------------------------------- 1 | open Base 2 | 3 | include (module type of Option) 4 | 5 | val apply : ('a -> 'b) t -> 'a -> 'b t 6 | -------------------------------------------------------------------------------- /ocaml/4/hidden_core.ml: -------------------------------------------------------------------------------- 1 | open Base 2 | 3 | type t = (string * int) list 4 | 5 | let empty = [] 6 | 7 | let to_list x = x 8 | 9 | let touch counts line = 10 | let count = 11 | match List.Assoc.find ~equal:String.equal counts line with 12 | | None -> 0 13 | | Some x -> x 14 | in 15 | List.Assoc.add ~equal:String.equal counts line (count + 1) 16 | -------------------------------------------------------------------------------- /ocaml/4/hidden_core.mli: -------------------------------------------------------------------------------- 1 | open Base 2 | 3 | (* one way to define abstract type - expose name, not definition *) 4 | type t 5 | 6 | val empty : t 7 | 8 | (* touch increments count of line by one *) 9 | val touch : t -> string -> t 10 | 11 | val to_list : t -> (string * int) list 12 | -------------------------------------------------------------------------------- /ocaml/4/included.ml: -------------------------------------------------------------------------------- 1 | open Base 2 | 3 | module Interval = struct 4 | type t = | Interval of int * int 5 | | Empty 6 | 7 | let create low high = 8 | if high < low then Empty else Interval (low, high) 9 | end;; 10 | 11 | module Extended_interval_i = struct 12 | include Interval 13 | 14 | let contains t x = 15 | match t with 16 | | Empty -> false 17 | | Interval (low, high) -> x >= low && x <= high 18 | end;; 19 | 20 | module Extended_interval_o = struct 21 | open Interval (* include is not same as open! *) 22 | 23 | let contains t x = 24 | match t with 25 | | Empty -> false 26 | | Interval (low, high) -> x >= low && x <= high 27 | end;; 28 | 29 | (* gives true *) 30 | Extended_interval_i.contains (Extended_interval_i.create 3 10) 4;; 31 | 32 | (* doesn't work, Extended_interval_o doesn't have create *) 33 | Extended_interval_o.contains (Extended_interval_o.create 3 10) 4;; 34 | -------------------------------------------------------------------------------- /ocaml/4/linecounter.ml: -------------------------------------------------------------------------------- 1 | open Base 2 | open Stdio 3 | 4 | let build_counts = fun () -> 5 | In_channel.fold_lines In_channel.stdin ~init:Hidden_core.empty ~f:Hidden_core.touch 6 | (* module names are capitalized even if filenames aren't! *) 7 | 8 | let () = 9 | build_counts () 10 | |> Hidden_core.to_list 11 | |> List.sort ~compare:(fun (_,x) (_,y) -> Int.descending x y) 12 | |> (fun l -> List.take l 10) 13 | |> List.iter ~f:(fun (line, count) -> printf "%3d: %s\n" count line);; 14 | -------------------------------------------------------------------------------- /ocaml/4/nested.ml: -------------------------------------------------------------------------------- 1 | open Base 2 | open Stdio 3 | module Time = Core_kernel.Time 4 | 5 | module type Username = sig 6 | type t 7 | val of_string : string -> t 8 | val to_string : t -> string 9 | val (=) : t -> t -> bool 10 | end 11 | 12 | module type ID = sig 13 | type t 14 | val of_string : string -> t 15 | val to_string : t -> string 16 | val (=) : t -> t -> bool 17 | end 18 | 19 | module String_id = struct 20 | type t = string 21 | let of_string x = x 22 | let to_string x = x 23 | let (=) = String.(=) 24 | end 25 | 26 | module Username : ID = String_id 27 | module Hostname : ID = String_id 28 | 29 | type session_info = { user : Username.t; 30 | host : Hostname.t; 31 | when_started : Time.t; 32 | } 33 | 34 | let sessions_have_same_user s1 s2 = 35 | Username.(=) s1.user s2.user 36 | 37 | (* also possible to have different implementations for the same signature! *) 38 | (* module types is analogous to Haskell type classes *) 39 | (* bunch of declarations that any instance is obligated to implement*) 40 | module type MySet = sig 41 | type set 42 | type elt 43 | val insert_set : set -> elt -> set 44 | val lookup_set : set -> elt -> bool 45 | val to_list : set -> elt list 46 | val from_list : elt list -> set 47 | end 48 | 49 | (* actual implementation/instance *) 50 | module List_string_set = struct 51 | type elt = string 52 | type set = elt list 53 | let insert_set s e = 54 | if List.mem s e String.(=) 55 | then s 56 | else e :: s 57 | let rec lookup_set = 58 | fun s e -> match s with 59 | | [] -> false 60 | | h :: t -> (String.(=) e h) || lookup_set t e 61 | let to_list x = x 62 | let from_list x = x 63 | end 64 | 65 | module LSS : MySet = List_string_set 66 | -------------------------------------------------------------------------------- /ocaml/5/5.ml: -------------------------------------------------------------------------------- 1 | open Core 2 | 3 | type etc_services_info = 4 | { 5 | service_name : string; 6 | port : int; 7 | protocol : string; 8 | } 9 | 10 | (* Records support parametric polymorphism! *) 11 | type 'a with_line_num = 12 | { 13 | item : 'a; 14 | line_num : int; 15 | } 16 | 17 | let extract line = 18 | let open Re in 19 | let matches = 20 | let pat = "([a-zA-Z]+)[ \t]+([0-9]+)/([a-zA-Z]+)" in 21 | Re.exec (Re.Posix.compile_pat pat) line 22 | in 23 | { service_name = Re.Group.get matches 1; 24 | port = Int.of_string (Re.Group.get matches 2); 25 | protocol = Re.Group.get matches 3; 26 | };; 27 | 28 | let x = extract "inspider 49150/tcp";; 29 | printf "%s\n" x.service_name;; (* Use dot syntax to access elements *) 30 | 31 | (* Irrefutable record pattern matching *) 32 | let extraction_to_string { service_name = name; port = port; protocol = prot } = 33 | sprintf "%s %i/%s" name port prot;; 34 | 35 | (* Field punning *) 36 | let punned_extraction_to_string { service_name ; port ; protocol } = 37 | sprintf "%s %i/%s" service_name port protocol;; 38 | 39 | (* Easy functional updates! *) 40 | let e = extract "iqobject 48619/udp";; 41 | let e1000 = {e with port = 1000};; 42 | 43 | type m_etc_services_info = 44 | { 45 | service_name : string; 46 | mutable port : int; (* note mutable keyword usage *) 47 | protocol : string; 48 | } 49 | 50 | (* Note that it uses latest record definition when field names are same. To 51 | * choose, use type annotations *) 52 | let e = {service_name = "foo"; port = 50; protocol = "bar"};; 53 | (* Can mutate as follows *) 54 | e.port <- 25;; 55 | -------------------------------------------------------------------------------- /ocaml/modules.md: -------------------------------------------------------------------------------- 1 | - An anonymous module signature is created by `sig D1;...;Dn end` 2 | where each `Di` is either a type declaration or a value declaration. A module 3 | signature can be named using `module type SignatureName = sig D1;...;Dn end`. 4 | - An anonymous module is created by `struct D1;...;Dn end` where each `Di` is a 5 | definition. A module can be named using `module ModuleName = struct 6 | D1;...;Dn end`. 7 | - A module can be annotated by a signature iff it defines every declaration 8 | in the signature (it can however have extra definitions, which cannot be 9 | accessed from outside the module). 10 | -------------------------------------------------------------------------------- /ocaml/old-mds/files-modules-programs.md: -------------------------------------------------------------------------------- 1 | `let () = ` serves the purpose of `main` from C/C++ 2 | 3 | If `Core` or any other external libraries are not being used, the executable can 4 | be built using 5 | ``` 6 | ocamlc freq.ml -o freq.byte 7 | ``` 8 | 9 | When using external libraries etc, use 10 | ``` 11 | ocamlfind ocamlc -linkpkg -thread -package core freq.ml -o freq.byte 12 | ``` 13 | 14 | A module is a collection of definitions that are stored within a namespace 15 | 16 | A module defined by a file `filename.ml` can be constrained by a signature 17 | placed in a file called `filename.mli` 18 | 19 | `val` declarations are used to specify values in a signature. Syntax 20 | ``` 21 | val : 22 | ``` 23 | 24 | A type is abstract if its name is exposed in the interface, but its definition 25 | is not. 26 | 27 | # Module declaration syntax 28 | 29 | Syntax: `module : = `. 30 | Example: 31 | ``` 32 | open Base 33 | module Time = Core_kernel.Time 34 | 35 | module type ID = sig 36 | type t 37 | val of_string : string -> t 38 | val to_string : t -> string 39 | val (=) : t -> t -> bool 40 | end 41 | 42 | module String_id = struct 43 | type t = string 44 | let of_string x = x 45 | let to_string x = x 46 | let (=) = String.(=) 47 | end 48 | 49 | module Username : ID = String_id 50 | module Hostname : ID = String_id 51 | 52 | type session_info = { user: Username.t; 53 | host: Hostname.t; 54 | when_started: Time.t; 55 | } 56 | ``` 57 | # Opening modules 58 | - Local open has two synatxes 59 | ``` 60 | let average x y = 61 | let open Int64 in 62 | (x + y) / of_int 2;; 63 | 64 | let averga x y 65 | Int64.((x + y) / of_int 2);; 66 | ``` 67 | - Names can also be rebinded locally 68 | ``` 69 | let print_median m = 70 | match m with 71 | | Counter.Median string -> printf "True median: %s\n" string 72 | | Counter.Before_and_after (b, a) -> printf "Before after: %s %s\n" b a 73 | 74 | let local_print_median m = 75 | let module C = Counter in 76 | match m with 77 | | C.Median string -> printf "True median: %s\n" string 78 | | C.Before_and_after (b, a) -> printf "Before after: %s %s\n" b a 79 | ``` 80 | -------------------------------------------------------------------------------- /ocaml/old-mds/records.md: -------------------------------------------------------------------------------- 1 | * A record represents a collection of values stored together as one, where each 2 | component is identified by a different field name. 3 | * Syntax 4 | ``` 5 | type = 6 | { 7 | : ; 8 | : ; 9 | } 10 | ``` 11 | * Example 12 | ``` 13 | type host_info = 14 | { 15 | hostname : string; 16 | os_name : string; 17 | cpu_arch : string; 18 | };; 19 | ``` 20 | * Elements from the record field can be extracted using the dot notation 21 | ``` 22 | my_host.cpu_arch;; 23 | - : string = "unknown" 24 | ``` 25 | * Types can be parameterized for polymorphism 26 | ``` 27 | type 'a with_line_num = { item: 'a; line_num : int};; 28 | let parse_lines parse file_contents = 29 | let lines = String.split ~on:'\n' file_contents in 30 | List.mapi lines ~f:(fun line_num line -> 31 | { item = parse line; 32 | line_num = line_num + 1; 33 | }) 34 | ;; 35 | parse_lines service_info_of_string 36 | "rtmp 1/ddp # Routing Table Maintenance Protocol 37 | tcpmux 1/udp # TCP Port Service Multiplexer 38 | tcpmux 1/tcp # TCP Port Service Multiplexer" 39 | ;; 40 | parse_lines Int.of_string "1\n10\n100\n1000";; 41 | ``` 42 | * Pattern matching 43 | ``` 44 | let service_info_to_string { service_name = name; port = port; protocol = prot } = 45 | sprintf "%s %i/%s" name port prot 46 | ``` 47 | - Patterns can mention only a subset of fields 48 | # Functional update 49 | ``` 50 | { with = ; 51 | = ; 52 | ... 53 | } 54 | ``` 55 | # Mutable fields 56 | - Use the `mutable` keyword for declaring a field as mutable 57 | - Use the `<-` for side-effecting update 58 | ``` 59 | let register_heartbeat t hb = 60 | t.last_heartbeat_time <- hb.Heartbeat.time; 61 | t.last_heartbeat_status <- hb.Heartbeat.status_message 62 | ;; 63 | ``` 64 | -------------------------------------------------------------------------------- /papers/la-tour-d-hanoi.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Notes on the paper "Functional Pearl: La Tour D'Hanoi"' 3 | author: Bharathi Ramana Joshi 4 | --- 5 | 6 | https://docs.google.com/presentation/d/1Xwm4XES3nXU_P6AqDk0uN_7wKNc2KicR7tp-2BAKz6I/edit?usp=sharing 7 | -------------------------------------------------------------------------------- /papers/logic-prog-survey.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Notes on the paper "Complexity and Expressive Power of Logic Programming"' 3 | author: Bharathi Ramana Joshi 4 | --- 5 | 6 | - Term: 7 | + Logic variables (`X`, `Y`, `Z`, ...). 8 | + Propositional constants (`a`, `b`, `c`, ...). 9 | + Functions, which take terms corresponding to its arity; i.e. 10 | `f(t1,...,tn)` is a term if `f` is an n-ary function symbol and `ti` are 11 | all terms. 12 | - A term is ground if it has no logic variables. 13 | - Herbrand universe of $L$, denoted by $U_L$ is the set of all ground terms that 14 | can be formed with functions and constants in $L$. 15 | - Atom: formula `p(t1,...,tn)` where `p` is a predicate symbol of arity `n` and 16 | all of `ti` are terms 17 | - Herbrand base of $L$, denoted by $B_L$, is the set of all ground atoms that 18 | can be formed with predicates from $L$ and terms from $U_L$. 19 | - Horn clause: `Head <- Body`, which means `Body => Head`. 20 | - Horn clause: `A0 <- A1,...,Am`, each `Ai` is an atom. 21 | - A Horn clause of the form `A0 <-` is a fact, and a ground fact if `A0` is 22 | ground. 23 | -------------------------------------------------------------------------------- /papers/predicate-logic-as-pl.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Notes on the paper "Predicate Logic as Programming Language"' 3 | author: Bharathi Ramana Joshi 4 | --- 5 | 6 | - Axioms : solver for problems 7 | - Theorems : individual problems to be solved 8 | - Proofs : computations generated by the solver 9 | 10 | # Syntax 11 | 12 | - Constants ::= 0-ary function symbols 13 | - Predicate symbols, function symbols, variables : three mutually disjoint sets 14 | of symbols 15 | - Term ::= variable 16 | | f(t1,...,tk) where f is function symbol and ti are terms 17 | - Atomic formula ::= P(t1,...,tk) where P is predicate symbol and ti are terms 18 | - Clause : pair of sets of atomic formulas, e.g. 19 | ``` 20 | B1, ..., Bm <- A1, ..., An 21 | ``` 22 | - Sentence in clausal form : set of clauses 23 | 24 | # Semantics 25 | 26 | - LHS (`B1, ..., Bm`) is disjunctions of atomic formulae 27 | - RHS (`A1, ..., An`) is conjunctions of atomic formulae 28 | - `<-` as implication 29 | - Thus read 30 | ``` 31 | B1, ..., Bm <- A1, ..., An 32 | ``` 33 | As 34 | ``` 35 | forall x1, ..., xk, B1 or ... or Bm 36 | is implied by A1 and ... and An 37 | ``` 38 | 39 | # Interesting phrases 40 | 41 | - "To communicate, the programmer had to learn the psychology of the machine and 42 | to express his problems in machine-oriented terms" 43 | 44 | # Thoughts 45 | 46 | - Literally all of miniKanren is described in this paper that came out in 1974 47 | -------------------------------------------------------------------------------- /papers/teaching-gc-without.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Notes on the paper "Teaching Garbage Collection without 3 | Implementing Compilers or Interpreters"' 4 | author: Bharathi Ramana Joshi 5 | --- 6 | 7 | - Outcomes 8 | + Minimize dependencies : to learn GC first learn compilers/interpreters 9 | + Flexible : should be able to explore alternate collecting strategies 10 | + Explorable : should handle non-trivial programs 11 | + Testing \& debugging : should be interchangeable with real garbage 12 | collector to debug 13 | - Methodology 14 | + The API 15 | -------------------------------------------------------------------------------- /prolog/ch1.pl: -------------------------------------------------------------------------------- 1 | % predicate (argument, argument ...) 2 | 3 | likes(bharath, lisp). 4 | likes(mary, jane). 5 | likes(jane, john). 6 | likes(mary, wine). 7 | likes(steph, wine). 8 | 9 | % rule = head :- body 10 | % , for conjunction 11 | likes(john, X) :- female(X), likes(X, wine). 12 | 13 | valuable(gold). 14 | valuable(silver). 15 | owns(jane, gold). 16 | father(john, mary). 17 | father(john, jane). 18 | gives(john,book,mary). 19 | 20 | male(albert). 21 | male(edward). 22 | 23 | female(jane). 24 | female(mary). 25 | female(alice). 26 | female(victoria). 27 | 28 | parents(edward, victoria, albert). 29 | parents(alice, victoria, albert). 30 | parents(bob, jane, edward). 31 | 32 | sister_of(X, Y) :- 33 | female(X), 34 | parents(X, M, F), 35 | parents(Y, M, F). 36 | 37 | is_mother(X) :- 38 | female(X), 39 | parents(_, X, _). 40 | is_father(X) :- 41 | male(X), 42 | parents(_, _, X). 43 | is_son(X) :- 44 | male(X), 45 | parents(X, _, _). 46 | grandpa_of(X, Y) :- 47 | male(X), 48 | parents(C, _, X), 49 | parents(Y, C, _) ; parents(Y, _, C). 50 | -------------------------------------------------------------------------------- /prolog/old-mds/1.md: -------------------------------------------------------------------------------- 1 | * In Prolog, an object refers to things that we can represent using *terms* 2 | * Computer programming in Prolog consists of 3 | - specifying some **facts** about objects and their relationships 4 | - defining some **rules** about objects and their relationships 5 | - asking questions about objects and their relationships 6 | # Facts 7 | ``` 8 | likes(john, mary). 9 | ``` 10 | * John likes Mary 11 | * The names of all relationships and objects must begin with a lower-case letter 12 | * The relationship is written first, the objects written separated by commas 13 | * The dot character must come at the end of a fact 14 | * Pick an arbitrary convention and stick to it - `likes(john, mary) != 15 | likes(mary, john)` 16 | * Names of the objects that are enclosed within the round brackets in each fact 17 | are called **arguments** 18 | * The name of the relationship is called the **predicate** 19 | * A collection of facts is called a **database** 20 | # Questions 21 | ``` 22 | ?-owns(mary, book). 23 | ``` 24 | * We can ask some **questions** about facts 25 | * A question looks just like a fact, except that we put a special symbol before 26 | it - a question mark followed by a hyphen 27 | * A question looks for facts that **unify** the fact in question 28 | * Two facts **unify** if their predicates are the same, and if their 29 | corresponding arguments each are the same 30 | # Variables 31 | ``` 32 | likes(john, mary). 33 | likes(john, eliza). 34 | ?-likes(john, X). 35 | X=mary?; 36 | X=eliza 37 | ``` 38 | * Terms that stand for objects that we are unwilling or unable to name are 39 | called **variables** 40 | * A variable can either be **instantiated** (there is an object that the 41 | * variable stands for) or **not instantiated** (what the variable stands for is 42 | not yet known). 43 | * Any name beginning with a capital letter is a variable 44 | # Conjunctions 45 | ``` 46 | likes(mary, chocolate). 47 | likes(mary, wine). 48 | likes(john, wine). 49 | likes(john, mary). 50 | ?-likes(john, mary), likes(mary, john). 51 | ``` 52 | * Use `,` to expresses conjunction 53 | * Each goal keeps its own place-marker 54 | * When working with a conjunction, Prolog attempts to satisfy each goal in turn, 55 | working from left to right 56 | # Rules 57 | * A **rule** is a general statement about objects and their relationships 58 | * A **rule** consists of a **head** and a **body** connected by a `:-` (if) 59 | -------------------------------------------------------------------------------- /rap/code/2.ml: -------------------------------------------------------------------------------- 1 | let c = .<1 + 2>.;; 2 | 3 | let rec power n x = 4 | if n == 0 then 1 5 | else if n mod 2 == 0 6 | then square (power (n / 2) x) 7 | else x * (power (n - 1) x);; 8 | 9 | let rec spower n x = 10 | if n == 0 then .<1>. 11 | else if n mod 2 == 0 12 | then .. 13 | else .<.~x * .~(spower (n - 1) x)>.;; 14 | 15 | let spowern = fun n -> . .~(spower n ..)>.;; 16 | -------------------------------------------------------------------------------- /rap/code/power_rts.ml: -------------------------------------------------------------------------------- 1 | let perf : (unit -> a) -> a = fun th -> 2 | let start_time = Sys.time() in 3 | let r = th () in 4 | let elapsed_time = Sys.time() - start_time in 5 | Printf.printf "\nit took %g secs\n" elapsed_time; 6 | r 7 | -------------------------------------------------------------------------------- /rap/code/square.ml: -------------------------------------------------------------------------------- 1 | let square x = x * x;; 2 | 3 | -------------------------------------------------------------------------------- /rap/square.cmi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/rap/square.cmi -------------------------------------------------------------------------------- /rap/square.cmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/rap/square.cmo -------------------------------------------------------------------------------- /rebel-sultans.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : "Notes on : Rebel Sultans" 4 | --- 5 | 6 | > The Deccan, to the world, was uniquely Indian; to India, however, it was a 7 | > mirror of the world 8 | -------------------------------------------------------------------------------- /republic/1.md: -------------------------------------------------------------------------------- 1 | # Persons 2 | 3 | 1. Socrates, the narrator 4 | 2. Glaucon 5 | 3. Adeimantus 6 | 4. Polemarchus 7 | 5. Cephalus 8 | 6. Thrasymachus 9 | 7. Cleitophon 10 | 11 | --- 12 | 13 | Cephalus: How does love suit with age, Sophacles, - are you still the man you 14 | wer? 15 | 16 | Sophacles: Peace; most gladly have I escaped the thing of which you speak; I 17 | feel as if I had escaped from a mad and furious master. 18 | 19 | --- 20 | -------------------------------------------------------------------------------- /rubik.md: -------------------------------------------------------------------------------- 1 | - Cubie: single 1x1x1 cube 2 | * 26 total 3 | * 8 corner cubies - urf 4 | * 12 edge cubies - ur 5 | * 6 center cubies - f 6 | - Oriented => urf != ruf != fur 7 | - Unoriented => urf = ruf = fur 8 | - Cubicles : spaces where cubies live, actions don't change cubicles only cubes 9 | - Move names: 10 | * R : clockwise right 11 | * U : clockwise up 12 | * F : clockwise front 13 | * B : clockwise back 14 | * L : clockwise left 15 | * D : clockwise down 16 | - Move are mod 4 17 | - Cubicle position is invariant under moves : edge cubie cannot be moved into corner cubicle and vice versa 18 | - Corner cubies configurations : 3^8 possible orientations * 8! cubicles 19 | - Edge cubies configurations : 2^12 position orientations * 12! cubicles 20 | - Total = 5.19 * 10^20 21 | - Valid configuration : can be achieved by a sequence of moves 22 | 23 | # Rubik's group 24 | - Set = all possible moves 25 | - Operation = move composition, i.e. M1 * M2 => do M1 then M2 26 | - M(C) cubicle that the oriented cubie C ends up in after move M. E.g. 27 | R(ur) = br 28 | - Commutator : [M1M2] = M1M2M1^-1M2^-1 29 | - Valid configuration is determined by 30 | * Position of corner cubies : S8 31 | * Position of edge cubies : S12 32 | * Orientation of corner cubies 33 | * Orientation of edge cubies 34 | 35 | - (1,2,3,4,5,6,7,8) 36 | - (0,0,0,0,0,0,0,0) 37 | -------------------------------------------------------------------------------- /russell-happy.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : Notes on Bertrand Russell's *The Conquest of Happiness* 4 | --- 5 | 6 | # What makes people unhappy? 7 | 8 | - External discipline is the only road to happiness for those unfortunates whose 9 | self-absorption is too profound to be cured in any other way 10 | - The Sinner : One who is absorbed in the consciousness of sin. Unattainable 11 | object - mother figure's approval 12 | - The Narcissist : Vanity kills pleasure in every activity for its own sake and 13 | leads to listlessness and boredom. Cure is self-respect 14 | - The megalomaniac : Desire for power than charm 15 | - The typical unhappy man is one who, having been deprived in youth of some 16 | normal satisfaction, has come to value this one kind of satisfaction more 17 | than any other, and has therefore given to his life a one-sided direction, 18 | together with a quite undue emphasis upon the achievement as opposed to the 19 | activities connected with it. 20 | 21 | # Byronic unhappiness 22 | 23 | - The wise man will be as happy as circumstances permit 24 | - Mood vs its intellectual expression 25 | - Struggle and unfulfilled desires are part of life, but they don't *have* to be 26 | the *meaning* of life 27 | - Trying to define the present as something only useful to give meaning to the 28 | future is a disaster 29 | 30 | # Competition 31 | 32 | - Comparing the competitive businessman with the Hindu widow 33 | - Too much emphasis on competitive success as the main source of happiness, 34 | ironically, leads to unhappiness 35 | - Education as a training in the capacity for enjoyment 36 | 37 | # Boredom and excitement 38 | 39 | - 40 | -------------------------------------------------------------------------------- /savsi.md: -------------------------------------------------------------------------------- 1 | # Chapter 1 : The Status of Sociology 2 | 3 | - Characteristics of a good scientific theory 4 | 1. internally consistent 5 | 2. in accord with evidence 6 | 3. constantly evolving - no true now and forever 7 | 4. abandon failed theories 8 | - Limitations of basing sociology on physical sciences 9 | 1. Cannot perform experiments 10 | * Social experiment is itself a social event 11 | * Too complex to be broken down into simple isolated components for 12 | further examination 13 | 2. Identifying regularities is not enough - *why* those regularities exist 14 | is a deeper question 15 | 3. Circular problem - any attempt to study sociological phenomena 16 | contaminates the evidence, since attempting itself requires social 17 | interaction 18 | -------------------------------------------------------------------------------- /scala/2.md: -------------------------------------------------------------------------------- 1 | * Scala has two kinds of variables, vals and vars 2 | - `val` variable cannot be changed after it has been defined 3 | - `var` can be reassigned throughout its lifetime 4 | * Type inference is the ability to figure out types that are left out 5 | * In Scala, a variable's type is specified after its name 6 | ``` 7 | val msg: String = "Hello again, world!" 8 | ``` 9 | * Functions are defined as follows (note that the Scala compiler does not infer 10 | function parameter types) 11 | ``` 12 | def max(x: Int, y: Int): Int = { 13 | if (x > y) x 14 | else y 15 | } 16 | ``` 17 | * If a function is recursive, its return type must be explicitly specified 18 | * If a contains just one sentence, curly braces can be left off 19 | ``` 20 | def max2(x: Int, y: Int) = if (x > y) x else y 21 | ``` 22 | * Command line arguments are available via an array named `args` 23 | * A *function literal* is created as follows 24 | ``` 25 | (x: Int, y: Int) => x + y 26 | ``` 27 | * `foreach` can be used on arrays as follows 28 | ``` 29 | args.foreach(println) 30 | ``` 31 | * A *for expression* is used as follows 32 | ``` 33 | for (arg <- args) 34 | println(arg) 35 | ``` 36 | -------------------------------------------------------------------------------- /scala/3.md: -------------------------------------------------------------------------------- 1 | * Objects/class instances can be instantiated using `new` 2 | ``` 3 | val big = new java.math.BigInteger("123456") 4 | ``` 5 | * Arrays are indexed by `()`, not `[]` 6 | ``` 7 | val greetStrings: Array[String] = new Array[String](3) 8 | greetStrings(0) = "Hello" 9 | greetStrings(1) = ", " 10 | greetStrings(2) = "world!\n" 11 | for(i <- 0 to 2) 12 | print(greetStrings(i)) 13 | ``` 14 | 15 | `val` variables can't be reassigned, but the object to which it refers could 16 | potentially still be changed. 17 | -------------------------------------------------------------------------------- /sdff/sdff.md: -------------------------------------------------------------------------------- 1 | --- 2 | author : Bharathi Ramana Joshi 3 | title : "Notes on : Software Design for Flexibility" 4 | --- 5 | 6 | # Flexibility in Nature and in Design 7 | 8 | - Additive programming : one should not modify an existing program, but be able 9 | to add to it to implement new functionality 10 | - To suppress noise, make the outputs of one phase small and well defined than 11 | the acceptable inputs of the next phase. "Be conservative in what you do, be 12 | liberal in what you accept from others." 13 | - Long term costs are additive rather than multiplicative 14 | - Generic dispatch : have distinct response procedures for disjoint sets of 15 | inputs and dispatch the appropriate procedure 16 | - Degeneracy : have multiple ways to compute something, which can be combined or 17 | modulated as needed 18 | - Parti : an abstract plan for the computations to be performed 19 | - Postel's law : be conservative in what you do, be liberal in what you accept 20 | from others 21 | 22 | # Domain-Specific Languages 23 | 24 | - Use general parts by configuring them dynamically to environment changes 25 | - Combinators : set of primitive parts + set of means of combining parts such 26 | that combined parts have same interface as primitive parts 27 | - Advantages of organizing a system around combinators 28 | + Parts can be arbitrarily mixed and matched, all combinations yield valid 29 | programs 30 | + Context in which part appears does not change the part's behaviour 31 | + Extensible since new parts don't affect existing parts 32 | - 33 | -------------------------------------------------------------------------------- /sed/1.md: -------------------------------------------------------------------------------- 1 | * Sed works by making only one pass over the input(s) 2 | * Running: `sed SCRIPT INPUTFILE` 3 | * If INPUTFILE is not specified or is `-`, sed filters the contents of the 4 | standard input 5 | * By default, `sed` writes to standard output. Use `-i` to edit files in-place 6 | * By default, `sed` prints all processed input. Use `-n` to suppress output and 7 | `-p` to print specific lines 8 | * Sed treats multiple input files as one long stream 9 | # Command-Line Options 10 | The full format for invoking `sed` is 11 | ``` 12 | sed OPTIONS... [SCRIPT] [INPUTFILE...] 13 | ``` 14 | | Option | Summary | 15 | | ------ | ------- | 16 | | `--help` | Print usage message | 17 | | `-n`, `--quiet`, `silent` | Suppress output printing | 18 | | `-e script`, `--expression=script` | Add commands in *script* to set of commands to be run while processing the input | 19 | | `-f script-file` | Add commands in *script-file* to set of commands to be run while processing the input | 20 | | `-i`, `--in-place` | Edit file in-place | 21 | | `l N`, `--line-length=N` | Specify default line-wrap length for the l command | 22 | | `--posix` | Disable all GNU extensions on sed | 23 | | `-b`,`--binary` | Open input files in binary mode | 24 | | `--follow-symlinks` | Follw symbolic link (default behaviour to break link) | 25 | | `-E`, `-r`, `--regexp-extended` | Specify extended regular expressions, the ones accepted by egrep | 26 | | `-s`, `--separate` | GNU sed extension to treate mulitple files separately | 27 | | `--sandbox` | Reject `e/w/r` commands and disable external programs | 28 | | `-u`, `--unbuffered` | Buffer both input and output as minimally as practical | 29 | | `-z`, `--zero-terminated`, `--null-data` | Treat input as a set of null terminated lines instead of newline terminated lines | 30 | -------------------------------------------------------------------------------- /sed/3.md: -------------------------------------------------------------------------------- 1 | * `sed` commands follow the syntax 2 | ``` 3 | [addr]X[options] 4 | ``` 5 | * `X` is a single-letter `sed` command 6 | * `[addr]` is an optional line address - it can be single line number, a regex, 7 | or a range of lines 8 | * `[options]` are used for some `sed` commands 9 | 10 | * Commands within a `script-file` can be separated by `;` or newlines, multiple 11 | scirpts can be specified using `-e` or `-f` option 12 | 13 | ## Commands summary 14 | | Command | Description | 15 | | ------- | ----------- | 16 | | `a text` | Append text after line | 17 | | `b label` | Branch unconditionally to `label` | 18 | | `c text` | Change lines with `text` | 19 | | `d` | Delete pattern space and immediately start next cycle | 20 | | `D`| If pattern space contains newlines, delete text in the pattern space up to the first newline, and restart cycle with the resultant pattern space, without reading a new line of input | 21 | | `e` | Executes the command that is found in pattern space and replaces the pattern space with the output; a trailing newline is suppressed | 22 | | `e command` | Executes command and sends its output to the output stream | 23 | | `F` | Print __filename__ of current input file | 24 | | `g` | Replace the contents of the pattern space with the contents of the hold space | 25 | | `G` | Append a newline to the contents of the pattern space, and then append the contents of the hodl space of that pattern space | 26 | | `h` | Replace the contents of the hold space with the contents of the pattern space | 27 | | `H` | Append a newline to the contents of the hold space, and then append the contents of the pattern space to that of the hold space | 28 | | `i text` | Insert text before a line | 29 | | `l` | Print the pattern space in an unambiguous form | 30 | # The `S` Command 31 | The substitute command has the syntax - `s/regexp/replacement/flags` 32 | -------------------------------------------------------------------------------- /setl/2.md: -------------------------------------------------------------------------------- 1 | # Variables 2 | 3 | ``` 4 | x := 3.1415; 5 | r := 2; 6 | y := x * r * r; 7 | ``` 8 | 9 | # Integer operations 10 | 11 | | Operation | Explanation | 12 | | -------- | ----------- | 13 | | `i + j` | sum | 14 | | `i - j` | difference | 15 | | `i * j` | product | 16 | | `i ** j` | power | 17 | | `i mod j` | integer division | 18 | | `i div j` | modulus | 19 | | `i max j` | max | 20 | | `i min j` | min | 21 | | `abs i` | absolute value | 22 | | `even i` | is even? | 23 | | `odd i` | is odd? | 24 | | `random i` | random number b/w 0 and i | 25 | 26 | # Integer predicates 27 | 28 | `=`, `/=`, `>`, `<`, `<=`, `>=`, `even` 29 | 30 | # Float operations (in addition to integer) 31 | 32 | 33 | | Operation | Explanation | 34 | | -------- | ----------- | 35 | | `i atan2 j` | tan inverse of `i/j` | 36 | | `floor i` | | 37 | | `ceil i` | | 38 | | `fix i` | | 39 | | `exp i` | | 40 | | `log i` | | 41 | | `cos i` | | 42 | | `sin i` | | 43 | | `tan i` | | 44 | | `acos i` | | 45 | | `asin i` | | 46 | | `atan i` | | 47 | | `tanh i` | | 48 | | `sqrt i` | | 49 | | `random i` | random float [0, x) | 50 | | `sign i` | +1,-1,0 indicating `i`'s sign | 51 | 52 | # String operations 53 | * `#s`: number of characters in `s` 54 | * `abs s`: integer code for `s` 55 | * `char i`: character corresponding to code `i` 56 | * `str x`: convert `x` to string 57 | * `s(i..j)`: string slice 58 | 59 | # `atoms` 60 | 61 | - Objects that can be members of sets or components of tuples 62 | - Create new atoms using `newat` 63 | - Comparison 64 | ``` 65 | a = aa 66 | a /= aa 67 | ``` 68 | -------------------------------------------------------------------------------- /spj-paper.md: -------------------------------------------------------------------------------- 1 | Seven suggestions 2 | 3 | 1. Don't wait : write 4 | 2. Identify your key idea 5 | 3. Tell a story 6 | 4. Nail your contributions 7 | 5. Related work : later 8 | 6. Put your readers first (examples) 9 | 7. Listen to your readers 10 | 11 | * Idea -> Write paper -> Do research 12 | - Writing papers is a primary mechanism for *doing* research (not just 13 | *reporting* it) 14 | * Make main idea of paper clear 15 | * Tell a story 16 | - Title 17 | - Abstract 18 | - Introduction 19 | + Say what the problem is 20 | + Bullet list out (refutable) contributions 21 | + Forward reference the whole paper 22 | -------------------------------------------------------------------------------- /tfgon/1.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | * Poincare's: There are some questions that one chooses to ask and other 4 | questions that ask themselves 5 | * Pascal: Imagination tires before Nature 6 | * Homely names make the monsters easy to tame! 7 | -------------------------------------------------------------------------------- /thoreau-civil-disobeience.md: -------------------------------------------------------------------------------- 1 | - Governments are expedient. 2 | - Critique of voting, how a vote without active action supporting the stance 3 | means nothing. 4 | - Men of inaction are not men at all, mere instruments of the men controlling 5 | them. 6 | - The right to revolution. 7 | - The broadest and most prevalent error requires the most disinterested virtue 8 | to sustain it. 9 | - Those who disapprove of the character and measure of a government yet yield to 10 | it their allegiance and support are its staunchest supporters. 11 | - Perception and performance of right, not only divides states and churches, it 12 | divides families, aye, it divides the individual, separating the diabolical in 13 | him from the divine. 14 | - "Is there not a sort of bloodshed when the conscience is wounded? Through this 15 | wound a man's real man-hood and immortality flow out", and he bleeds to an 16 | everlasting death. 17 | - In a government that imprisons anyone unjustly, the prison is the place 18 | where the just man belongs. 19 | - If there were one who lived wholly without money, the state wouldn't hesitate 20 | to ask money of him. 21 | - Money takes away the moral feet on which a man stands as he no longer thinks 22 | of what goes into providing a good/service, rather thinks of how to spend his 23 | money. 24 | - Pay mind to how far your private feelings get to your actions affecting the 25 | public good. 26 | - We love eloquence for its own sake, and not for any truth it may utter 27 | -------------------------------------------------------------------------------- /top-student.md: -------------------------------------------------------------------------------- 1 | # Study Basics 2 | ## Time management 3 | * Maintain a global list and a daily list of tasks. 4 | * Schedule the tasks in the daily list. 5 | * Don't pseudo work! work done = time x focus 6 | ## War on Procrastination 7 | * Keep a work progress journal - make entries whenever something is not 8 | achieved. 9 | * Drink water constantly, monitor caffeine intake, food = energy, don't skip 10 | meals 11 | * Make an event out of the worst tasks 12 | * Build a routine 13 | * Choose your hard days 14 | # Choose when, where and how long 15 | * When: Early! 16 | * Where: Isolation 17 | * How long: 50min + 10min break 18 | ## Quizzes & Exams 19 | * Take smart notes, gather the right materials, nontechincal courses - identify 20 | the big ideas 21 | * Big ideas - Question - Evidence - Conclusion 22 | * Format notes aggressively - date & title; your notes are for YOU 23 | * QUESTION - EVIDENCE - CONCLUSION 24 | * Note taking priority - problem statement & answer, question the confusing, 25 | record the steps and annotate the steps 26 | * Work constantly - little bits and pieces at a time on assignments 27 | * Decide what textbooks to read 28 | * Read assignments from favoured sources 29 | * Makes an argument > describes an event/person > provides context 30 | * Confirm your decisions 31 | * Takes notes while reading 32 | * Don't work alone on problem sets 33 | * Solve problems on the go 34 | * Write solutions right the first time 35 | ## Marshall your resources 36 | * If you're studying hard, then you're doing something wrong 37 | * Build a study guide 38 | * Mega problem set 39 | * Memorization aids 40 | * Quiz-and-recall: reproduce proofs on a blank sheet of paper not just reading 41 | -------------------------------------------------------------------------------- /trat/1.tex: -------------------------------------------------------------------------------- 1 | \documentclass[titlepage, 12pt]{article} 2 | \usepackage[parfill]{parskip} 3 | \usepackage{amsmath} 4 | 5 | \begin{document} 6 | 7 | \title{Term Rewriting and All That\\Chapter 1 notes} 8 | 9 | \author{Bharathi Ramana Joshi} 10 | 11 | \date{Compiled: \today} 12 | 13 | \newpage 14 | 15 | \begin{itemize} 16 | 17 | \item First-order language: collection $S$ of symbols for relations, functions and 18 | constants, which, in combination with the symbols of elementary logic, 19 | single out certain combinations of symbols as sentences. 20 | 21 | \item Define addition using constant $0$ and successor function $s$ 22 | \begin{gather*} 23 | x + 0 \approx x\\ 24 | x + s(y) \approx s(x + y) 25 | \end{gather*} 26 | 27 | \item\textbf{Terms}: built from \textbf{variables}, \textbf{constant symbols} 28 | and \textbf{function symbols}. 29 | 30 | \item\textbf{Termination}: Is it always the case that after finitely many rule 31 | applications we reach an expression to which no more rules apply? 32 | 33 | \item\textbf{Confluence}: If there are different ways of applying rules to a 34 | given term leading to different terms $t_1$ and $t_2$, can $t_1$ and $t_2$ 35 | can be joined, i.e. can we always find a common term $s$ that can be reached 36 | both from $t_1$ and $t_2$ by rule application? 37 | 38 | \item\textbf{Completion}: Can we always make a non-confluent system confluent 39 | by adding implied rules? 40 | 41 | \item\textbf{Word problem}: given a set of identities $E$ and two terms $s$ 42 | and $t$, is it possible to transform the term $s$ into the term $t$, using 43 | the identities in $E$ as rewrite rules that can be applied in both 44 | directions? 45 | 46 | \end{itemize} 47 | 48 | \end{document} 49 | 50 | -------------------------------------------------------------------------------- /typescript/functions.md: -------------------------------------------------------------------------------- 1 | * Functions can access variables outside their scope. A function is said to 2 | *capture* such variables. 3 | ``` 4 | let z: number = 100; 5 | 6 | let my Add:(x: number, y: number) => number = 7 | function addToZ(x: number, y: number): number { return x + y + z; }; 8 | ``` 9 | 10 | # Optional & Default Parameters 11 | * Append `?` to a parameter name to make it optional. Use `if` to check if an 12 | optional parameter has been passed. Optional parameters must follow required 13 | parameters. 14 | * Append `=` followed by a value to assign a default value to a parameter. 15 | Default-initialized parameters that come after all required parameters are 16 | treated as optional. If a user wishes to omit a default parameter in 17 | between, they should explicitly pass `undefined`. 18 | # Rest Parameters 19 | * Rest parameters are treated as boundless number of optional parameters. 20 | ``` 21 | function buildName(firstName: string, ...restOfName: string[]) { 22 | return firstName + " " + restOfName.join(" "); 23 | } 24 | 25 | let buildNameFun: (fname: string, ...rest: string[]) => string = buildName; 26 | ``` 27 | # `this` 28 | TODO: read up on JavaScript's `this` and then come back 29 | # Function overloading 30 | * Supply multiple function types for the same function as a list of overloads 31 | and use `typeof` operator to check the type of a parameter. 32 | ``` 33 | let suits = ["hearts", "spades", "clubs", "diamonds"]; 34 | 35 | function pickCard(x: {suit: string; card: number;}[]): number; 36 | function pickCard(x: number): {suit: string; card: number; }; 37 | function pickCard(x) : any { 38 | if(typeof x == "object") { 39 | let pickedCard = Math.floor(Math.random)() * x.length); 40 | return pickedCard; 41 | } 42 | 43 | else if(typeof x == "number") { 44 | let pickedSuit = Math.floor(x / 13); 45 | return {suit: suits[pickedSuit], card: x % 13}; 46 | } 47 | } 48 | 49 | let myDeck = [{ suit: "diamonds", card: 2 }, { suit: "spades", card: 10 }, { suit: "hearts", card: 4 }]; 50 | let pickedCard1 = myDeck[pickCard(myDeck)]; 51 | alert("card: " + pickedCard1.card + " of " + pickedCard1.suit); 52 | 53 | let pickedCard2 = pickCard(15); 54 | alert("card: " + pickedCard2.card + " of " + pickedCard2.suit); 55 | ``` 56 | -------------------------------------------------------------------------------- /typescript/generics.md: -------------------------------------------------------------------------------- 1 | * Use `<>` syntax for creating generics 2 | ``` 3 | function identity(arg: T): T { // T is called a type variable 4 | return arg; 5 | } 6 | 7 | // Explicit typing 8 | let output = identity("myString"); 9 | 10 | // Type inference 11 | let output = identity("myString"); 12 | 13 | // Generic type parameter in the type 14 | let myIdentity: (arg: U) => U = identity; 15 | 16 | // Generic type as a call signature of an object literal type 17 | let myIdentity: {(arg: T): T} = identity; 18 | ``` 19 | * The type of generic functions is just like those of non-generic functions, 20 | with the type parameters listed first. 21 | ``` 22 | // Generic interface 23 | interface GenericIdentityFn { 24 | (arg: T): T; 25 | } 26 | 27 | function identity(arg: T): T { 28 | return arg; 29 | } 30 | 31 | let myIdentity: GenericIdentityFn = identity; 32 | ``` 33 | # Generic classes 34 | * Generic classes have a generic type parameter list in angle brackets. 35 | ``` 36 | class GenericNumber { 37 | zeroValue: T; 38 | add: (x: T, y: T) => T; 39 | } 40 | 41 | let myGenericNumber = new GenericNumber(); 42 | myGenericNumber.zeroValue = 0; 43 | myGenericNumber.add = function(x, y) { return x + y; }; 44 | ``` 45 | * Generic classes are only generic over their instance side rather than their 46 | static side, so when working with classes, static members can not use the 47 | class's type parameter. 48 | # Generic Constraints 49 | * Use interfaces to express constraints 50 | ``` 51 | interface Lengthwise { 52 | length: number; 53 | } 54 | 55 | function loggingIdentity(arg: T): T { 56 | console.log(arg.length); 57 | return arg; 58 | } 59 | 60 | loggingIdentity(3); // Error, no .length property 61 | 62 | loggingIdentity({length: 3, value: 3}); // Works 63 | ``` 64 | # Type Parameters in Generic Constraints 65 | ``` 66 | function getProperty(obj: T, key: k) { 67 | return obj[key]; // Constraint to make sure we don't try accessing 68 | // properties that dont exist 69 | } 70 | ``` 71 | 72 | # Class Types in Generics 73 | TODO: read up about factories and read this section again 74 | -------------------------------------------------------------------------------- /typescript/variables.md: -------------------------------------------------------------------------------- 1 | * Variables are declared using `let` keyword 2 | * Variables are lexical-scoped 3 | * Variables cannot be used outside their scope or before they are declared 4 | ("temporal dead zone") 5 | * Re-declarations are illegal 6 | # const 7 | Variables declared with `const` cannot be changed. However, their internal state 8 | is still modifiable. 9 | ``` 10 | const kitty = { 11 | name: "Aurora", 12 | numLives: 9, 13 | } 14 | 15 | // Error 16 | kitty = { 17 | name: "Danielle", 18 | numLives: 10, 19 | } 20 | 21 | // Accepted 22 | kitty.name = "Cat"; 23 | kitty.numLives--; 24 | ``` 25 | # Destructring 26 | Destructring is pattern matching. 27 | ``` 28 | let [first, ...rest] = [1, 2, 3, 4]; 29 | let [,second, ,fourth] = [1, 2, 3, 4] 30 | console.log(first) // 1 31 | console.log(rest) // [2, 3, 4] 32 | cosole.log(second) // 2 33 | ``` 34 | # Property renaming 35 | ``` 36 | let { a: newName1, b: newName2} = o; 37 | ``` 38 | is same as 39 | ``` 40 | let newName1 = o.a; 41 | let newName2 = o.b; 42 | ``` 43 | -------------------------------------------------------------------------------- /univAlgebra/makefile: -------------------------------------------------------------------------------- 1 | pdfs: 2 | for i in *.tex; do latexmk -pdf "$i";done 3 | mkdir pdfs 4 | mv *.pdf pdfs 5 | rm -f *.aux *.toc *.log *.fdb_latexmk *.fls *.out 6 | clean: 7 | rm -r ./pdfs/* 8 | rmdir pdfs 9 | rm -f *.aux *.toc *.log *.fdb_latexmk *.fls *.out 10 | rmlogs: 11 | rm -f *.aux *.toc *.log *.fdb_latexmk *.fls *.out 12 | rmpdfs: 13 | rm *.pdf 14 | -------------------------------------------------------------------------------- /vim/11.md: -------------------------------------------------------------------------------- 1 | * `set wrapmargin=10` is same as `set textwidth=70` (assuming screen is 80 2 | characters long) 3 | 4 | * Use `gq[motion]` for formatting 5 | * For formatting current paragraph, use 6 | * `gq}` from the beginning of the paragraph 7 | * `gqip` form in between the paragraph (ip = inner paragraph) 8 | * For formatting current line, use `gqgq` or `gqq` 9 | * Use `:[range] center/left/right [width]` to center/left/right justify [range] 10 | of text to [width] 11 | * Use `joinspaces` option to use two spaces instead of one when joining lines 12 | with `J` where upper line ends in a punctuation mark. 13 | * Use `set formatoptions=[characters]` 14 | where [characters] are from the following 15 | * `t` : automatically wrap text 16 | * `c` : automatically wrap comments 17 | * `r` : Insert comment leader automatically 18 | * `o` : Insert comment leader in a comment when a new line is inserted 19 | * `q` : Insert comment leader in a comment when a new line is created 20 | * `2` : allow gq to format comments 21 | * `v` : format based on the indent of the second line, not the first 22 | * `b` : wrap only on blanks, but only if they occur before 23 | * `l` : do not break line in insert 24 | * Use `set spell` for highlighting misspelled words 25 | * Use `z=` on a misspelled word for correction suggestions 26 | * Use `:spellrepall` to repeat previous `z=` for all similar words 27 | * Use `]s` to go to the next misspelled word from current cursor 28 | * Use `[s` to go to the next misspeleed word from beginning of file 29 | * use `:set spellfile=global.add, local.dd` to add spell files 30 | * Use `:spellinfo` to list all the dictionary files being used 31 | * To change whether or not the file ends in an ``, use `:set endofline` and 32 | `:set noendofline` 33 | * The `)` command moves forward one sentence. 34 | * The `(` command moves backward one sentence. 35 | * The `}` command moves forward one paragraph. 36 | * The `{` command moves backward one paragraph. 37 | * Use `:set paragraphs="macromacromacro.."` option is used to set the troff 38 | macros that start a paragraph 39 | * The `[[` and `[]` commands move a section backward (a section is any text 40 | separated by a page break character `CTRL-L`). 41 | * The `]]` and `][` commands move a section forward. 42 | * To encrypt text using rot13, use `g?` 43 | -------------------------------------------------------------------------------- /vim/19.md: -------------------------------------------------------------------------------- 1 | * To turn on case insensitivity, 2 | ``` 3 | :set noignorecase 4 | ``` 5 | * `smartcase` - if pattern contains uppercase it is case sensitive otherwise, 6 | not 7 | # Searching 8 | * Prepend `\<` to a regex to match words beginning with regex 9 | * Append `\>` to a regex to match words end with regex 10 | * `*` for greedy > 0 match 11 | * `\+` for > 1 match 12 | * `\a` for any single letter 13 | * `\d` for any single digit 14 | * `[bar]` match ranges 15 | * `[^bar]` match everything **except** range 16 | * `\{minimum(0), maximum(INF)}` match atom number of times greedily 17 | * `-` following either `minimum` or `maximum` to match as little as possible 18 | * `\(foo\)` to specify a group 19 | * `\1` is assigned the first enclosed string 20 | * `\|` to use or operator 21 | 22 | ``` 23 | :set nomagic 24 | ``` 25 | disables `*`, `.`, `[`, `]` and treats them as regular characters. They must be 26 | escaped to use them as regex. 27 | -------------------------------------------------------------------------------- /web/2.md: -------------------------------------------------------------------------------- 1 | * Applications responsible for sending emails (SMTP) are known as MTAs (Mail 2 | Transfer Agents) and applications responsible for retriving messages from a 3 | mailbox (POP servers) are known as MRAs (Mail Retrival Agents) 4 | 5 | -------------------------------------------------------------------------------- /x64_cheatsheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iambrj/notes/18ee1f33e10da8ff6011ed2d90f06cdce07ab2c3/x64_cheatsheet.pdf --------------------------------------------------------------------------------