Skip to content

Instantly share code, notes, and snippets.

View andy6804tw's full-sized avatar
💻
Follow my YouTube channel https://reurl.cc/4R1jy2

Yi Lin Tsai andy6804tw

💻
Follow my YouTube channel https://reurl.cc/4R1jy2
View GitHub Profile
@andy6804tw
andy6804tw / tello_get_battery.py
Last active July 17, 2022 09:02
Check tello wifi connection and get current battery.
import subprocess
import time
import pywifi
from pywifi import const
import socket
import threading
"""
Global variable
"""
@andy6804tw
andy6804tw / get_mac_SSID.py
Created July 15, 2022 15:06
Get Wifi information on mac using Python
import subprocess
def get_wifi_info_mac():
process = subprocess.Popen(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport','-I'], stdout=subprocess.PIPE)
out, err = process.communicate()
process.wait()
wifi_info = {}
for line in out.decode("utf-8").split("\n"):
if ": " in line:
@andy6804tw
andy6804tw / get_win_SSID.py
Last active July 15, 2022 15:07
Get Wifi information on windows using Python
import subprocess
def get_wifi_info_win():
out = subprocess.check_output('netsh wlan show interfaces')
wifi_info = {}
for line in out.decode("utf-8", errors="ignore").split("\n"):
if ": " in line:
key, val = line.split(": ")
key = key.replace(" ", "")
val = val.strip()
from tensorflow import keras
from tensorflow.keras import layers
class network(keras.Model):
def __init__(self):
super(network,self).__init__()
self.layer_1 = layers.Dense(8 , activation='relu')
self.layer_2 = layers.Dense(16 , activation='relu')
self.output_layer = layers.Dense(3 , activation='softmax')
from tensorflow.keras import layers
from tensorflow.keras.models import Model
def build_model():
model_input = layers.Input(shape=(X.shape[-1],))
x = layers.Dense(8,activation='relu')(model_input)
x = layers.Dense(16,activation='relu')(x)
model_output = layers.Dense(3,activation='softmax')(x)
return Model(model_input ,model_output)
from tensorflow.keras.layers import Dense, Activation
from tensorflow.keras import Sequential
model = Sequential()
model.add(Dense(8, Activation('relu'), input_dim=X.shape[-1]))
model.add(Dense(16, Activation('relu')))
model.add(Dense(3, Activation('softmax')))
public class Main {
static int arr[]= {1,2,3,4,5}; // S集合
static int ans[]=new int[3]; // 從集合中取三個的組合
public static void main(String[] args) {
backtracking(0,0);
}
public static void backtracking(int n,int pos) {
if(n==3) { // 若dimension維度是第三層代表找完答案依序印出並結束遞迴
for(int i=0;i<3;i++) {
System.out.print(ans[i]+" ");
@andy6804tw
andy6804tw / [C_ST49-易] 字串取代.java
Last active March 29, 2018 02:52
https://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=7009 這題直接用JAVA的(replaceAll)將單字做取代替換就行了
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
String str=scn.nextLine();
String arr[]= {"hate","stupid","angry","dirty"},arr2[]= {"love","smart","happy","clean"};
for(int i=0;i<4;i++)
str = str.replaceAll(arr[i], arr2[i]);
@andy6804tw
andy6804tw / [C_ST35-易] 抱怨值問題.java
Last active March 29, 2018 02:52
https://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?a=1154 一開始寫完交出去結果回傳1,仔細看題目發現原來數字間除了逗號外還可能包含多個空白! 所以解婕辦法是先將所有的空白用(replaceAll)取代空字串,最後再用(split)來切逗號數字,這題是找目前數字之前有幾個比自己還大,所以利用O(n2)方式下去搜。
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
String str=scn.nextLine().replaceAll(" ", "");
String arr[]=str.split(",");
int count =0;
for(int i=0;i<arr.length;i++) {
@andy6804tw
andy6804tw / [C_ST38-中] 字數統計.java
Last active March 29, 2018 02:52
https://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=2691 題目有說道要去除標點符號,所以利用字串取代(replaceAll)將遇到的標點符號改為空字串,之後再使用字串切割(split)將字串切成陣列,最後在陣列走訪依序的計算每個單字的數量,比對單字是否存在時可以統一將單字轉成小寫(toLowerCase)
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
String str="";
while(scn.hasNext()) {
str+=scn.nextLine()+" ";
}