Skip to content

Instantly share code, notes, and snippets.

@saulcosta
saulcosta / glacier_uploader.py
Last active July 20, 2022 21:39
A quick Python script for uploading an archive file to an AWS Glacier storage vault.
'''
A quick Python uploader script for pushing files to AWS Glacier storage.
Assumptions:
1) You have boto installed (eg. with pip)
2) You have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY set as environment variables
Based (very loosely) on some code found here:
http://forrestbao.blogspot.com/2013/06/amazon-glacier-in-python-with-boto-part.html
'''
@saulcosta
saulcosta / style.css
Created March 10, 2016 07:16
Cleaner scrollbar
// ------------- //
// Google Chrome //
// ------------- //
::-webkit-scrollbar {
width: 7px; // width of vertical scrollbar
height: 7px; // height of horizontal scrollbar
}
// Part of scrollbar that moves up and down as you scroll
::-webkit-scrollbar-thumb {
@saulcosta
saulcosta / weather.py
Last active February 6, 2019 03:24
Python OpenWeatherMap example 2
import pyowm
owm = pyowm.OWM('<api_key>') # TODO: Replace <api_key> with your API key
la = owm.three_hours_forecast('Los Angeles, US')
print(la.will_have_clouds())
@saulcosta
saulcosta / forecast.py
Created February 6, 2019 03:23
Python OpenWeatherMap example 1
import pyowm
owm = pyowm.OWM('<api_key>') # TODO: Replace <api_key> with your API key
london = owm.three_hours_forecast('London, GB')
print(london.will_have_rain())
print(london.will_have_fog())
@saulcosta
saulcosta / temperature.py
Created February 6, 2019 03:25
PyOWM example 3
import pyowm
owm = pyowm.OWM('<api_key>') # TODO: Replace <api_key> with your API key
sf = owm.weather_at_place('San Francisco, US')
weather = sf.get_weather()
print(weather.get_temperature('fahrenheit')['temp'])
@saulcosta
saulcosta / sunrise_sunset.py
Created February 6, 2019 03:25
PyOWM example 4
import pyowm
owm = pyowm.OWM('<api_key>') # TODO: Replace <api_key> with your API key
boston = owm.weather_at_place('Boston, US')
weather = boston.get_weather()
print(weather.get_sunrise_time(timeformat='iso')) # Prints time in GMT timezone
print(weather.get_sunset_time(timeformat='iso')) # Prints time in GMT timezone
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
@saulcosta
saulcosta / main.py
Created May 6, 2019 16:14
Example calculator Python script.
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
Hostname "localhost"
FQDNLookup true
BaseDir "/var/lib/collectd"
PluginDir "/usr/lib/collectd"
#TypesDB "/usr/share/collectd/types.db" "/etc/collectd/my_types.db"
AutoLoadPlugin false
CollectInternalStats false
LoadPlugin logfile
<Plugin logfile>
LogLevel "info"
File "/root/sandbox/collectd.log"
PrintSeverity true
</Plugin>