Skip to content

Instantly share code, notes, and snippets.

View suriyadeepan's full-sized avatar
🌱
Solving Hard Problems with Machine Learning

Suriyadeepan Ramamoorthy suriyadeepan

🌱
Solving Hard Problems with Machine Learning
View GitHub Profile
<html>
<head>
<title>SAMPLE2</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--[if lte IE 8]><script src="assets/css/ie/html5shiv.js"></script><![endif]-->
<link rel="stylesheet" href="assets/css/main.css" />
<link rel="stylesheet" href="assets/css/style.css" />
<!--[if lte IE 9]><link rel="stylesheet" href="assets/css/ie/v9.css" /><![endif]-->
<!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie/v8.css" /><![endif]-->
@suriyadeepan
suriyadeepan / index.html
Created June 23, 2015 07:29
Solves the issue
<body class="landing">
<div id="topdiv" class="button special"> <a href="#page-wrapper" class="goto-next scrolly"></a></div>
<div id="page-wrapper">
<!-- Header -->
<p id="#demo1"></p>
<button onclick="myFunction();">Change</button>
<br>
<img id="dateimage1" class='change-img' src="http://vignette4.wikia.nocookie.net/pacman/images/2/2d/Pinkyyghost.png/revision/latest?cb=20090919170357" alt="Loading..." width="75%" />
def splitStringList(X):
newX = []
for x in X:
newx = []
for i in re.split('[^a-z]+',x):
if i:
newx.append(i)
newX.append(newx)
return newX
@suriyadeepan
suriyadeepan / wiki_toc.py
Last active August 26, 2016 06:02
Scrap Table of Contents from a Wiki page using Beautiful Soup
from bs4 import BeautifulSoup
import requests
url = 'https://en.wikipedia.org/wiki/Transhumanism'
# get contents from url
content = requests.get(url).content
# get soup
soup = BeautifulSoup(content,'lxml') # choose lxml parser
# find the tag : <div class="toc">
tag = soup.find('div', {'class' : 'toc'}) # id="toc" also works
@suriyadeepan
suriyadeepan / wiki_images.py
Created August 26, 2016 06:09
Scrap images from a wiki page using Beautiful Soup
from bs4 import BeautifulSoup
import requests
url = 'https://en.wikipedia.org/wiki/Transhumanism'
# get contents from url
content = requests.get(url).content
# get soup
soup = BeautifulSoup(content,'lxml') # choose lxml parser
# find the tag : <img ... >
image_tags = soup.findAll('img')
@suriyadeepan
suriyadeepan / wiki_refs.py
Created August 26, 2016 06:20
Scrap all references from a wiki page using Beautiful Soup
from bs4 import BeautifulSoup
import requests
url = 'https://en.wikipedia.org/wiki/Transhumanism'
# get contents from url
content = requests.get(url).content
# get soup
soup = BeautifulSoup(content,'lxml') # choose lxml parser
# find all the references
ref_tags = soup.findAll('span', { 'class' : 'reference-text' })
@suriyadeepan
suriyadeepan / wiki_links.py
Last active August 26, 2016 06:28
Scrap a wiki page to get the other wiki articles that are cited in it, using Beautiful Soup
@suriyadeepan
suriyadeepan / wiki_recursive.py
Created August 26, 2016 07:33
Recursively grab Article titles from wiki using Beautiful Soup
from bs4 import BeautifulSoup
import requests
start_url = 'https://en.wikipedia.org/wiki/Transhumanism'
domain = 'https://en.wikipedia.org'
''' get soup '''
def get_soup(url):
# get contents from url
content = requests.get(url).content
@suriyadeepan
suriyadeepan / custom_sort2.py
Created August 29, 2016 06:33
Sort a list based on more than one attribute
lst = [ 'file', 'if', 'hat', 'zoltan', 'calculator', 'cup', 'pocket', 'symbolic', 'I', 'attributes' ]
sorted_lst1 = sorted(lst, key=len)
print(sorted_lst1)
## OUTPUT : ['I', 'if', 'hat', 'cup', 'file', 'zoltan', 'pocket', 'symbolic', 'calculator', 'attributes']
sorted_lst2 = sorted(lst, key=lambda item : (len(item),item[0]) )
print(sorted_lst2)
## OUTPUT : ['I', 'if', 'cup', 'hat', 'file', 'pocket', 'zoltan', 'symbolic', 'attributes', 'calculator']
# alternative to lambda
def len_alpha(item):
return ( len(item), item[0] )
@suriyadeepan
suriyadeepan / twitter_casper.js
Created September 10, 2016 13:28
Casper sucks!!
casper = require('casper').create({
verbose : true,
logLevel : 'debug', // debug, info, warning, error,
pageSettings: {
logImages : false,
logPlugins : false,
//userAgent : 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'
//userAgent : 'Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19'
userAgent : 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36'