Skip to content

Instantly share code, notes, and snippets.

@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 / zoho_send_email.py
Last active December 4, 2024 17:10
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 / 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 / internalLinkAnimation
Created May 25, 2015 04:16
webpage internal link animation
$(function(){
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 1000);
return false;
;; Webpage: http://emacswiki.org/emacs/ParEdit
(require 'paredit)
(add-hook 'emacs-lisp-mode-hook (lambda () (paredit-mode 1)))
(add-hook 'lisp-mode-hook (lambda () (paredit-mode 1)))
(add-hook 'lisp-interaction-mode-hook (lambda () (paredit-mode 1)))
(add-hook 'python-mode-hook (lambda () (paredit-mode 1)))
(add-hook 'scheme-mode-hook (lambda () (paredit-mode 1)))
(add-hook 'clojure-mode-hook (lambda () (paredit-mode 1)))
;;https://github.com/grettke/parenface
(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 黑莓