Skip to content

Instantly share code, notes, and snippets.

@yuyueugene84
yuyueugene84 / gmail.py
Created September 7, 2017 16:24 — forked from jasonrdsouza/gmail.py
Python script to access a gmail account and download particular emails
import email, getpass, imaplib, os
detach_dir = '.' # directory where to save attachments (default: current)
user = raw_input("Enter your GMail username:")
pwd = getpass.getpass("Enter your password: ")
# connecting to the gmail imap server
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user,pwd)
m.select("cs2043") # here you a can choose a mail box like INBOX instead
@yuyueugene84
yuyueugene84 / jupyterhub_aws.md
Created March 24, 2019 17:12 — forked from widdowquinn/jupyterhub_aws.md
Set up JupyterHub on AWS

JupyterHub on AWS

EC2 Setup

  • Log in to AWS
  • Go to a sensible region
  • Start a new instance with Ubuntu Trusty (14.04) - compute-optimised instances have a high vCPU:memory ratio, and the lowest-cost CPU time. c4.2xlarge is a decent choice.
  • Set security group (firewall) to have ports 22, 80, and 443 open (SSH, HTTP, HTTPS)
  • If you want a static IP address (for long-running instances) then select Elastic IP for this VM
  • If you want to use HTTPS, you'll probably need a paid certificate, or to use Amazon's Route 53 to get a non-Amazon domain (to avoid region blocking).
Sub CalculateCorr4()
Dim corrSheet As Worksheet
Set corrSheet = Worksheets("闽┦だ猂")
Dim portSheet As Worksheet
Set portSheet = Worksheets("щ戈舱厨筍だ猂")
Dim corr As Double
Dim i As Integer
For i = 2 To 13
corr = Application.WorksheetFunction.Correl(portSheet.Range("B2:B95").Value, _
Sub CalculateCorr4()
Dim corrSheet As Worksheet
Set corrSheet = Worksheets("相關性分析")
Dim portSheet As Worksheet
Set portSheet = Worksheets("投資組合報酬分析")
Dim corr As Double
Dim i As Integer
Dim j As Integer
For j = 2 To 13
Sub CalculateCorr4()
Dim corrSheet As Worksheet
Set corrSheet = Worksheets("相關性分析")
Dim portSheet As Worksheet
Set portSheet = Worksheets("投資組合報酬分析")
Dim corr As Double
Dim i As Integer
Dim j As Integer
For j = 2 To 13
Sub InputFill()
'Cells(Cells(1, "B").Value, Cells(2, "B").Value ) ' ¨Ï¥ÎªÌ«ü©wªº°_©lÀx¦s®æ
'Cells( Cells(3, "B").Value, Cells(4, "B").Value ) '¨Ï¥ÎªÌ«ü©wªºµ²§ôÀx¦s®æ
Range(Cells(Range("B1").Value, Range("B2").Value), Cells(Range("B3").Value, Range("B4").Value)).Value = Range("B5").Value
End Sub
Sub CalculateReturnValue()
Dim i As Integer
Dim j As Integer
For j = 3 To 7 Step 2
For i = 3 To 24
Cells(i, j).Value = (Cells(i, j - 1).Value - Cells(i - 1, j - 1).Value) / Cells(i - 1, j - 1).Value
Next i
Next j
Sub CalculateCorr4()
Dim corrSheet As Worksheet
Set corrSheet = Worksheets("相關性分析")
Dim portSheet As Worksheet
Set portSheet = Worksheets("投資組合報酬分析")
Dim corr As Double
Dim i As Integer
Dim j as Integer
@yuyueugene84
yuyueugene84 / rps.py
Last active September 12, 2023 02:29
import random
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
# 玩家出拳
user_hand = int(input("請出拳 (1) 剪刀 (2) 石頭 (3) 布:"))
# 電腦出拳
comp_hand = random.randint(1,3)
# 判斷玩家是贏還是輸
if user_hand == comp_hand:
from random import randint
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
user_score = 0
comp_score = 0
draw = 0
for i in range(1, 4):