Skip to content

Instantly share code, notes, and snippets.

View ranveeraggarwal's full-sized avatar
👋
Hej!

Ranveer Aggarwal ranveeraggarwal

👋
Hej!
View GitHub Profile
@ranveeraggarwal
ranveeraggarwal / iitb-ldap-auth.php
Created July 18, 2014 17:13
IITB LDAP Auth Script (PHP)
<?php
function ldap_auth($ldap_id, $ldap_password){
$ds = ldap_connect("ldap.iitb.ac.in") or die("Unable to connect to LDAP server. Please try again later.");
if($ldap_id=='') die("You have not entered any LDAP ID. Please go back and fill it up.");
if($ldap_password=='') die("You have not entered any password. Please go back and fill it up.");
$sr = ldap_search($ds,"dc=iitb,dc=ac,dc=in","(uid=$ldap_id)");
$info = ldap_get_entries($ds, $sr);
$roll = $info[0]["employeenumber"][0];
//print_r($info);
$ldap_id = $info[0]['dn'];
@ranveeraggarwal
ranveeraggarwal / acm20151amrita-rankscrape.py
Created October 11, 2014 18:35
ACM ICPC 2015 - Round I - Amritapuri - Rank List Scraper
import urllib2
from bs4 import BeautifulSoup
page = urllib2.urlopen('http://www.codechef.com/rankings/ACMAMR14?utm_content=bufferd975d&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer')
page = page.read()
soup = BeautifulSoup(page)
soup.prettify()
userranks = []
for anchor in soup.findAll('a', href=True):
p = anchor['href']
if "users/acm14am" in p:
@ranveeraggarwal
ranveeraggarwal / codegags-template.html
Created October 21, 2014 21:57
CodeGags Template
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
</head>
<body style="background-color:black">
<center>
<h1 style="color:white; font-family: 'Open Sans', sans-serif; font-size:100px; margin-top:15%;" >Darwin was right. <br> Nature doesn't start from scratch.</h1>
</center>
@ranveeraggarwal
ranveeraggarwal / remove-pyc.sh
Last active June 24, 2016 15:32
Remove pyc's from a python project
find . -name "*.pyc" -exec git rm -f "{}" \;
brew install python3
pip3 install numpy
brew install cmake
git clone --depth=1 https://github.com/Itseez/opencv.git
cd opencv
mkdir build
cd build
# note: in the next line, adjust paths to point to the correct python version
cmake -DBUILD_opencv_python3=YES -DBUILD_opencv_python2=NO -DINSTALL_PYTHON_EXAMPLES=YES -DPYTHON3_EXECUTABLE=/usr/local/bin/python3 -DPYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m/ -DPYTHON3_LIBRARY=/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5.dylib -DPYTHON3_NUMPY_INCLUDE_DIRS=/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/core/include/ -DPYTHON3_PACKAGES_PATH=/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/ ..
make -j8
@ranveeraggarwal
ranveeraggarwal / kisscartoon.py
Created April 27, 2016 11:09
A script to download videos off KissCartoon
# I am not the author of this script. I just keep it here because it is infinitely useful.
__author__ = 'Jan'
import base64
from bs4 import BeautifulSoup
import cfscrape
from pySmartDL import SmartDL
import os.path
import argparse
@ranveeraggarwal
ranveeraggarwal / 2d-picking.py
Created July 4, 2016 19:27
Picking of 2D Actors in VTK-Python
import vtk
class CustomInteractor(vtk.vtkInteractorStyleTrackballCamera):
def __init__(self, renderer, renWin):
self.AddObserver('LeftButtonPressEvent', self.OnLeftButtonDown)
self.AddObserver('LeftButtonReleaseEvent', self.OnLeftButtonRelease)
self.AddObserver('MouseMoveEvent', self.OnMouseMove)
self.renderer = renderer
@ranveeraggarwal
ranveeraggarwal / Ignored Files.txt
Last active March 13, 2017 08:26
Count lines of code between commits with wildcard ignores
*.txt
a/b/*.txt
*.xml
*.csproj
var systemjsBuilder = require('gulp-systemjs-builder');
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var includedJsFiles = [
"node_modules/core-js/client/shim.min.js",
"node_modules/zone.js/dist/zone.js",
"node_modules/reflect-metadata/Reflect.js",
"node_modules/systemjs/dist/system.src.js",
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';