Skip to content

Instantly share code, notes, and snippets.

View alucard001's full-sized avatar

Ellery Leung alucard001

View GitHub Profile
@alucard001
alucard001 / apns.py
Created June 2, 2017 04:13
Python Apple Push Notification HTTP/2 Example - Silent Push
"""
Use HTTP/2 send APNS Example main reference
===========================================
http://gobiko.com/blog/token-based-authentication-http2-example-apns/
Error 410 to detect uninstalls
==============================
https://leftshift.io/mobile-tracking-uninstalls-on-ios-and-android
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1
@alucard001
alucard001 / send_email_with_attachments.py
Created January 18, 2024 03:01 — forked from kuharan/send_email_with_attachments.py
Send email with attachments in AWS lambda
def send_email(sender, recipient, aws_region, subject, file_name):
# The email body for recipients with non-HTML email clients.
BODY_TEXT = "Hello,\r\nPlease find the attached file."
# The HTML body of the email.
BODY_HTML = """\
<html>
<head></head>
<body>
<h1>Hello!</h1>
<p>Please find the attached file.</p>
@alucard001
alucard001 / data_source.py
Last active January 24, 2024 07:06
Python3 AWS Lambda Send email with CSV attachment full code
"""
Again, don't just copy and paste the code below. This is for your study only.
Change the code to suit your case accordingly.
"""
import logging
import csv
import zipfile
from zoneinfo import ZoneInfo
@alucard001
alucard001 / GoogleIndexing.py
Created May 27, 2019 04:49
Google Indexing API V3 Working example with Python 3
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
import json
import pandas as pd
# https://developers.google.com/search/apis/indexing-api/v3/prereqs#header_2
JSON_KEY_FILE = "json_key_file_downloaded_after_creating_your_google_service_account_see_above_details_on_how_to_do.json"
SCOPES = ["https://www.googleapis.com/auth/indexing"]
@alucard001
alucard001 / sample.py
Created May 1, 2024 13:41
Ollama using Chinese embedding model and Qwen to answer question
import ollama
import chromadb
import os
# Read files in `data` dir as string
# and create a list of documents
data_dir = 'data'
files = os.listdir(data_dir)
documents = []
for file in files:
@alucard001
alucard001 / Dockerfile
Last active May 4, 2024 01:19
Docker + Laravel + Nginx + Swoole Reverse Proxy Setup
FROM php_base:latest
RUN apt update -y && apt upgrade -y
WORKDIR /var/www/html
RUN composer update --optimize-autoloader
COPY src/. /var/www/html
COPY build/php/.env.local /var/www/html/.env