Skip to content

Instantly share code, notes, and snippets.

@KWMalik
KWMalik / compgeo.md
Created September 16, 2012 22:04 — forked from dideler/compgeo.md
Computation Geometry

Computational Geometry

(Abridged notes from Introduction to Algorithms)

Branch of CS that studies algorithms for solving geometric problems. Input is typically a set of points, a set of line segments, or the vertices of a polygon in counterclockwise order. Output is often a response to a query about the objects, such as whether any lines intersect, or finding a new geometric object (e.g. convex hull) of the set of points.

We look at computational-geometry algorithms in two dimensions (2D), i.e. in the plane. Each object is represented by a set of points {P1, P2, P3, ...}, where each Pi = (Xi, Yi). For example, an n-vertex polygon _P = _.

@KWMalik
KWMalik / interviewitems.MD
Created September 16, 2012 22:04 — forked from amaxwell01/interviewitems.MD
My answers to over 100 Google interview questions

##Google Interview Questions: Product Marketing Manager

  • Why do you want to join Google? -- Because I want to create tools for others to learn, for free. I didn't have a lot of money when growing up so I didn't get access to the same books, computers and resources that others had which caused money, I want to help ensure that others can learn on the same playing field regardless of their families wealth status or location.
  • What do you know about Google’s product and technology? -- A lot actually, I am a beta tester for numerous products, I use most of the Google tools such as: Search, Gmaill, Drive, Reader, Calendar, G+, YouTube, Web Master Tools, Keyword tools, Analytics etc.
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them? -- Google competes on numerous fields: --- Search: Baidu, Bing, Duck Duck Go
@KWMalik
KWMalik / computing_data_analysis_notes.md
Created October 11, 2012 21:19 — forked from sandys/computing_data_analysis_notes.md
notes for Computing for Data Analysis coursera course

using logical indexes

in1 <- c(TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE)
x[in1]```

* single [] operator returns the same class - except in matrix. To get the same behavior in matrix, set ``` drop=FALSE``` attribute
    * ```x[1,,drop=FALSE] ``` 
* ```attributes(y) ``` to list all attributes of a data strucuture
    * ``` attr(y, "class")``` to print out one particular attribute
* lists also work as hashes ```x &lt;- list(foo = 1:4, bar=0.6) x$foo ```
@KWMalik
KWMalik / gist:3881665
Created October 12, 2012 21:37 — forked from mhawksey/gist:3799483
Practising some data shaping in R for #compdata week 1
# compdata week 1 pracitce
# Script reads a NodeXL twitter search for #compdata hashtag that's been uploaded to Google Spreadsheet
# Data is reshaped using subsetting to get a slice of rows columns fitting a certiain condition
# read csv from Google Spreadsheet, headers in row 2 in this case an vertices list
vertices <- read.csv("https://docs.google.com/spreadsheet/pub?key=0AqGkLMU9sHmLdHJ1Y0Jsb0R4MjdXM2M1WExXU21FVWc&single=true&gid=1&output=csv",header=TRUE,skip=1,)
# see number of rows
nrow(vertices)
@KWMalik
KWMalik / gist:3881669
Created October 12, 2012 21:38 — forked from mhawksey/gist:3833072
Bulk collect social share counts from Facebook, Twitter, Delicious, Pinterest and Google +1s and return json
<?php
$url = $_GET['url'];
$finfo = json_decode(file_get_contents('http://api.ak.facebook.com/restserver.php?v=1.0&method=links.getStats&urls='.$url.'&format=json'));
$tinfo = json_decode(file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url='.$url));
$dinfo = json_decode(file_get_contents('http://feeds.delicious.com/v2/json/urlinfo/data?url='.$url));
$pinfo = json_decode(preg_replace('/^receiveCount\((.*)\)$/', "\\1",file_get_contents('http://api.pinterest.com/v1/urls/count.json?callback=receiveCount&url='.$url)));
$gplus = gplus_shares($url);
//http://papermashup.com/google-plus-php-function/
@KWMalik
KWMalik / data-science-resources.md
Created October 12, 2012 21:55
Data Science Resources
@KWMalik
KWMalik / py-data-science.md
Created October 12, 2012 21:56
Python packages for Data Analysis

Python packages for Data Analysis, Natural Language Processing, Machine Learning and Statistics

Forever a work in progress.

I recommend you install these from the python package manager - pip.

Keep in mind that you have to resolve the dependencies yourself(unless those dependencies are python packages), if you feel that you cannot do this then please install them from your distro's package manager.

@KWMalik
KWMalik / sudoku_solver.cpp
Created October 12, 2012 21:56
Sudoku solver in C++11
#include <iterator>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <cassert>
#include <memory>
#include <future>
#include <chrono>
@KWMalik
KWMalik / setup.sh
Created October 12, 2012 21:56
Create and deploy a Python/Flask "hello world" app on Heroku.
#!/bin/bash
# Create and deploy a Python/Flask "hello world" app on Heroku.
# by James Thornton, http://jamesthornton.com
# To run it, do:
# $ heroku login
# $ bash setup.sh helloworld
# $ cd helloworld
@KWMalik
KWMalik / latency.txt
Created October 12, 2012 21:56
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns