Skip to content

Instantly share code, notes, and snippets.

View zapstar's full-sized avatar

Thirumal Venkat zapstar

View GitHub Profile
@zapstar
zapstar / Notes on Linear Regression
Last active August 29, 2015 13:57
Notes on linear regression chapter from 15.071x = Analytics Edge (Week 02)
Dependent variable = y what we predict
Independent variable = x's. What we use to predict y.
Baseline Prediction: We take the average of all y in the training set and predict that no matter what x is input into the model.
One variable linear regression:
y_i = B_0 + B_1 * x_i + e_i
y_i = i'th independent variable
B_0 = intercept term (the value of y when x is 0)
@zapstar
zapstar / BitBoolean.java
Created March 17, 2014 05:59
Bit boolean class in Java for implementing a more space-efficient boolean storage (1 bit instead of 1 byte). All operations are O(1).
import java.util.Map;
import java.util.HashMap;
public class BitBoolean {
//Holds boolean data as bits
//Each byte can hold 8 boolean values
//So index = booleanDataIndex + booleanMappingIndex
//booleanDataIndex = index/8
//boleanMappingIndex, see booleanMapping variable
@zapstar
zapstar / list_comprehension.py
Created March 28, 2014 04:19
List Comprehension in Python (Quick Reference)
# Syntax: All in one line or by escape characters
# [ <some expression to be evaluated and put in another list>
# for <some iterating variable in the list>
# in <some list>
# if <some condition holds true>
# ]
mylist = [10,20,30,40,50,60,70,80,90,100]
# create a new list containing variables in the list divided by 10
@zapstar
zapstar / Notes on Logic: Language and Information 1.md
Last active August 29, 2015 13:57
My notes for the Coursera course on Language and Information of Logic

Logic: Language and Information 1

Propositions: Fundamental units of information. You can assert/deny, agree/disagree, believe/not believe


Connectives

  • ~A is true only when A is false
  • A & B is true, only when both A and B are true
@zapstar
zapstar / fast_multiply.py
Created April 21, 2014 16:41
A method for multiplying faster than our repeated addition
# Really cool algorithm I learnt from a blog somewhere
# Also sometimes called russian's peasents algorithm
def fast_multiply(a,b):
z=0;
while a > 0:
if a % 2 == 1:
z = z + b
a = a >> 1
b = b << 1
@zapstar
zapstar / SecondLargest.java
Created May 2, 2014 06:17
Finds the second largest element in an array within n + log(n)_base2 -2 comparisons
import java.util.LinkedList;
/**
* @author thiru
*
*/
public class SecondLargest {
private class TreeNode {
int item;
@zapstar
zapstar / isitme.sh
Created September 3, 2014 04:12
Simple shell script to check whether a website is down only for me or everyone else. Uses curl and isup.me service.
# Simple script to figure out whether a site is up or not
TOOL_SITE="http://www.isup.me/"
if [ $# -ne 1 ]
then
echo "Incorrect arguments specified"
exit 1
fi
@zapstar
zapstar / tryMongoDB.js
Last active August 29, 2015 14:14
Notes from the MongoDB introductory tutorial present at http://try.mongodb.org
// This is the MongoDB tutorial from http://try.mongodb.org
// Get started with `help`
// To try out an interactive tutorial type `tutorial`
// This shell is a (limited) javascript interpreter, so any commands you are familiar from javascript should work here. Try out:
var a = 5;
a * 10;
for(i=0; i<10; i++) { print('hello'); };
// You can move onto the next step anytime by typing `next`
@zapstar
zapstar / .vimrc
Last active December 29, 2020 09:21
My vimrc
""""""""""""""""""
" PACKAGES START "
""""""""""""""""""
set nocompatible
call plug#begin('~/.vim/plugged')
" Start adding Vundle plugins from here
" Package manager itself
@zapstar
zapstar / max2.c
Created March 9, 2015 12:26
Find the two largest numbers among the three.
#include <stdio.h>
void max2(int a, int b, int c) {
int first, second;
printf("a = %d, b = %d, c = %d\n", a, b, c);
if (a > b) {
second = a;
if (a > c) {
first = a;
if (b > c) {