Skip to content

Instantly share code, notes, and snippets.

View KartikTalwar's full-sized avatar
🚀
Gone phishing

Kartik Talwar KartikTalwar

🚀
Gone phishing
View GitHub Profile
@KartikTalwar
KartikTalwar / modernizer.js
Created October 26, 2012 23:58
Modernizer.js
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-flexboxlegacy-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
*/
;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a){var e=a[d];if(!G(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"functi
@KartikTalwar
KartikTalwar / APIPub.php
Created October 25, 2012 17:30
API Dissertation
<?php
$url = 'http://api.uwaterloo.ca/public/v1/?key=apikey&';
$url .= 'service=publicationdetails&q='.$_GET['q'];
$get = json_decode(file_get_contents($url))->response->data;
$data['title'] = $get->Title;
$data['authors'] = $get->Authors;
$data['approved'] = $get->Approved;
$data['abstract'] = $get->Abstract;
@KartikTalwar
KartikTalwar / prof.php
Created October 16, 2012 16:32
API Prof
<?php
$url = 'http://api.uwaterloo.ca/public/v1/?';
$url .= 'key=&service=staffinfo&q='.$q[0];
$get = file_get_contents($url);
$json = json_decode($get);
$data['name'] = $json->response->data->Name;
$data['dept'] = $json->response->data->Department;
@KartikTalwar
KartikTalwar / HungarianAlgorithm.java
Created September 15, 2012 23:13
Hungarian Algorithm
import java.util.Arrays;
/* Copyright (c) 2012 Kevin L. Stern
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@KartikTalwar
KartikTalwar / TwitterCheck.php
Created August 18, 2012 20:24
Twitter Followers Prereq Check
<?php
/*
Usage:
@KartikTalwar
KartikTalwar / phptest.xml
Created August 18, 2012 20:02
PHP Lib Test
<?xml version="1.0" encoding="UTF-8"?>
<test>
<case>42</case>
</test>
@KartikTalwar
KartikTalwar / GooglePageRankCheckSum.php
Created August 2, 2012 22:34
Google PageRank Checksum Algorithm
<?php
function fch($csm)
{
if($csm < 0)
$csm += 4294967296.0;
$a = (int)fmod($csm, 10);
$t = 1;
$b = (int)($csm / 10);
@KartikTalwar
KartikTalwar / LFSR.java
Created July 31, 2012 04:20
Galois linear feedback shift register (LFSR)
/*
* Galois linear feedback shift register (LFSR) in Java
* Copyright (c) 2012 Nayuki Minase
*/
import java.math.BigInteger;
import java.util.Random;
/**
@KartikTalwar
KartikTalwar / GreedyCoin.py
Created July 28, 2012 00:07
Simple Greedy Coin Algorithm
def bestChange(denominations, amount):
if amount == 0:
return []
for i in denominations:
if i <= amount:
return [i] + bestChange(denominations, amount-i)
denominations = [100, 50, 20, 10, 5, 2, 1]
amount = 109
@KartikTalwar
KartikTalwar / HungarianAlgorithm.py
Created July 22, 2012 05:21
Hungarian Algorithm
#!/usr/bin/python
# ecole polytechnique - c.durr - 2009
# Kuhn-Munkres, The hungarian algorithm. Complexity O(n^3)
# Computes a max weight perfect matching in a bipartite graph
# for min weight matching, simply negate the weights.
""" Global variables:
n = number of vertices on each side
U,V vertex sets