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
import requests | |
class Scraper: | |
''' Request information and Scrape data class ''' | |
def __init__(self,ip=None): | |
self.address = 'http://ip-api.com/json/' | |
self.ip = ip | |
def get_geo_ip_info(self): | |
'''Collect geo ip info''' |
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
import re | |
log_list = [] | |
hosts = set() | |
hosts_status = set() | |
test_str = '' | |
filepath = 'problem-2.txt' | |
with open(filepath) as fp: | |
test_str = fp.read().strip() |
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
# Add User Non-interactively without password | |
1. sudo adduser --disabled-password --gecos "" username | |
# Grant root access to the user so s/he can execute sudo without a password. | |
1. sudo visudo | |
#After includedir /etc/sudoers.d put-. | |
2. username ALL=(ALL) NOPASSWD: ALL | |
# Create a folder named .ssh in the user’s home directory. | |
1. mkdir /home/username/.ssh |
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
BEGIN TRANSACTION; | |
CREATE TABLE Students (ID integer PRIMARY KEY, Name varchar(255)); | |
CREATE TABLE Friends (ID integer PRIMARY KEY, Friend_ID integer); | |
CREATE TABLE Packages (ID integer PRIMARY KEY, Salary float(23,19)); | |
INSERT INTO Students (ID,Name) | |
VALUES (1,'Ashley'); | |
INSERT INTO Students (ID,Name) | |
VALUES (2,'Samantha'); |
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
<!DOCTYPE html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<script>L_PREFER_CANVAS=false; L_NO_TOUCH=false; L_DISABLE_3D=false;</script> | |
<script src="https://cdn.jsdelivr.net/npm/leaflet@1.3.4/dist/leaflet.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.3.4/dist/leaflet.css"/> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/> |
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
import os | |
import pandas as pd | |
import numpy as np | |
import random | |
import django | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'categorized_affect_map.settings') | |
django.setup() | |
from classification.models import Category, Feature | |
from django.utils import timezone |
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
import os | |
import pandas as pd | |
import numpy as np | |
import random | |
import django | |
from django.utils import timezone | |
from populate_weather import get_location,get_weather | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'categorized_affect_map.settings') | |
django.setup() |
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
import requests | |
def get_weather(latitude_,longitude_): | |
# latitude = latitude_ | |
# longitude = longitude_ | |
# url = 'http://api.openweathermap.org/data/2.5/weather?lat={}&lon={}&appid=8f47bbfcc82517d109015de292ab80cd&units=metric'.format(latitude, longitude) | |
# res = requests.get(url) | |
# data = res.json() | |
response = dict(main="Haze",desc="haze",temp=18,pressure=1014,humidity=72,temp_min=18,temp_max=18,wind_speed=1.5,wind_degree=310,datetime=1544556600,clouds_all=20,sys_sunrise=1544488256,sys_sunset=1544526753) | |
return response |
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
# http://en.wikipedia.org/wiki/Extreme_points_of_the_United_States#Westernmost | |
top = 49.3457868 # north lat | |
left = -124.7844079 # west long | |
right = -66.9513812 # east long | |
bottom = 24.7433195 # south lat | |
def cull(l): | |
c = [] | |
for (lat, lng) in l: | |
if bottom <= lat <= top and left <= lng <= right: |
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
There is a known method to emulate a container for variables, which support both methods of access: by a variable's name and a string key. | |
class Vars: | |
def __init__(self, **kw): | |
self.__dict__.update(kw) | |
def __getitem__(self, key): | |
return self.__dict__[key] | |
def __setitem__(self, key, val): |
OlderNewer