Skip to content

Instantly share code, notes, and snippets.

View elowy01's full-sized avatar

Ernesto Lowy elowy01

  • Biofidelity
  • Cambridge, UK
View GitHub Profile
# Information about classes
https://www.codecademy.com/learn/learn-c-plus-plus/modules/learn-cpp-classes-and-objects/cheatsheet
# Information about pointers
https://www.codecademy.com/learn/learn-c-plus-plus/modules/learn-cpp-references-and-pointers/cheatsheet
### Document on to deal with Excel (.xlsx) files in Python
# read-in Excel files into Pandas DF
import pandas as pd
DF = pd.read_excel('path/file.xlsx', 1) # 1 is the ix of the worksheet
# we want to parse
# concatenate different workbooks into a single workbook
# ex extracted from :
# https://towardsdatascience.com/merging-spreadsheets-with-python-append-f6de2d02e3f3
import math
try:
print(math.sqrt(-9))
except ValueError:
print("inf")
else:
print("fine")
finally:
print("the end")
#### Lambdas
In Python, a lambda function is a single-line function declared with no name, which can have any number of arguments, but it can only have one expression.
is a function without a name (you can also call it an anonymous function)
# An example is a square function:
# this is equivalent
def square(num):
return num * num
##### SparkSQL
from pyspark import SparkContext as sc
from pyspark.sql import SparkSession
spark1 = SparkSession.builder.appName('SQL').getOrCreate()
# read-in a .csv file on stocks
df = spark1.read.csv('appl_stock.csv',inferSchema=True,header=True)
# print the schema of the readed data
# Tutorial at:
https://towardsdatascience.com/scalable-python-code-with-pandas-udfs-a-data-science-application-dd515a628896
This tutorial shows how to apply a logistic Regression classifier in a distributes and parallelized mode to
a Pandas dataframe that will be converted through Pandas UDF and the model will be map-applied
# background on Reverse Proxy
https://www.middlewareinventory.com/blog/docker-reverse-proxy-example/#vuukle-emote
# docker apache example with reversed proxy enabled. Tutorial I followed successfully
https://www.middlewareinventory.com/blog/docker-reverse-proxy-example/
## ENUMS
// An example program to demonstrate working
// of enum in C
#include<stdio.h>
enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun};
int main()
{
## Reference documentation:
https://docs.github.com/en/free-pro-team@latest/rest/guides/getting-started-with-the-rest-api
# Basic curl get command:
curl https://api.github.com/zen
# The same but getting info on the headers:
curl -i https://api.github.com/zen
# Get info on a particular repo:
# Convert a time in UTC to BTC
import pytz
from datetime import datetime
tz = pytz.timezone('UTC')
naive_time = datetime.strptime('2016-04-05 15:00', '%Y-%m-%d %H:%M')
tz_time = tz.localize(naive_time)
london_tz = pytz.timezone('Europe/London')
london_time = tz_time.astimezone(london_tz)
print(tz_time)