Notes
Notes - notes.io |
width=17
print width/2.0
height=12.0
print height/3
delimiter='1049'
print delimiter * 5
print 4/3 * 3.14 * 5 ** 3
print 24.95 * 0.6+3+59 * 0.75
print int(3.99999999) #integer
print int(-2.3)
def print_lyrics():
print "this is code"
print "this is hard"
print_lyrics()
"""wdjkasjdjdnjdjands"""
bruce = 60
def print_twice(bruce):
print bruce
print bruce
print_twice(bruce)
l = [1, 2, "a"] #list
d = {"a":1, "b":2}
for x in range(5):
print x
primes = [2, 3, 5, 7]
for prime in primes:
print(prime)
count = 0
while count < 5:
print(count)
count=count + 1
umm=0
while umm < 10:
print(umm)
umm=umm + 2
dict = {'Name': 'roger', 'Age': 13, 'Class': '9th'} #dict
print "dict['Name']: ", dict['Name']
print "dict['Age']: ", dict['Age']
num=[951, 402, 984, 651, 360, 69, 408, 319, 601, 485, 980, 507, 725, 547, 544,
615, 83, 165, 141, 501, 263, 617, 865, 575, 219, 390, 984, 592, 236, 105, 942, 941]
print len(num)
x = 0
while x < 32: #if else
if num[x]%2 == 0:
print num[x]
x = x + 1
else:
x = x+1
weight = float(input("How many pounds does your suitcase weigh? ")) #while loop
if weight > 50:
print("There is a $25 charge for luggage that heavy.")
print("Thank you for your business.")
age = float(input('how old are you')) #if else
if age > 20:
print('your old')
else:
print('your young')
def spam():
eggs = 12
return eggs
print spam()
hello_world = "hi"
goodbye_world= "kys"
combined_world= hello_world + " " + "and" + " " + goodbye_world
print (combined_world)
print(8%3)
from math import pi
print pi
from math import cos
print cos(6)
print len('kadjfaisdjksf')
print (1,000,000)
miles = 26.2
print miles * 1.61
parrot = "norwegian blue"
print (parrot).upper()
print (parrot).lower()
print len(parrot)
pi=3.14
print str(pi)
name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")
print "Ah, so your name is %s, your quest is %s, "
"and your favorite color is %s." % (name, quest, color)
import urllib2
import requests
url= "https://www.youtube.com/"
response=requests.get(url)
print (response)
import json
obj=requests.get(url)
print (obj)
f=open("a random file.txt").w
f.site(obj)
f.close()
import json
import requests
url="http://130.127.49.170/test.json"
response=requests.get(url)
print (response.json())
obj=json.dumps(response.json())
print obj
print (obj["name"])
import json
import requests
url="http://130.127.49.170/test.json"
response=requests.get(url)
obj=json.dumps(response.json())
x = json.loads(obj)
i = 0
while i < (len(x["colleagues"])):
print x["colleagues"][i]["name"]
i = i + 1
cat test.py is view it
python is translate to python
python test .py is to get to the test
vim test.py is to go to the test
escape : w is save q is quit
clear is to clear
look back on the file if it says syntax error
ssh [email protected]
password
cd /home/roger
ls
vim crawl.py
loading bad words that are inserted and save it as bw file
if the amount of photos is greater or equal to 3 than print the number
print the id, number, and title
.out file extension is used by various programs because it is a general file extension. Files with the .out extension contain texts that are used for the purpose of logging as well as analyzing the unexpected behavior of certain software.
The first program loads all the bad words and puts it in the file bw file. The second program names the id, owner, and title of the photo. It also analyzes if the photo has inappropriate content. The main use for this code is to extract photos and identify them. it gathers data from the last 20 years. If the amount of photos exceed 3500, the program extracts it. Every 7 days the program will also extract photos.
#!/usr/local/bin
import urllib2
import json
from profanity import profanity
import time
import requests
import datetime
from dateutil.relativedelta import relativedelta
import urllib
from multiprocessing import Pool as ThreadPool
URL = 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=53f2c30b976c36e03457a1d6e85f72f0&text=XXXXXX&min_upload_date=YYYYYY&max_upload_date=ZZZZZZ&sort=relevance&extras=count_comments&per_page=500&format=json&nojsoncallback=1'
IMAGE_URL = 'https://farmFARM.staticflickr.com/SERVER/PHOTOID_SECRET.jpg'
COMMENTS_URL = 'https://api.flickr.com/services/rest/?method=flickr.photos.comments.getList&api_key=53f2c30b976c36e03457a1d6e85f72f0&photo_id=PHOTOID&format=json&nojsoncallback=1'
HASHTAGS = ['moron', 'loser', 'fatso']
POSTS_DIR = './posts/'
IMAGES_DIR = './images/'
NOW = datetime.datetime.today()
# Load profane words
badwords = []
with open('./bad-words.txt', 'r') as bwfile:
for line in bwfile:
badwords.append(line.replace('n', ''))
profanity.load_words(badwords)
# Persist
def persist(photo):
#import pdb;pdb.set_trace()
if(int(photo['count_comments']) >= 3):
#print photo['count_comments']
p_id = photo['id']
owner = photo['owner']
title = photo['title']
imgUrl = IMAGE_URL.replace('FARM', str(photo['farm'])).replace(
'SERVER', photo['server']).replace(
'PHOTOID', photo['id']).replace(
'SECRET', photo['secret'])
resp = urllib2.urlopen(COMMENTS_URL.replace('PHOTOID', photo['id']))
#print COMMENTS_URL.replace('PHOTOID', photo['id'])
comments = json.load(resp)
json_dict = {'id':p_id, 'owner':owner, 'title':title, 'comments':comments}
with open(POSTS_DIR + p_id + '.json', 'w') as outfile:
json.dump(json_dict, outfile)
f = open(IMAGES_DIR + p_id + '.jpg', 'wb')
f.write( urllib.urlopen(imgUrl).read() )
f.close()
# Crawl...
def delegate(h, from_date, to_date):
while( from_date > (NOW - relativedelta(years = 20)) ):
print h,'From', from_date, ' To ', to_date
#if( from_date < (NOW - relativedelta(years = 20)) ):
# return
from_date_epoch = str( int( time.mktime(from_date.timetuple()) ) )
to_date_epoch = str( int( time.mktime(to_date.timetuple()) ) )
#print URL.replace('XXXXXX', h).replace('YYYYYY', from_date_epoch).replace('ZZZZZZ', to_date_epoch)
data = requests.get( URL.replace('XXXXXX', h).replace('YYYYYY', from_date_epoch).replace('ZZZZZZ', to_date_epoch) ).text
try:
data = json.loads(data)
except Exception:
print 'sometimes json is not good'
continue
print data['photos']['total']
if(int(data['photos']['total']) > 3500):
#if(int(data['photos']['total']) > 35):
# Extract All Posts
pages = data['photos']['pages']
###################################
for i in range(1, pages + 1):
print ' Working on page', i
page_data = requests.get( URL.replace('XXXXXX', h).replace(
'YYYYYY', from_date_epoch).replace(
'ZZZZZZ', to_date_epoch) + '&page=' + str(i) ).text
try:
page_data = json.loads(page_data)
except Exception:
print 'sometimes json is not good'
continue
photos = page_data['photos']['photo']
for photo in photos:
persist(photo)
##############
#pool = ThreadPool(2)
#try:
#pool.map(persist, photos)
#except Exception:
#print 'SSL Error'
#pool.close()
#pool.join()
##############
from_date = from_date - relativedelta(days = 7)
to_date = from_date
#delegate(h, from_date - relativedelta(days = 7), from_date)
else:
from_date = from_date - relativedelta(days = 7)
#print 'here'
#delegate(h, from_date - relativedelta(days = 7), to_date)
for h in HASHTAGS:
delegate(h, NOW - relativedelta(days = 1), NOW )
#break
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team