-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from opencode18/master
Updated Fork
- Loading branch information
Showing
17 changed files
with
348 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import re | ||
|
||
user_input=input() | ||
date=re.sub(r'(\d{2})-(\d{2})-(\d{4})','\\2/\\1/\\3',user_input) | ||
|
||
print('Converted format : '+ date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from urllib.request import urlopen | ||
from bs4 import BeautifulSoup | ||
|
||
web="https://scirate.com/" | ||
|
||
page=urlopen(web) | ||
|
||
soup=BeautifulSoup(page,"html.parser") | ||
|
||
all_names=soup.find_all('div',attrs={'class' : 'title'}) | ||
all_links=soup.find_all('a',attrs={'title':'Download PDF'}) | ||
i=0 | ||
for name in all_names: | ||
print('Name = '+name.text) | ||
if(i<len(all_links)): | ||
print('Link = '+all_links[i]['href']) | ||
i=i+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import re | ||
def date_month_exchange(date): | ||
return re.sub(r'(\d{1,2})-(\d{1,2})-(\d{4})', '\\2/\\1/\\3', date) | ||
date1 = input() | ||
print("Date in old format : ",date1) | ||
print("Date in new format : ",date_month_exchange(date1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// var xhttp = new XMLHttpRequest(); | ||
// xhttp.open("POST", "https://jobs.github.com/positions.json?description=ruby&location=newyork"); | ||
// xhttp.setRequestHeader("Content-type", "application/json"); | ||
// xhttp.send(); | ||
// // var response = JSON.parse(xhttp.responseText); | ||
// | ||
// var response = xhttp.responseText; | ||
// console.log(response) | ||
const yargs = require('yargs') | ||
const h2p = require('html2plaintext') | ||
const request = require('request'); | ||
|
||
|
||
const argv = yargs | ||
.options({ | ||
a: { | ||
describe: 'Address of the location', | ||
demand: true, | ||
alias: 'address', | ||
string: true | ||
}, | ||
d: { | ||
describe: 'Job Description', | ||
demand: true, | ||
alias: 'jobDes', | ||
string: true | ||
} | ||
}) | ||
.help() | ||
.alias('help', 'h') | ||
.argv; | ||
|
||
request({ | ||
url: `http://jobs.github.com/positions.json?description=${argv.jobDes}&location=${argv.address}`, | ||
json: true, | ||
}, (error,response, body) => { | ||
for(var i=0; i<body.length; i++){ | ||
console.log(`Job ${i+1} ==>`) | ||
console.log(`Title: ${body[i].title}`); | ||
console.log(`Location: ${body[i].location}`); | ||
console.log(`Type: ${body[i].type}`); | ||
var description = h2p(body[i].description); | ||
console.log(`Description: ${description}`) | ||
console.log(`Company: ${body[i].company}`); | ||
var howTo = h2p(body[i].how_to_apply); | ||
console.log(`How to apply: ${howTo}`); | ||
console.log(`-------------------------------------------`) | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from bs4 import BeautifulSoup | ||
import requests | ||
|
||
document = requests.get("https://scirate.com/") | ||
soup = BeautifulSoup(document.content, "html.parser") | ||
|
||
titles = soup.select(".title a") | ||
links = soup.find_all("a", attrs={'title': "Download PDF"}) | ||
i=0 | ||
for title in titles: | ||
print("Title: " + title.text) | ||
if(i<len(links)): | ||
print("Link: " + links[i]['href']) | ||
print("---------------------------------------------------------------------") | ||
i+=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.keys import Keys | ||
|
||
email = raw_input("Enter your Email ID\n") | ||
password = raw_input("Enter your Password\n") | ||
|
||
driver = webdriver.Firefox() | ||
driver.get('https://www.facebook.com/') | ||
assert "Facebook" in driver.title | ||
|
||
emailField = driver.find_element_by_id('email') | ||
passwordField = driver.find_element_by_id('pass') | ||
submitField = driver.find_element_by_id('u_0_2') | ||
|
||
emailField.send_keys(email) | ||
passwordField.send_keys(password) | ||
|
||
submitField.submit() | ||
|
||
# driver.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import urllib2 | ||
from bs4 import BeautifulSoup | ||
#import webbrowser | ||
|
||
|
||
wiki = "https://scirate.com/" | ||
page = urllib2.urlopen(wiki) | ||
soup = BeautifulSoup(page,"html.parser") | ||
|
||
all_links = soup.find_all("div",{"class": "title"}) | ||
|
||
for link in all_links: | ||
print link.string | ||
for i in link: | ||
pdf_link = "http://arxiv.org/pdf/"+i['href'].split("/")[2]+".pdf" | ||
#webbrowser.open(pdf_link) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#python 2.7 | ||
import re | ||
|
||
date = raw_input() | ||
print "" + re.sub(r'(\d{1,2})-(\d{1,2})-(\d{4})', '\\2/\\1/\\3', date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
README.md | ||
|
||
|
||
fb.py is a python program to log into your Facebook accounts! | ||
It uses the mechanize library! | ||
|
||
To use this, first go the folder Task6 and type ". build.sh" | ||
|
||
It'll take you to virtualenv to use this functionality! | ||
|
||
Then type "fb --login", and it'll prompt you for your email and password, and then returns whether your login was successful or not! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import requests | ||
import json | ||
from bs4 import BeautifulSoup | ||
|
||
jobDescription = raw_input("What technology do you want to work with? ") | ||
|
||
jobLocation = raw_input("What's your preferred job location? ") | ||
|
||
obj = requests.get("https://jobs.github.com/positions.json?description="+jobDescription+"&location="+jobLocation) | ||
|
||
jsonObj = json.loads(obj.content) | ||
|
||
suggestionNumber = 1 | ||
if(jsonObj): | ||
print "%d jobs have been found with the information you gave!"%len(jsonObj) | ||
for jobSearch in jsonObj: | ||
print ("------------------------------------------------------------") | ||
print ("Suggestion %d :"%suggestionNumber) | ||
print ("JOB TITLE : " + jobSearch['title']) | ||
print ('\n') | ||
print ("COMPANY : " + jobSearch['company']) | ||
print ('\n') | ||
print ("LOCATION : " + jobSearch['location']) | ||
print ('\n') | ||
print ("TYPE : " + jobSearch['type']) | ||
print ('\n') | ||
print ("COMPANY URL : " + jobSearch['company_url']) | ||
print ('\n') | ||
descriptionSoup = BeautifulSoup(jobSearch['description'],'html.parser') | ||
print ("JOB DESCRIPTION : \n" + descriptionSoup.text) | ||
print ('\n') | ||
apply_soup = BeautifulSoup(jobSearch['how_to_apply'],'html.parser') | ||
print ("HOW TO APPLY? : \n" + apply_soup.text) | ||
print ('\n') | ||
print ("------------------------------------------------------------") | ||
suggestionNumber+=1 | ||
print ('\n\n') | ||
else: | ||
print ("\n\nSorry but we have no jobs available currently with the preferences you entered.\nTry again soon! :)") | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from bs4 import BeautifulSoup | ||
import mechanize | ||
|
||
browser = mechanize.Browser() | ||
reponse = browser.open("https://scirate.com/") | ||
soup = BeautifulSoup(reponse,'html.parser') | ||
|
||
name_list = soup.find_all('div',attrs={'class':'title'}) | ||
link_list = soup.find_all('a',attrs={'title':'Download PDF'}) | ||
|
||
i = 0 | ||
|
||
for topics in name_list: | ||
print str(i+1)+') '+topics.text | ||
print link_list[i].get('href') | ||
i+=1 | ||
print"----------------------------------------------------------------------" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
xRange = np.arange(0.0,2.0,0.01) | ||
sinGraph = 2*np.sin((np.pi/4)*xRange) | ||
|
||
plt.plot(xRange,sinGraph) | ||
|
||
plt.title('A sin graph plot') | ||
plt.grid(True) | ||
plt.savefig("sin.png") | ||
plt.show() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
#include <sys/wait.h> | ||
|
||
int fact(int a) | ||
{ | ||
int factVal = a; | ||
if(a==0 || a==1) | ||
printf("The factorial is 1"); | ||
else | ||
{ | ||
for(int i=a-1;i>1;i--) | ||
factVal*=i; | ||
} | ||
|
||
} | ||
|
||
int main() | ||
{ | ||
pid_t pid; | ||
int input,factVal; | ||
|
||
printf("Enter a value of your choice: "); | ||
scanf("%d",&input); | ||
pid = fork(); | ||
/*Creates 2 different processes (child and parent) | ||
So only one process goes on at a particular time! | ||
Therefore both are calculated separately*/ | ||
|
||
if(pid == 0) //Enters when the process is child process | ||
printf ("The exponential of %d wrt itself is %d\n",input,input*input); | ||
|
||
else if(pid>0) //Enter when the process is parent process | ||
{ | ||
factVal = fact(input); | ||
printf("The factorial of %d is %d\n",input,factVal); | ||
wait(NULL); | ||
} | ||
|
||
else //if pid returns a negative value then it means process creation failed | ||
printf("Process creation failed"); | ||
|
||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
if [ -f venv/bin/activate ] | ||
then | ||
echo "As virtualenv exists, we'll only be setting up the virtual environment now!" | ||
echo "ACTIVATING........" | ||
chmod 777 build.sh #Gives reading, writing and execution power to all users on system | ||
. venv/bin/activate #helps you enter into virtual environment | ||
pip install --editable . | ||
else | ||
echo "Since you don't have Virtualenv installed already, we'll install it for you!" | ||
echo "After installing, we'll also be setting it up for you!" | ||
echo "Please wait for a few moments! :)" | ||
echo "INSTALLING......." | ||
sudo apt-get install virtualenv #install virtualenv | ||
virtualenv venv #creates your virtualenv by the name venv | ||
chmod 777 build.sh #Gives reading, writing and execution power to all users on system | ||
. venv/bin/activate #helps you enter into virtual environment | ||
pip install --editable . | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from bs4 import BeautifulSoup | ||
import mechanize | ||
import click | ||
|
||
|
||
email = raw_input('Enter your Email ID: ') | ||
pwd = raw_input('Enter your password: ') | ||
|
||
def authenticate(browser,url,email,pwd): | ||
browser.open(url) | ||
browser.select_form(nr = 0) #This is login-password form -> nr = number = 0 | ||
browser.form['email'] = email | ||
browser.form['pass'] = pwd | ||
response = browser.submit() | ||
return BeautifulSoup(response,'html.parser') | ||
|
||
@click.command() | ||
|
||
@click.option('--login',is_flag=True,help='Allows you to login to Facebook') | ||
|
||
|
||
|
||
def cli(login): | ||
browser = mechanize.Browser() | ||
browser.set_handle_robots(False) #Allows everything to be written | ||
cookies = mechanize.CookieJar() | ||
browser.set_cookiejar(cookies) | ||
browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7')] | ||
browser.set_handle_refresh(False) #Sometimes hangs without this | ||
try: | ||
url = 'http://www.facebook.com/login.php' | ||
soup = authenticate(browser,url,email,pwd) #Parses the html and stores in 'soup' | ||
if(login): #To find number of new friend request | ||
fr_num_box = soup.find('span',attrs={'id':'requestsCountValue'}) #Finds span tags with the given ID | ||
if(fr_num_box != None): | ||
click.echo("\n\nLOGIN SUCCESSFUL!\n" ) | ||
else: | ||
click.echo("\n\nLOGIN UNSUCCESSFUL!\nEither the password or email id you've entered is wrong!\nPlease try again!") | ||
except AttributeError: | ||
click.echo("Either the password or email id you've entered is wrong") | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from setuptools import setup | ||
|
||
setup( | ||
name='fb', | ||
version=1.0, | ||
py_modules=[ | ||
'fb', | ||
], | ||
install_requires=[ | ||
'bs4', | ||
'BeautifulSoup', | ||
'mechanize', | ||
'click', | ||
], | ||
entry_points={ | ||
'console_scripts':[ | ||
'fb=fb:cli', | ||
] | ||
}, | ||
) |