Skip to content

Instantly share code, notes, and snippets.

View dvdme's full-sized avatar

David Ervideira dvdme

View GitHub Profile
"""
Example usage of the function `group_json_by_key`
"""
import json
JSON_EXAMPLE_STR = """
{
"color": {
"0": "yellow",
"1": "red"
@dvdme
dvdme / install-docker-18.04.sh
Last active December 1, 2019 17:33
Install Docker on Ubuntu 18.04
#!/bin/bash
# Install with instructions from Docker
apt-get remove docker docker-engine docker.io containerd runc
apt-get update
apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
@dvdme
dvdme / Flatten.cs
Last active December 12, 2022 07:09
C# List of lists Flattener
public static class ListExtension
{
/// <summary>
/// Creates a single flat list from a list of lists input.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="inListOfLists"></param>
/// <returns>A single flatten list from a list of lists input</returns>
public static List<T> Flatten<T>(this List<List<T>> inListOfLists)
{
@dvdme
dvdme / PyFor.md
Last active September 3, 2016 16:17

External modules, requests, json, list comprehension and (simple) webservers

  • In this part we will talk about how to install external modules, installing and using one of the most popular ones, requests, that is used to make http requests.

Install the requests module

pip install requests
@dvdme
dvdme / past_weather_data.py
Last active April 23, 2016 18:19
Get weather data from different cities from the past with forecastiopy
from forecastiopy import *
apikey = 'YOUR_APY_KEY'
Lisbon = [38.7252993, -9.1500364]
Madrid = [40.383333, -3.666667]
Paris = [48.866667, 2.332778]
def print_icon(lat, lon):
@dvdme
dvdme / forecastiopy-daily-example.py
Created January 6, 2016 21:48
Hot to use forecastiopy module to retrieve maximum temperature, minimum temperature and precipitation information for all daily data. Raw
from forecastiopy import *
apikey = 'YOUR_API_KEY'
Lisbon = [38.7252993, -9.1500364]
# 'units', 'lang' and 'exclude' options are optional but it is nice to ensure that
# the reply comes in correct language and unit. Setting the 'exclude' option
# reduces the reply size. If ou don't need the data, don't ask for it.
@dvdme
dvdme / forecastiopy-daily-example2.py
Created January 6, 2016 21:46
Hot to use forecastiopy module to retrieve maximum temperature, minimum temperature and precipitation information for only one day from daily data.
from forecastiopy import *
apikey = 'YOUR_APY_KEY'
Lisbon = [38.7252993, -9.1500364]
# 'units', 'lang' and 'exclude' options are optional but it is nice to ensure that
# the reply comes in correct language and unit. Setting the 'exclude' option
# reduces the reply size. If ou don't need the data, don't ask for it.