Skip to content

Instantly share code, notes, and snippets.

@frankyxhl
frankyxhl / zoho_send_email.py
Last active March 24, 2024 23:45
Python script to send email by zoho.com's mail service
# Code from best solution in page below:
# https://help.zoho.com/portal/community/topic/zoho-mail-servers-reject-python-smtp-module-communications
import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.utils import formataddr
# Define to/from
sender = 'sender@example.com'
@frankyxhl
frankyxhl / main.rs
Created July 20, 2019 13:49
Rust send smtp email by Zoho code example
// === In Cargo.toml file======
// lettre = "0.9.2"
// lettre_email = "0.9.2"
// native-tls = "0.2.3"
// ============================
use lettre_email::Email;
use lettre::smtp::authentication::Credentials;
use lettre::{ClientSecurity, ClientTlsParameters, SmtpClient, Transport};
use native_tls::TlsConnector;
@frankyxhl
frankyxhl / http-server.py
Created February 11, 2019 07:45
python http.server auto increment port
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Try to run http.server. Default port is 8000.
If 8000 is in use, use 8001...
"""
import socket
import errno
@frankyxhl
frankyxhl / BRSimplePrintViewController.swift
Last active May 18, 2018 06:40
Brother RJ-3050AI ERROR CODE -34 problem
// This code works
// BRSimplePrintViewController.swift
// SDK_Sample_Swift
//
// Copyright © 2017 Brother Industries, Ltd. All rights reserved.
//
import Foundation
import UIKit
@frankyxhl
frankyxhl / Minimal Raspbian packages
Created September 19, 2017 16:43
Remove useless packages in Pi
#!/bin/bash
# -*- coding: utf-8 -*-
# @date: 2012-09-20
# @author: Frank.Xu
# @version: 0.1
# @description: Remove useless packages in Pi
sudo apt-get remove --purge wolfram-engine libreoffice*
sudo apt-get clean
sudo apt-get autoremove
@frankyxhl
frankyxhl / elisp
Created January 30, 2017 15:22
fast-paren-space
;; Fast paren mode 1.0
;; Copyright(C) 2012, CrLF0710
;; Please use this code under BSD license
(defun fast-paren-space ()
(interactive)
(if (member (preceding-char) '(0 9 10 32 40))
(if (and (symbol-value 'paredit-mode)
(symbol-function 'paredit-open-round))
(funcall 'paredit-open-round)
// ==UserScript==
// @name RemoveAdsOnSalangane-books
// @namespace salangane_books
// @author Frank_Xu
// @include http://salangane-books.com/*
// @version 1
// @grant none
// ==/UserScript==
// 本脚本去掉海燕烦人的广告
@frankyxhl
frankyxhl / sr-speedbar-emacs-config.el
Created September 25, 2012 07:07
sr-speedbar-emacs-config
;;===========================================================================
;;sr-speedbar-mode
;;===========================================================================
(require 'sr-speedbar)
;;默认显示所有文件
(custom-set-variables
'(speedbar-show-unknown-files t)
)
;;sr-speedbar-right-side 把speedbar放在左侧位置
;;sr-speedbar-skip-other-window-p 多窗口切换时跳过speedbar窗口
(eval-when (:compile-toplevel :load-toplevel :execute)
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init))))
(ql:quickload '(:split-sequence :alexandria))
(use-package :alexandria)
;; Color Spade 黑桃 Heart 红心 Diamond 红钻 Club 黑莓
@frankyxhl
frankyxhl / gist:4122935
Created November 21, 2012 04:01
RubyConfChina_Feedback
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
# @date: 2012-11-20
# @author: Frank_Xu franky.xhl[at]gmail.com I'm a Ruby Newbie~
# 变量设定
# qn = question number count
qn = 13
# filename
filename = "rslt.txt"