Skip to content

Instantly share code, notes, and snippets.

@frankyxhl
frankyxhl / main.rs
Created Jul 20, 2019
Rust send smtp email by Zoho code example
View main.rs
// === 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 Feb 11, 2019
python http.server auto increment port
View http-server.py
#!/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 Jul 25, 2022
Python script to send email by zoho.com's mail service
View zoho_send_email.py
# 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
Brother RJ-3050AI ERROR CODE -34 problem
View BRSimplePrintViewController.swift
// 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 Sep 19, 2017
Remove useless packages in Pi
View Minimal Raspbian packages
#!/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 Jan 30, 2017
fast-paren-space
View elisp
;; 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)
View remove_salangane_books_ads
// ==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
webpage internal link animation
View internalLinkAnimation
$(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;
View paredit-mode
;; 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
View gist:4316454
(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 黑莓