This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: UTF-8 -*- | |
""" | |
https://blog.ittraining.com.tw/2024/10/normal-distribution.html | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
#from matplotlib.mlab import bivariate_normal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import statsmodels.api as sm | |
def process_stock_data(df): | |
# Copy the DataFrame to avoid modifying the original |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openai | |
# Replace 'YOUR_API_KEY' with your actual API key from OpenAI | |
api_key = 'YOUR_API_KEY' | |
# Initialize the OpenAI API client | |
openai.api_key = api_key | |
# Specify the prompt for text generation | |
prompt = "Once upon a time," |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ocr_by_goole_vision(input_file='captcha.png',draw_text=False): | |
with io.open(input_file, 'rb') as image_file: | |
content = image_file.read() | |
response = client.text_detection(image=vision.Image(content=content)) | |
if response.error.message: | |
raise Exception( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = [[]]*3 #[[], [], []] | |
print(c) | |
c[0].append(100) | |
print(c) | |
print(id(c[0])) #c[0]==c[1]==c[2] | |
print(id(c[1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from itertools import chain | |
from itertools import chain, combinations | |
''' | |
Why do we use frozenset ? | |
Example 1: | |
count[{'B','C'}]+=1 # TypeError Error : "unhashable type: 'set'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main () | |
{ | |
char method_str[]="GET /doc/test.html HTTP/1.1 \r\n"; | |
char *url; | |
char *protocol; | |
char *end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
//#define DEBUG 3 | |
#ifdef DEBUG | |
#define debug(fmt,args...) printf (fmt ,##args) | |
#define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args); | |
#else | |
#define debug(fmt,args...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t *lock) | |
{ | |
unsigned long flags; | |
local_irq_save(flags); // local CPU 中斷關閉, 防ISR搶 | |
preempt_disable(); // preemptive 也禁止, 防止process 也來互搶 | |
spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// blink.c | |
// | |
// Example program for bcm2835 library | |
// Blinks a pin on an off every 0.5 secs | |
// | |
// After installing bcm2835, you can build this | |
// with something like: | |
// gcc -o blink blink.c -l bcm2835 | |
// sudo ./blink | |
// |
NewerOlder