Skip to content

Instantly share code, notes, and snippets.

View stanwu's full-sized avatar

Stan Wu (吳信典) stanwu

View GitHub Profile
@stanwu
stanwu / .htaccess
Created October 16, 2020 07:16
Bluehost force SSL
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@stanwu
stanwu / imap_body_decoding.php
Created October 1, 2020 03:41
PHP IMAP decoding messages
<?php
$hostname = '{********:993/imap/ssl}INBOX';
$username = '*********';
$password = '******';
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to server: ' . imap_last_error());
$emails = imap_search($inbox,'ALL');
if($emails) {
@stanwu
stanwu / clean_gradle.sh
Created September 29, 2020 07:42
Clean up your gradle
#!/bin/bash
echo "Before:"
du -h -d 0 .gradle
find ~/.gradle -type f -atime +30 -delete
find ~/.gradle -type d -mindepth 1 -empty -delete
echo "Now:"
du -h -d 0 .gradle
@stanwu
stanwu / telnet.py
Last active September 27, 2020 15:03
python telnet example
import getpass
import telnetlib
#
# Please remove line 8, 10 if use for HTTP port 80 only
# class telnetlib.Telnet(host=None, port=0[, timeout])
#
HOST = "localhost"
user = input("Enter your remote account: ")
@stanwu
stanwu / de.py
Created September 9, 2020 14:45
Full Code Example (decode)
from cryptography.fernet import Fernet
def load_key():
"""
Load the previously generated key
"""
return open("secret.key", "rb").read()
def decrypt_message(encrypted_message):
"""
@stanwu
stanwu / en.py
Created September 9, 2020 14:43
Full Code Example (encode)
from cryptography.fernet import Fernet
def generate_key():
"""
Generates a key and save it into a file
"""
key = Fernet.generate_key()
with open("secret.key", "wb") as key_file:
key_file.write(key)
#!/bin/bash
for i in `cat dingding.txt`
do
ip=`nslookup $i | grep Address | grep -v 8.8.8.8 | awk '{print $2}'`
echo $i
echo $ip
done
@stanwu
stanwu / .screenrc
Created September 3, 2017 07:03 — forked from onsails/.screenrc
My .screenrc
# GNU Screen configuration file
#
# Balaji S. Srinivasan <balajis_at_stanford_dot_edu>
# This file can be found at http://jinome.stanford.edu/stat366/unix/.screenrc
# Modified to play well with emacs, by moving Ctrl-A to Ctrl-T
# Modification of original files by Sven Guckes, Sarunas Vancevicius, and Mike Perry
# Sarunas Vancevicius original: http://www.redbrick.dcu.ie/~svan/configs/screenrc
# Mike Perry original: http://fscked.org/writings/225notes/unix/.screenrc

JSI Tip 0470 - How to launch a program before the shell (Explorer) starts.

Mar 27, 1998 Jerold Schulman In tip 074, I explained how to change the Shell for selected users.

Using the same technique, you can launch an application before the Shell, so as to avoid any interaction with it.

Leaving the Shell as Explorer.exe, edit: