Skip to content

Instantly share code, notes, and snippets.

@pedrovgp
pedrovgp / upsert_df.py
Last active August 22, 2024 05:32
Allow upserting a pandas dataframe to a postgres table (equivalent to df.to_sql(..., if_exists='update')
# Upsert function for pandas to_sql with postgres
# https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/8702291#8702291
# https://www.postgresql.org/docs/devel/sql-insert.html#SQL-ON-CONFLICT
import pandas as pd
import sqlalchemy
import uuid
import os
def upsert_df(df: pd.DataFrame, table_name: str, engine: sqlalchemy.engine.Engine):
@arnodeceuninck
arnodeceuninck / sheets-to-calendar.gs
Last active May 13, 2023 00:54
Import events from a Spreadsheet into Google Calendar. Written in Google Apps script, allows you to create a planning in Google Sheets, and then sync the dates written in the sheet to your calendar.
// ID of the calendar, can be found in sharing settings of the calendar
var calendarID = "winak.be_7somerandomcharacters@group.calendar.google.com"
// Input data from the sheet with name "Final Planning"
let planning = SpreadsheetApp.getActive().getSheetByName('Final Planning')
// Get cell values as strings in 2D array format
let eventsData = planning.getDataRange().getValues()
// Column name shortcuts, their index get determined in setRowIndices based on the column header
@bluewalk
bluewalk / GetNordVPNWireGuardDetails.md
Last active April 17, 2026 20:06
Getting NordVPN WireGuard details

About

Instructions to obtain WireGuard details of your NordVPN account. These can be used to setup a WireGuard tunnel on your router to NordVPN.

Source: https://forum.gl-inet.com/t/configure-wireguard-client-to-connect-to-nordvpn-servers/10422/27

Prerequisites

If you have any linux machine, use that or install a vm if you don't have one.

Get their official linux app installed. Make sure you have wireguard installed too. And set the used technology to Nordlynx by running nordvpn set technology nordlynx

@Webreaper
Webreaper / docker-compose.yml
Last active January 30, 2026 08:41
Sample Docker-compose file which shows how to set up Sonarr, Radarr, Prowlarr, Lidarr, QBittorrent and a VPN container so that all all traffic from the containers is routed through the VPN. Also includes Plex and get_iplayer containers, which are not routed through the VPN.
# Docker compose to set up containers for all services you need:
# VPN
# Sonarr, Radarr, Lidarr, Qbittorrent
# Non-VPN
# Plex, get_iplayer
# Before running docker-compose, you should pre-create all of the following folders.
# Folders for Docker State:
# /volume1/dockerdata. - root where this docker-compose.yml should live
# /volume1/dockerdata/plex - Plex config and DB
# /volume1/dockerdata/sonarr - Sonarr config and DB
@alfredlucero
alfredlucero / emailLinkRedirectCypress.ts
Last active July 9, 2022 15:45
Cypress Tips/Tricks - Using cheerio to parse email body contents, make cy.request() to links, follow redirect back to web app
// In some page_object.ts
// For this scenario, we have a Cypress test that triggers a download email to be sent to the user's inbox after performing
// some UI steps on the page i.e. clicking a button on the page to export data to a CSV for us to download
// We need to follow the download link in the email back to the web app we own and control to continue the test
redirectToCSVDownloadPageFromEmail({
user,
pass,
searchString,
}: {
user: string;
@JonahKr
JonahKr / climate.yaml
Last active April 18, 2023 08:33
Automation Template for managing Homeassistant Climate entities through events (Rhasspy)
# Manging Rhasspy calls for the climate entity
# A climate entity controls temperature, humidity, or fans, such as A/C systems and humidifiers.
# --> https://developers.home-assistant.io/docs/core/entity/climate/
automation:
#Changing the Temperature
- alias: Rhasspy Set Temperature
description: Set new target temperature
trigger:
- event_data: {}
@prasanthmj
prasanthmj / messages.html
Last active January 29, 2024 17:50
Parse and extract data from Gmail to Google Sheet. Read full article here: http://blog.gsmart.in/parse-and-extract-data-from-gmail-to-google-sheets/
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<title>Message Display Test</title>
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
</head>
<body style="padding:3em;">
<h1>Messages</h1>
<ul>
@sferich888
sferich888 / requests-saml.py
Last active January 13, 2023 06:59
Example SAML implementation using Python Requests
from requests.auth import AuthBase
class SAML(AuthBase):
from bs4 import BeautifulSoup
"""Implemeents SSO with RH auth.redhat.com"""
def __init__(self, username, password):
# setup any auth-related data here
self.username = username
self.password = password
function YNABAccounts(accessToken, budgetId) {
const accounts = _getBudgetAccounts(accessToken, budgetId);
if(accounts == null) {
return null;
}
const columns = ["Name", "Type", "Budget", "Closed", "Balance"];
const rows = accounts.map(function (acc) {
return [
@thomassuckow
thomassuckow / ExtractEmailBodyText.java
Created November 10, 2017 16:30
Nifi Extract Email Body Text Processor
package foo;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.nio.charset.StandardCharsets;
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.documentation.CapabilityDescription;