Skip to content

Instantly share code, notes, and snippets.

@PraveshKoirala
PraveshKoirala / youtube_playlist.py
Created July 30, 2012 16:28
Youtube playlist downloader
"""
Back when I wanted to download some online lectures from MIT, I couldn't find anything that can mass download
youtube playlists save for some softwares. I didn't want to download and install any software and such and hence
I had to create this script (Now, I use ByTubeD to do the same in firefox).
Extract videos from your favorite playlist. Enter the playlist id for example, in the playlist
http://www.youtube.com/playlist?list=PLE7DDD91010BC51F8 the playlist id is PLE7DDD91010BC51F8.
The script will generate downloadable scripts in your desired formats and prompt you for a location to save your files to.
Please note that youtube keeps on changing their protocols so if you are using this script in say 2013
or such, then good luck!!! And yes, if this code causes ANY problems with your pcs like for example say your
@PraveshKoirala
PraveshKoirala / snake.asm
Created August 11, 2012 14:29
8086 Snake game
;*******************************************************************************************************************
; Snake Game By *
; HERO-DAI *
;*******************************************************************************************************************
;code is not well-commented, sorry about that, I'll try to comment it nice and well, but can't make any
;promises, Also, this code writes directly into the video memory instead of int 21H (21H is slow) except
;at some certain points (like displaying scores and the intro)
;and next time someone tells you to not use goto, ask them to code in assembly without goto... :P
@PraveshKoirala
PraveshKoirala / snake.asm
Created August 11, 2012 14:43
8086 Snake game MASM compatible
;*******************************************************************************************************************
; Snake Game By *
; HERO-DAI *
;*******************************************************************************************************************
;code is not well-commented, sorry about that, I'll try to comment it nice and well, but can't make any
;promises, Also, this code writes directly into the video memory instead of int 21H (21H is slow) except
;at some certain points (like displaying scores and the intro)
;and next time someone tells you to not use goto, ask them to code in assembly without goto... :P
@PraveshKoirala
PraveshKoirala / toh.asm
Created August 30, 2012 16:10
Tower of Hanoi in 8086
.model small
.stack 300H
.data
x dw 3
text db "Move from peg "
d1 db ?
text2 db " to peg "
d2 db ?
newline db 0AH, 0DH, '$'
@PraveshKoirala
PraveshKoirala / tsp_simulated_annealing.ipynb
Last active July 19, 2016 08:49
Solving Travelling Salesperson problem by using Simulated Annealing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Simple search engine\n",
"#### By Pravesh Koirala\n",
"\n",
"A search engine that will index given [toy] documents.. just to show how to do it."
@PraveshKoirala
PraveshKoirala / recaptcha_validate.py
Last active September 29, 2016 10:36 — forked from earthtrip/recaptcha_validate.py
Simple Recaptcha validation method when using Google App Engine (GAE), Webapp2 [Updated]
from google.appengine.api import urlfetch
from urllib import urlencode
import json
def validate_captcha(self):
recaptcha_response_field = self.request.params.get("g-recaptcha-response")
remote_ip = self.request.remote_addr
secret = 'YOUR SECRET HERE' # put recaptcha private key here
recaptcha_post_data = {
@PraveshKoirala
PraveshKoirala / interpreter.py
Created September 15, 2017 18:38
Developed for /r/dailyprogrammer challenge #331
import re
from operator import mul, pow, add, sub, div
__author__ = 'pravesh'
def get_simple_statement(statement):
template=r"((\-?\d+(?:\.\d+)?)\%s(\-?\d+(?:\.\d+)?))(?!\^)"
for opstr, opfunc in [("^", pow), ("*", mul), ("/", div), ("+", add), ("-", sub)]:
template_str = template % opstr
while opstr in statement:
#todo associativity for ^ operator